1 [[!meta date="2016-10-10 21:48:11 +0800"]]
3 [[!tag R code automation]]
4 A lot of information on [knitr](https://cran.r-project.org/web/packages/knitr/index.html) is centered around using it for reproducible research. I've found it to be a nice way to make abstraction of mundane reporting though. It is as easy as performing the necessary data extraction and manipulation in an R script, including the creation of tables and graphs.
6 To develop the report template, simply `source` the R script within an Rmd one, per the example template below:
11 date: "`r Sys.time()`"
15 ```{r setup, include=FALSE}
17 knitr::opts_chunk$set(echo = TRUE)
21 Include some text about your report.
33 When you are ready to create the report, the convenience of [RMarkdown](https://cran.r-project.org/web/packages/rmarkdown/) is hard to beat:
36 R -e "rmarkdown::render('~/my-report.Rmd',output_file='~/my-report.pdf')"
39 Thanks to the YAML header at the start of the report template, information like the report's title and target output format don't need to be mentioned. This command can easily be scripted a bit further to include a date-time stamp in the output filename for instance, and scheduled using `cron`.