Day 29 of viz with me

Data viz Beginner ggplot quarto video reproducibility DataViz Challenge

A reproducible document of all that we learnt.


Author

Affiliation

Soundarya Soundararajan

 

Published

Oct. 28, 2024

Citation

Soundararajan, 2024


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 . Let’s get started.

Keep your script handy as we’ll be copying and pasting code from it into our Quarto document.

Step-by-Step Guide

Viz by Soundarya
  1. Install Quarto

If you haven’t already, install Quarto.

Then in your console, install the quarto package.

install.packages("quarto")
  1. Creating the Quarto Document

Go to File > New File > Quarto Document. Give it a name.

  1. Set Up the YAML Header

At the top of your Quarto document, include a YAML header like this:

YAML 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.

  1. Copy and Paste Your Code

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.

This is how you insert a new chunk
This is how a code chunk looks
  1. Render Your Document

Once you are done with your document, click the “Render” button to knit your document.

Tips and Suggestions

Avoid Installing Packages Inside the 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.

Text Between Code Chunks

Use plain text to explain your code between code chunks, creating a narrative flow.

Anatomy of a Quarto Document

  1. YAML Header: This is where you define the document’s title. YAML can do much more, but for now, we’ll keep it simple.

  2. 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.

  3. 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.

Video demo

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!

Footnotes

    References

    Allaire, JJ, and Christophe Dervieux. 2024. “Quarto: R Interface to ’Quarto’ Markdown Publishing System.” https://CRAN.R-project.org/package=quarto.

    Citation

    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}
    }