My data file includes a long list of case, one row per case. I want to produce a long PDF report, that would include one page per case, each page would contain the same table and graphs, but for a different case.
I understand I should have a 'child' markdown (one page), for example, childfile.Rmd:
---
title: "case number `r params$case[1]`"
output: pdf_document
params:
case: [0,0,0,0,0,0,0]
---
```{r part1, echo=FALSE}
params$case[2:4]
```
```{r part2, echo=FALSE}
params$case[5:7]
```
and render it using a loop in a 'parent' markdown, for example, parentfile.Rmd:
---
title: "all cases"
output: pdf_document
---
```{r parent, include=FALSE}
df = data.frame(number = c(1,2,3,4),
var1 = c(1,2,3,4),
var2 = c(1,2,3,4),
var3 = c(1,2,3,4),
var4 = c(1,2,3,4),
var5 = c(1,2,3,4),
var6 = c(1,2,3,4) )
for ( i in 1:4 ){
rmarkdown::render("childfile.Rmd",
params = list(case = as.vector(df[i,])))
}
```
However, this results in a blank pdf for the parent, and a second pdf for the chid, containg only the last case.
How can the complete set of child PDFs can be rendered into one PDF?