简体   繁体   中英

Is it possible to automate R markdown files?

I need to generate a thousand R Markdown files, each essentially the same, just with different titles and a different subset of the data. Is there a way to store those titles and subsets in objects and automate creating and knitting the R Markdown files?

Yes. When you klick the knit button in Rstudio, it calls the function rmarkdown::render() . This can also be done in code, either in a for loop, with apply or the purrr -version of apply called map . You will need to create a rmarkdown-document that takes parameters for the title and the subset first and then pass these to the render-function in said way.

For an introduction to paramters in your documents have a look at the documentation here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM