Tips for custom parameterized issue ...
Opened this issue · 0 comments
ibecav commented
Hi Meghan,
First and foremost thanks for the great blog post. My R is good but my LaTeX is weak and your article was a great read. One quick suggestion...
You provide code that you say will produce all 9 reports (3 years * 3 species) but it actually doesn't do that...
purrr::map2(unique(penguins$species), unique(penguins$year), runpdfs)
will only make 3 pdfs.
Sticking with your current functions as is consider
crossed_list <-
penguins %>%
expand(species, year) %>%
as.list()
purrr::walk2(
crossed_list$species,
crossed_list$year,
runpdfs,
.progress = TRUE
)
I switched over to walk2
to avoid all the excess by product output as well instead of map2
turned on the progress bar inherent in the latest versions of purrr
and if you hate as I do all the chattiness from knitting and weaving can modify your function very slightly:
runpdfs <- function(species, year) {
quarto::quarto_render(
"penguins.qmd",
output_format = "pdf",
execute_params = list(species = species, year = year),
output_file = glue::glue("{species}_{year}.pdf"),
quiet = TRUE
)
}