You want to use R to generate multiple reports from a single template, each containing different data.
How? Create a parameterised RMarkdown template with a params YAML argument. Iterate over param values with rmarkdown::render() inside purrr::map().
This repo contains a demo of the approach that focuses on parameterised {xaringan} slides. It includes a further {purrr} step with pagedown::chrome_print() to render the HTML outputs to PDF.
docs/
contains:
- a parameterised RMarkdown report template (
ninja-knitting-template.Rmd
) - resources (
libs/
andstyles/
) - rendered HTMLs (one for each parameter passed to the template)
- rendered PDFs (one for each HTML)
src
contains one R file, 00-run.R
, that:
- Iterates over the RMarkdown template with different param variables to produce HTML reports
- Iterates over the HTML reports to render them to PDF
Read more on the associated blog post.