Reproducible Reporting
with Quarto

Jadey Ryan // April 25, 2024
Community Engaged Data Science
College of the Atlantic

Acknowledgements

Community Engaged Data Science Logo

College of the Atlantic Logo

Purple R Ladies Logo


R/Medicine Data Cleaning 2023 Workshop taught by Crystal Lewis, Shannon Pileggi, and Peter Higgins


ASA Traveling Courses on Quarto taught by Mine Çetinkaya-Rundel and Andrew Bray

Disclaimer and license

Opinions expressed are solely my own and do not express the views of my employer or any organizations I am associated with.


This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA).

Jadey Ryan

Data scientist at WA Dept of Agriculture

The Coding Cats: cat & code themed merch

jadeyryan.com

@jadeynryan

linkedin.com/in/jadey-ryan

jadeynryan

thecodingcats.etsy.com

Three snowshoe siamese cats in loaf mode. From left to right: Tai, Mai, and Skye

Jadey collecting a bulk density soil sample in a field of wheat stubble.

Participation

Log in to Posit Cloud work space:

https://posit.cloud/spaces/504211/content/8093007


If Posit Cloud doesn’t work, download materials locally:

usethis::use_course(
  "https://github.com/jadeynryan/parameterized-quarto-workshop/raw/coa-ceds/exercises/ceds-quarto-exercises.zip"
#  ,destdir = "___"
  )


Workshop structure: presentation, 💃🏻 demos, 💪🏻 exercises

💪🏼 Exercise 0

Student introductions:

  • Your name

  • Briefly describe your community project & what you’re hoping to learn from this workshop

Community partner // Maine UseR introductions:

  • Your name, position title, and affiliation

  • Briefly describe how you use R Markdown or Quarto

15:00

Learning objectives

  • Learn what Quarto is and what you can use it for.

  • Learn how to weave code and text together to create a fully reproducible report.

  • Learn how to use parameters to create variations of a report.

Syntax and RStudio aside

Pipes

  • 2014+ magrittr pipe %>%

  • 2021+ (R \(\geq\) 4.1.0) native R pipe |>

Isabella Velásquez’s blog post Understanding the native R pipe |> (2022)


do_something(arg1, arg2, arg3, ...)

arg1 |>  
  do_something(arg2, arg3)
mean(0:10)

0:10 |> 
  mean()


To change shortcut to the native pipe:

ToolsGlobal OptionsCodeEditingUse Native Pipe Operator

Windows: Ctrl + Shift + M

Mac: Cmd + Shift + M

Namespacing

package::function()

dplyr::select()

  • tells R explicitly to use the function select from the package dplyr

  • helps avoid name conflicts (e.g., MASS::select())

  • does not require library(dplyr)

library(dplyr)

mtcars |>  
  select(mpg, cyl) 
# library(dplyr) not needed

mtcars |>  
  dplyr::select(mpg, cyl) 

RStudio options

ToolsGlobal Options

  • Fussy YAML indentation:

    CodeDisplayIndentation guides:Rainbow lines


  • Match parentheses:

    CodeDisplayIndentation guides: → Check Use rainbow parentheses


  • Matching divs:

    R MarkdownAdvanced → Check Use rainbow fenced divs

R Markdown → Quarto

R Markdown is an authoring framework supported by many R packages

Figure from “Hello, Quarto” keynote by Julia Lowndes and Mine Çetinkaya-Rundel, presented at RStudio::Conf(2022).

Quarto is a publishing system that supports many multiple & outputs

Artwork from “Hello, Quarto” keynote by Julia Lowndes and Mine Çetinkaya-Rundel, presented at RStudio::Conf(2022). Illustrated by Allison Horst.

A schematic representing rendering of Quarto documents from .qmd, to knitr or jupyter, to plain text markdown, then converted by pandoc into any number of output types including html, PDF, or Word document.

R Markdown vs Quarto

R Markdown

  • Vast R Markdown ecosystem

  • Dependent on R

Quarto

  • Command line interface (CLI)

  • Expands R Markdown ecosystem

  • “Batteries included”

  • Multi-language and multi-engine


If you’re happy with R Markdown and it’s not broken, no need to switch!


R Markdown will still be maintained but likely no new features (Xie 2022).

How I use Quarto

Screenshot of this workshop website built with Quarto

Screenshot of workshop slides built with Quarto and revealjs

Screenshot of my personal website built with Quarto

Screenshot of my personal blog built with Quarto

Screenshot of HTML report titled QC Summary of 2020-2023 Results, Author Jadey Ryan, Published August 28, 2023, Table of contents, a bullet point list summary, and a table with summary statistics. There is a scroll bar on the right, indicating the report has much more content than shown.

2021 MS Word report for soil health survey participant, generated from a parameterized Quarto report.

2023 MS Word report for soil health survey participant, generated from a parameterized Quarto report.

2023 HTML report for soil health survey participant, generated from a parameterized Quarto report.

More real-world applications of Quarto

Quarto gallery

Quarto website showcase

New format type: manuscripts

New format type: dashboards

Convert .Rmd.qmd

  1. Change file extension from .Rmd.qmd
  2. Change YAML header (output:format:)
  3. Convert chunk headers with knitr::convert_chunk_header()

R Markdown

```{r, label=rmarkdown, eval=FALSE}
# code
```

Quarto

```{r}
#| label: quarto
#| eval: false

# code
```

🆕 Shiny app to convert R Markdown to Quarto

App: https://mounaabelaid.shinyapps.io/RMarkdown2Quarto

Repo: https://github.com/MounaBelaid/RMarkdown2Quarto

Resources for R Markdown users

Get started with Quarto

Create a single Quarto document

One .qmd file for a report, presentation, or dashboard

File > New File > Quarto Document…

Pop up menu for creating a new document. The title field shows that we entered "2024 Sampling Report" and the author field shows the name "Jadey Ryan". HTML format is selected via the radio button.

Create a Quarto project

Multiple .qmd files for a website, blog, or book

File > New Project > New Directory > Quarto Project/Website/Blog/Book

Pop up menu for creating a new project in a new directory. A list of Project Types are presented with Quarto Project, Quarto Website, Quarto Blog, and Quarto Book highlighted.

Authoring

Toggle between Visual and Source modes with Cmd/Ctrl + Shift+ F4.

On the left: Document in the visual editor. On the right: Same document in the source editor. The visual/source editor toggle is highlighted in both documents marking their current state. The document shown is the "Hello Quarto" document from a previous image on the page.

💪🏼 Exercise 1-1

  1. Create a Quarto document that will generate an HTML output format. Name it 1-hello-quarto.

  2. Toggle between Visual and Source modes. What differences in the RStudio IDE do you notice?

  3. In Visual mode, try a traditional keyboard shortcut to format text in Google Docs or Microsoft Word (Cmd/Ctrl + B to bold text).

  4. Try out other formatting shortcuts you normally use.

  5. Try inserting an image using the Insert Anything shortcut (Cmd/Ctrl + /).

05:00

Three ways to render

  1. Use the RStudio/Quarto integration

Quarto render button in RStudio Render button to render the file and preview the output.

Keyboard shortcut: Cmd/Ctrl + Shift + K

Top of the text editor in RStudio with the Render button highlighted with a purple box.

Check the Render on Save option to automatically render and update the preview after saving.

Top of the text editor in RStudio with the Render on Save checkbox checked and highlighted with a purple box.

Three ways to render

  1. Use the quarto package in the Console or an R script
Console or R script
quarto::quarto_render(input = "hello.qmd", output_format = "html")
  1. Use the CLI in the Terminal
Terminal
quarto render hello.qmd --to html

💪🏼 Exercise 1-2

  1. Render the document using the Quarto render button in RStudio Render button.

  2. Modify the text and code, render using the quarto package, and review the output.

  3. Check the Render on Save option, make more changes, save, and watch the preview update.

03:00

Anatomy of a .qmd file

  1. YAML header (metadata and document options)

  2. Narrative (text)

  3. Code chunks (import, wrangle, visualize data)

1. YAML header

“Yet Another Markup Language” or “YAML Ain’t Markup Language”

1---
2title: 2024 Sampling Report
author: Jadey Ryan
date: 2024-04-25
format:
3  html:
    theme: flatly
    toc: true
---
1
Demarcated by three dashes (---) on the top and bottom
2
Document level metadata and options using key-value pairs in the format key: value
3
Use 2 spaces for each indentation level – YAML is very fussy!


See available options in the reference guides: HTML, PDF, MS Word.

YAML intelligence: tab-completion

  • Start a word and then Tab to complete.

  • Cmd/Ctrl + Space to see all available options.

Quarto document with YAML being edited. Next to the cursor code completion helper is open showing YAML options beginning with the letters preceding the cursor ('to').

YAML intelligence: diagnostics

Incorrect YAML is highlighted when documents are saved:

Quarto document YAML metadata with an incorrect option underlined in red.

💪🏼 Exercise 1-3

  1. Explore the Quarto documentation on HTML theming and choose a Bootswatch theme.

  2. Add your chosen theme to the YAML.

format:                      
  html:                       
    theme: flatly 
  1. Cmd/Ctrl + Space to see all available YAML options for the HTML format.

  2. Try any that sound interesting.

  3. 💬 Discuss: Share your two favorites.

Use the HTML reference as needed.

08:00

2. Narrative

Markdown syntax for:

  • Text with formatting: **bold**bold

  • Section headers: # Header 1, # Header 2

  • Hyperlinks: [google.com](https://google.com)google.com

  • Images: ![](image.png)

  • Inline code: 2024-04-252024-04-25

  • Inline math: `$E = mc^{2}$`\(E = mc^{2}\)


💪🏼 Exercise 1-4

  1. Enable the Visual mode.

  2. Explore the Format, Insert, and Table drop downs.

  3. Pick one or two options from these drop downs and try them out.

  4. Switch to the Source mode and see what that formatting or feature looks like in markdown syntax.

  5. 💬 Discuss: Share your two favorites.

05:00

3. Code chunks (or cells or blocks)

Three ways to insert code chunks:

  1. Keyboard shortcut Cmd/Ctrl + Option/Alt + I.

  2. Insert Chunk button in RStudio Insert Chunk button in the editor toolbar.

  3. Manually type the chunk delimiters ```{r} and ```.

Two ways to run code chunks:

  1. Use the Run Current Chunk or Run All Chunks Above buttons.

    Code chunk in RStudio with the Run All Chunks Above and Run Current Chunk buttons highlighted and labelled.

  2. Run the current code chunk with Cmd/Ctrl + Shift + Enter.

💪🏼 Exercise 1-5

  1. Insert a code chunk at the beginning of the document that includes library(ggplot2).
    Do not run this chunk yet.

  2. Insert a chunk at the end that includes ggplot2 code to generate a plot of your choice.
    Browse the various geoms on the ggplot2 documentation website for examples.

  3. Try running just this plot code chunk. It should error with could not find function "ggplot". 💬 Discuss: We attached the ggplot2 package, why can’t R find the ggplot function?

  4. Click the Run All Chunks Above button.

    💬 Discuss: Why do you think it worked this time?

08:00

Optional code chunk labels

Use a hashpipe (#|) to specify labels.

```{r}
#| label: simple-addition
#| code-line-numbers: "|2"

1 + 1
```
[1] 2

Improve documentation and navigation.

Optional code chunk options

Use a hashpipe (#|) to specify options.

```{r}
#| label: simple-multiplication
#| eval: false
#| code-line-numbers: "|3-4"

2 * 3
```

Control code execution, text or plot output, layout, captions, etc.

  • eval: false prevents code from being evaluated and does not generate results. Use this to display example code or disable a code block.

  • echo: false prevents code, but not the results from appearing in the report. Use this when writing reports aimed at people who don’t want to see the underlying R code.

Use tab-completion to see available options!

Read about knitr specific options in the developer’s documentation or the Quarto Code Cells: Knitr reference.

💪🏼 Exercise 1-6

  1. Add appropriate labels to the first and last code chunks.

  2. Try navigating to the chunks using the drop down navigator at the bottom left of the source pane.

  3. Add #| echo: false to all chunks and re-render. How did this change the report?

  4. Try two more chunk options and re-render.
    To see all options, type #| then Tab, or Cmd/Ctrl + Space.

  5. 💬 Discuss: Share which options you tried and what they did.

Use the Code Cells: Knitr reference as needed.

06:00

Global options

Use for chunk options you want to apply to all chunks by default.

Code execution options:

---
title: "Report for audience that doesn't need to see the code"
execute:
  echo: false
---


Some global options relevant only to R must be set under the knitr key, under opts_chunk:

---
title: "Report with all plots centered"
knitr:
  opts_chunk:
    fig-align: "center"
---

💪🏼 Exercise 1-7

  1. Delete the echo: false option from all code chunks.

  2. Add code-fold: true (under the html: key in the YAML header) to collapse all code chunks by default.

  3. 💬 Discuss: What do you think will happen if you add echo: false (under the execute: key in the YAML header)? Try it out.

  4. Try adding a knitr: opts_chunk: global option. Careful with indentation!

    knitr:
      opts_chunk:
        out-width: 50%   # width of the plot in the output document

    Tab-completion doesn’t seem to work for the opts_chunk YAML key.
    Use the Code Cells: Knitr reference as needed.

10-min break after this exercise

06:00

🚶🏻‍♀ Break 🧘🏻‍♀️

10:00

Parameterized reports

Many use cases


Different audiences, different reports

Show code for technical staff and hide code for everyone else (StackOverflow example).

Like a custom function

File with the word '.qmd' inside and the word 'Function' above.

An arrow points from 'Input' with 'params$year' to the previous image with 'Function' and '.qmd' file.

In addition to the previous two images, arrows point to five reports with years 2019 through 2023 on them in a flow chart.

What makes a report “parameterized”?

  • YAML header with params key-value pairs

  • Use these params to create different variations of a report from a single .qmd document.

Important

Workflow

  1. Write report template with default values hard-coded, and then render & review.

  2. Set default params key-value pairs in YAML.

  3. Replace hard-coded values with the params variables.

  4. Render the single report and review.

  5. Render extreme cases and review.

    • Parameter values with barely any data and with tons of data.
  6. Render all variations of the report at once.

💪🏼 Exercise 2

Explore a report without parameters and see where we could add them.

  1. Open 2-swiss-cats.qmd.

  2. Click the Quarto render button in RStudio Render button.

  3. Look at the source markdown & code and the rendered report.

  4. 💬 Discuss: What variables could we set as parameters?

    💡 Hint: run the setup chunk and look at the pets dataframe to see what variables it has.

05:00

Set params in YAML header

---
title: "Swiss Cats"             # Metadata
format:                         # Set format types
  html:
    toc: true                   # Set additional options
  docx: default                           
params:                         # Set default parameter key-value pairs
  fave_breed: "Snowshoe"                                
---
    
Report content goes here.       # Write narrative and code

Important

Your default params key-value pairs must be found in your dataset. Otherwise, code will error or output will be blank.

The variable name for params can be anything you choose. Often, it’s a column name in your dataset.

Access params

Run any line or chunk to add params to your environment.

params object is a list.

str(params)
List of 1
 $ fave_breed: chr "Snowshoe"


Access with $ notation.

params$fave_breed
[1] "Snowshoe"


For inline code in YAML or report content, enclose the expression in `r `.

My favorite cat breed is the **`r params$fave_breed`**.

My favorite cat breed is the Snowshoe.

Replace hard-coded values with params

  • Cmd/Ctrl + F to find where to replace hard-coded values with params.
Find and replace toolbar with "pet_type in the Search field highlighted by a purple box and "params$pet_type in the Replace field highlighted by a blue box. The .qmd file shows a filter statement with the "pet_type highlighted by RStudio as a match for the Find tool. This filter statement is highlighted by a purple box with an arrow pointing to a blue box that has the filter statement with the hard-coded "cats string replaced with "params$pet_type.

Replace hard-coded values with params

Use inline R code for markdown.

## My favorite breed: `r params$fave_breed`


Use paste() or glue::glue() for plot and table titles and labels.

# ggplot code +
labs(title = paste(params$fave_breed, "population"))

# OR

# ggplot code +
labs(title = glue::glue("{params$fave_breed} population"))

💃🏻 Demo

Modify 2-swiss-cats.qmd to add pet_type and fave_breed parameters.


This parameterized version of 2-swiss-cats.qmd is the starting point for the next section’s exercises (3-quarto-render.qmd).

Rendering many reports

Review three ways to render

  1. RStudio/Quarto integration:

    Quarto render button in RStudio Render button in RStudio or Cmd/Ctrl + Shift + K keyboard shortcut

  2. Quarto R package

    Console or R script
    quarto::quarto_render(
      input = here::here("3-quarto-render.qmd"),   # Input Quarto file
      execute_params = list(                       # Named list of params
        pet_type = "cats",
        fave_breed = "Snowshoe"))
  3. Quarto CLI

    Terminal
    quarto render 3-quarto-render.qmd -P pet_type:'cats' -P fave_breed:'Snowshoe'

💪🏼 Exercise 3-1

Change parameters in the YAML and render using Quarto render button in RStudio Render button.

  1. Look at the unique pet breeds and pick your favorite.

    # Run in Console
    pets <- readr::read_rds(here::here("data", "pets.RDS")) |> 
       dplyr::distinct(pet_type, breed) |> View()
  2. In 3-quarto-render.qmd Change the default parameters in the YAML to your favorite pet type and breed. Render using the Quarto render button in RStudio Render button.

    params:
      pet_type: "___"
      fave_breed: "___"
  3. 💬 Discuss: Which breed did you pick and why? What do you think will happen if you set the pet_type default parameter to “cats” and the fave_breed parameter to “American Bulldog”?

Try it out!

07:00

💪🏼 Exercise 3-2

Change parameters and render using quarto_render().

  1. Render with quarto::quarto_render().

    # Run in the console
     quarto::quarto_render(
       input = here::here("3-quarto-render.qmd"),
       execute_params = list(
         pet_type = "___",
         fave_breed = "___"))
  2. 💬 Discuss: What kinds of variables will you use as parameters for your reports?

10-min break after this exercise

07:00

🚶🏻‍♀ Break 🧘🏻‍♀️

10:00

Render all 538 reports

One HTML report for each cat breed and each dog breed.

pets <- readr::read_rds(here::here("data", "pets.RDS"))

pets |>
  dplyr::distinct(pet_type, breed) |>
  dplyr::count(pet_type) |>
  janitor::adorn_totals()
pet_type n
cats 104
dogs 434
Total 538
  1. Change the default params in the YAML.

  2. Render button or Cmd/Ctrl + Shift + K keyboard shortcut.

  3. Rename the rendered report to include the parameter & prevent overwriting.

  4. Repeat 537 times.

😭

quarto::quarto_render(
  input = here::here("3-quarto-render.qmd"),
  output_file = "dogs-affenpinscher-report.html",
  execute_params = list(
    pet_type = "dogs",
    fave_breed = "Affenpinscher"))

quarto::quarto_render(
  input = here::here("3-quarto-render.qmd"),
  output_file = "dogs-afghan-hound-report.html",
  execute_params = list(
    pet_type = "dogs",
    fave_breed = "Afghan Hound"))

quarto::quarto_render(
  input = here::here("3-quarto-render.qmd"),
  output_file = "dogs-aidi-chien-de-montagne-de-l-atlas-report.html",
  execute_params = list(
    pet_type = "dogs",
    fave_breed = "Aidi Chien De Montagne De L Atlas"))

quarto::quarto_render(
  input = here::here("3-quarto-render.qmd"),
  output_file = "dogs-akita-report.html",
  execute_params = list(
    pet_type = "dogs",
    fave_breed = "Akita"))

# + 534 more times... 
# 😭

Create a dataframe with three columns that match quarto_render() args:

  • output_format: file type (html, revealjs, pdf, docx, etc.)

  • output_file: file name with extension

  • execute_params: named list of parameters

Map over each row:

  • purrr::pwalk(dataframe, quarto_render, <arguments for quarto_render>) 😎

purrr map functions for iteration

Map functions apply the same action/function to each element of an object.

  • Base R apply() functions are map functions.

  • purrr map functions have consistent syntax and the output data type is predictable.

for loopslapply()purrr::map()

purrr R package logo

Learn more:

Create dataframe to iterate over

pet_reports <- pets |>
  dplyr::distinct(pet_type, breed) |>   # Get distinct pet/breed combos
  dplyr::mutate(
    output_format = "html",             # Make output_format column
    output_file = paste(                # Make output_file column:
      tolower(pet_type),                # cats-abyssiniane-report.html
      tolower(gsub(" ", "-", breed)),           
      "report.html",
      sep = "-"
    ),
    execute_params = purrr::map2(       # Make execute_params column
      pet_type,
      breed,
      \(pet_type, breed) list(pet_type = pet_type, breed = breed)))

Subset to first 2 cat/dog breeds

pet_reports_subset <- pet_reports |>
  dplyr::slice_head(n = 2, by = pet_type) |>
  dplyr::select(output_file, execute_params)

pet_reports_subset
output_file execute_params
cats-abyssiniane-report.html cats , Abyssiniane
cats-aegean-cat-report.html cats , Aegean Cat
dogs-affenpinscher-report.html dogs , Affenpinscher
dogs-afghan-hound-report.html dogs , Afghan Hound

Map over each row

  • purrr::pwalk() iterates over multiple arguments simultaneously.

  • First .l argument is a list of vectors.

    • Dataframe is a special case of .l that iterates over rows.
purrr::pwalk(
  .l = pet_reports_subset,                      # Dataframe to map over
  .f = quarto::quarto_render,                   # Function we are applying to each row
  input = here::here("3-quarto-render.qmd"),    # Named arguments of .f
  .progress = TRUE                              # Show a progress bar :)
)

Note

index is the only named argument of quarto_render() included in pwalk().

output_format, output_file, and execute_params are already passed in through the dataframe.

Multiple formats

Render all reports to all formats

Add to the format: YAML option to render additional output formats from the same .qmd file.

---
format:
  html: 
    embed-resources: true   # Makes the report self-contained
  pdf: default              # If not using any additional format options,
  docx: default             # set value to `default`  
---

Note: the Render button now has a dropdown!

Screenshot of Quarto file with the Render dropdown showing options for HTML, PDF, and MS Word formats.

Quarto docs on multiple formats

💃🏻 Demo

Demo programmatically rendering all reports in all formats in 4-demo-quarto-render-purrr.qmd and 4-demo-quarto-render-purrr.R.

Watchouts

  • Can’t render reports to another directory.


  • If using embed-resources: true YAML option, .qmd can’t be in subfolder, otherwise:

Conditional code execution

Conditionally execute a code chunk

  • More efficient to not execute code that generates interactive outputs for static reports.

  • Useful for executing interactive plot code (e.g., plotly or ggiraph) for HTML reports and static ggplot2 code for all other formats.

  • Useful for executing different code based on a parameter value.

  • Not currently a feature of Quarto v1.4. Follow along with this GitHub discussion.

  • Chunk options can use R code for option values with !expr. Learn about the limitations to this YAML “tag” literal syntax in the Quarto Chunk Options reference.

Conditional code based on output

Include in the setup chunk of your .qmd file.

Get the format of the Pandoc output:

```{r}
#| label: setup

# Get output format
format <- knitr::opts_knit$get("rmarkdown.pandoc.to")
```

Use eval: !expr chunk option

```{r}
#| eval: !expr format %in% c("latex", "docx")

# code to create static {ggplot2}
```

💡 Pandoc uses LaTeX to create PDFs.

```{r}
#| eval: !expr format == "html"

# code to create interactive {plotly}
```

💪🏼 Exercise 5


Conditionally execute ggplot2 code for static reports & plotly code for interactive reports.

  1. Open ex-5-conditional-code.qmd.

  2. Fill in the blanks for the eval: option for ggplot code chunks and plotly code chunks.

  3. 💬 Discuss: How would you change the eval: option to execute a chunk based on a parameter value rather than the output format?

# Options are html, latex, and docx.

#| eval: !expr format == "___"

#| eval: !expr format %in% c("___", "___")
05:00

Conditional code based on parameter

Use params in !expr:

#| eval: !expr params$fave_breed == "Snowshoe"

# Code for a special plot for my favorite cat breed.


#| eval: !expr !params$fave_breed == "Snowshoe"

# Code for a different plot for all other breeds.
# Note the ! in front of params.


Community project: home energy monitoring

Consider using a different conditional code chunk to create different visualizations depending on heating source.

Child documents

Generate dynamic contents with a “child” template

  • knitr::knit_child() and knitr::knit_expand() are functions from R Markdown that also work with Quarto

  • “child” document is a template, which is run with different parameters

  • “main” document includes the output from all the different iterations of the child document


Community project: water quality monitoring monitoring

Consider creating a main document using the river as the parameter and a child document as a template for the heading, plots, tables, and text for each sampling site.

Do not run interactively!

Code chunks including knitr::knit_child() are not supposed to be used interactively (see this Stack Overflow response from the knitr developer Yihui Xie). If run interactively, you will get an error similar to the one shown below.

Error in `purrr::map_chr()`:
ℹ In index: 1.
Caused by error in `setwd()`:
! character argument expected

Read a description of this issue in WSDA’s {soils} R package vignette.

Learn more about child documents

💃🏻 Demo

Generate a report that dynamically creates sections and plots for all breeds of the pet_type.

Main document: 6-demo-knit-child.qmd

Child document: _child-template.qmd

🏁 Recap

Learning objective 1

Learn what Quarto is and what you can use it for.

Scientific and technical publishing system for:

Check out the Quarto Gallery!

Artwork from “Hello, Quarto” keynote by Julia Lowndes and Mine Çetinkaya-Rundel, presented at RStudio::Conf(2022). Illustrated by Allison Horst.

Learning objective 2

Learn how to weave code and text together to create a fully reproducible report.

.qmd documents contain:

  • document level metadata and options in the YAML
  • a narrative using markdown syntax, and
  • code chunks to import, wrangle, visualize data.

Learning objective 3

Learn how to use parameters to create variations of a report.

Parameterized reports → very fancy custom functions:

  • Function → .qmd template

  • Input → parameters

  • Output → rendered reports

Useful for creating variations of the same report:

  • spatial: country, state, county, or city

  • temporal: year or other time period

  • water bodies, sampling sites, energy sources, breeds, species, diseases, trials, etc.

Note

We only covered reports, but you can also parameterize revealjs presentations! See this Jumping Rivers blog post about it.

Thank you!

🏡 Home for all workshop materials: jadeyryan.quarto.pub/ceds-quarto-workshop/

🎥 Recordings from previous workshops & talks:
links in GitHub repo or my YouTube playlist

From left to right, Mai, Tai, and Skye. Three snowshoe cats cuddling in their warming beds.