Resources

Questions

When rendering multiple reports, can I map over multiple (dependent) parameters where only some combinations of the parameters are desired?

Yes, you can! As long as you have a way of defining what those combinations of parameters are. For example, this selects some different combinations of years and continents from the gapminder dataset:

params_df <- gapminder |>
  filter(
    year %in% c(2002, 2007) & continent %in% c("Europe") |
      year %in% c(1952, 1957) & continent %in% c("Asia", "Americas")
  ) |>
  select(continent, year) |>
  distinct()

You can then use walk() from {purrr} in a similar way to the examples, but mapping over each row of your parameter data:

walk(
  .x = 1:nrow(params_df),
  .f = ~ quarto_render(
    input = "example.qmd",
    output_file = glue("{params_df$continent[.x]}_{params_df$year[.x]}.html"),
    execute_params = list(
      choose_continent = params_df$continent[.x],
      choose_year = params_df$year[.x]
    )
  )
)

If my list of parameters is long, is there a nice way to see how long my code has left to run when generating multiple reports?

Yes, within walk(), set .progress = TRUE and this will create a progress bar in the console showing how far through your code is, and an approximate amount of time left. You can also use the {beepr} package to get your laptop to beep when the code is finished!