Hello,
Is it possible to save the R Markdown HTML output file by a variable I set in the code?
Help/guidance much appreciated.
Hello,
Is it possible to save the R Markdown HTML output file by a variable I set in the code?
Help/guidance much appreciated.
This might not be what you're looking for, but something I've done in the past with parameterized templates in Quarto projects is to use purrr::walk()
to pass the parameters in and name the output file with those values. I think this could be achieved in a similar way using rmarkdown::render()
(non-working example below). If you wanted this to be included in the actual .rmd file, I'm not sure if you can achieve something similar by putting the render command in its own chunk and setting the chunk option eval = FALSE
, but maybe that would work. Keeping a small external R script was cleaner for me to maintain, however.
notebook_params <- c("A", "B", "C")
purrr::walk(
notebook_params,
function(param) {
rmarkdown::render(
input = "<path_to_template_file.rmd>",
output_file = glue::glue("{param}.html"),
params = param
)
}
)
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.