Automatically generated reports using rMarkdown

本秂侑毒 提交于 2019-12-06 08:27:21

问题


I am trying to generate about 50 reports with the same template in rMarkdown. I do not want to change the name of the input file every time and I would like to choose different names for output files.

Is there any way how to automate this process?

Thank you.


回答1:


Another option is to render your reports using the render() function of the rmarkdown package in a seperate R script.

report.Rmd looks like this:

---
output: pdf_document
---
# A table with data received from R script

```{r,results='asis'}
library("knitr")
kable(mydataset)
```

The R script looks like that:

library("rmarkdown")
for (i in 1:50){ 
 mydataset <- head(mtcars) 
 render( input="report.Rmd", output_file=paste0("reportNo_", i, ".pdf") )
} 


来源:https://stackoverflow.com/questions/28368150/automatically-generated-reports-using-rmarkdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!