I have student evaluation dataset as df
. I've designed the PDF report in rmarkdown
format for each student. I want to save the PDF file of each student report.
Data and RMarkdown (index.Rmd)
---
title: "Evaluation Report of `r params$Student`"
output: pdf_document
params:
Student: "Student name"
---
```{r include = FALSE}
# libraries
# data
df <- tribble(
~Student,~Math,~Physics,~Computer,~Note,
"Michael Scott","80","88","65","Keep working",
"Leslie Knope","76","88","76","Good",
"Jake Peralta","45","87","46","Learn more",
)
```#(ignore this comment, just for the sake of code visual)
Dear `r df$Student`,
Here is your test score
Math
> `r df$Math`
Physics
> `r df$Physics`
Computer
> `r df$Computer`
`r df$Note`
Sincerely,
Your teacher
Expectation
I want to save the PDF for each Student with one time run, will save all 3 PDFs. The real case is that I have dataset contains of around 500 people, so save it manually will really time consuming
What I did so far
I'm using for loop but keep didn't work
for (i in 1:3) {
rmarkdown::render(
input = "index.Rmd",
params = list(Student = df$Student)
output_file = paste("Report of", params, ".pdf")
)
}
How to best do it?