I have a parameterized RMarkdown file, parameterized.Rmd
, with the following contents.
---
title: "Parameterized report"
output: html_document
params:
input_df: NULL
---
```{r sec1}
head(params$input_df[, 1:2])
```
I can knit it from the console using rmarkdown::render
, generating distinct documents for distinct dataframe inputs. This works as expected.
rmarkdown::render("parameterized.Rmd",
params = list(input_df = mtcars),
output_file = "cars.html")
rmarkdown::render("parameterized.Rmd",
params = list(input_df = iris),
output_file = "iris.html")
I would like to have each of these results be child documents to a common document. My first attempt is with knitr::knit_child
, but it does not take params
as an argument. So this failed.
---
title: "Main report"
output: html_document
---
```{r test-cars}
knitr::knit_child("parameterized.Rmd", envir = environment(), quiet = T,
params = list(input_df = mtcars))
```
How may I knit together child documents which require parameters?