Skip to content
Coming soon: Ally. Your guide to the world of AI and R. Learn More →
R for the Rest of Us Logo

R in 3 Months (Fall 2025)

Parameterized Reporting, Part 3

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

View code shown in video
library(quarto)
library(tidyverse)
library(gapminder)

countries <-
  gapminder |>
  distinct(country) |>
  pull(country) |>
  as.character()

reports <-
  tibble(
    input = "example-report.qmd",
    output_file = str_glue("{countries}.html"),
    execute_params = map(countries, ~ list(country = .))
  )

pwalk(reports, quarto_render)

Your Turn

  1. Open the file called render-part-2.R.

  2. Replace all instances of TODO with the correct text.

  3. Render your reports.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Amalie Baisgaard

Amalie Baisgaard • June 4, 2024

I dont think I get the right results. Despite using the code from the "Solution" folder, I get all the different HTML files but the all only show data for New Zealand and Australia. The names are correct for the different continents and filenames, bit the data in the graph is only New Zealand and Australia.

What have I done wrong?

Here is the code:

library(quarto)
library(tidyverse)
library(gapminder)

continents <-
  gapminder |>
  distinct(continent) |>
  pull(continent) |>
  as.character()

reports <-
  tibble(
    input = "report.qmd",
    output_file = str_glue("{continents}.html"),
    execute_params = map(continents, ~list(continent = .))
  )

pwalk(reports, quarto_render)
David Keyes

David Keyes Founder • June 4, 2024

I actually think this was an error on my part. Please go in and change the YAML to this:

---
title: "Population Report"
format: 
  html:
    embed-resources: true
execute: 
  echo: false
  warning: false
  message: false
---

The line that says embed-resources: true should fix this for you!

Amalie Baisgaard

Amalie Baisgaard • June 5, 2024

Hi David

Should the YAML you send go to the "report.qmd" or the "render-part-2.R" file?

David Keyes

David Keyes Founder • June 5, 2024

In the report.qmd file.

Marina Gimenez

Marina Gimenez • May 7, 2025

What if I would like to have more than one parameter reported? Do you have a link where I could have a look at such example? Thank you

David Keyes

David Keyes Founder • May 8, 2025

Yup, check this video out! You can see the Quarto document here and the R script file here. Hope that helps!

Jesco Brown

Jesco Brown • April 26, 2026

I hope this is the right place to ask. I saw your talks with Typst and Quarto parameters. But when using quarto_render() and execute_params, the new parameters are not transferred to Typst with typst-template.typ and type-show.typ. The new execute_params are correctly overwritten in the quarto file, but in the .typ file they are the params in the original quarto file. is this a known issue or is there another function that i need to use? Do you have an example?

David Keyes

David Keyes Founder • April 27, 2026

So this is beyond my skills, but my consultant Joseph had this exact same issue (see this GitHub issue). He says the solution is to use the write_yaml_metadata_block() function. Hope that helps!

Course Content

128 Lessons