A reproducible document of all that we learnt.
Welcome to Day 29
Goals for today: Creating Your Reproducible Document
Today, we’ll bring everything together by creating a reproducible document that captures all we’ve learned in this series. We’ll use a Quarto
document for this, enabling us to blend text, code, and output seamlessly (Allaire and Dervieux 2024). Let’s get started.
Keep your script handy as we’ll be copying and pasting code from it into our Quarto document.
If you haven’t already, install Quarto.
Then in your console, install the quarto
package.
install.packages("quarto")
Go to File > New File > Quarto Document. Give it a name.
At the top of your Quarto document, include a YAML header like this:
I have deliberately kept it very simple. You can add more details to it. In fact YAML can do a lot more. If interested read what all you can do with YAML here.
Transfer the code from each day into code chunks within your Quarto document.
What are code chunks? They are sections of code that you can run independently. They start with three backticks followed by {r}
and end with three backticks. You can just type them or use the insert chunk button on top right of the document.
Once you are done with your document, click the “Render” button to knit your document.
Installing packages directly in the document causes them to reinstall each time it’s knitted. Instead, install packages outside the document. You already have all the packages you need from this series. So simply call the libraries inside the document. If you use any library which is not installed, you can install it once and then call it in the document.
Use plain text to explain your code between code chunks, creating a narrative flow.
YAML Header: This is where you define the document’s title. YAML can do much more, but for now, we’ll keep it simple.
Code Chunks: Start each code chunk with three backticks followed by {r} and end with three backticks. Running Chunks: Test each chunk individually by running them before knitting.
Text: Use plain text to explain your code and results in between the code chunks.
Running Chunks: Test each chunk individually by running them before knitting.
See me walkthrough the steps in this video.
And that’s it! You now have a reproducible document summarizing everything learned in this series. Looking forward to Day 30!
For attribution, please cite this work as
Soundararajan (2024, Oct. 29). My R Space: Day 29 of viz with me. Retrieved from https://github.com/soundarya24/SoundBlog/posts/2024-10-29-day-29-of-viz-with-me/
BibTeX citation
@misc{soundararajan2024day, author = {Soundararajan, Soundarya}, title = {My R Space: Day 29 of viz with me}, url = {https://github.com/soundarya24/SoundBlog/posts/2024-10-29-day-29-of-viz-with-me/}, year = {2024} }