1

I can produce my reports rather quickly thanks to knitr and RDoc; however I want to streamline my process a little more by automatically generating the documents in my R script.

Do ya'lls have any solutions or resources I could use to further investigate to create a solution?

C Ried
  • 290
  • 4
  • 15

1 Answers1

3

To automate a knitr job you can use something like the command line below.

Rscript -e "library(knitr); knit2pdf('myRnw.Rnw')"

Put that in a .sh file and you can cron tab it all you want.

Explanation (aka the same again in English):

  • Rscript is the script-running version of R
  • Rscript -e "myexpression();" is the expression runner, it runs everything in the quotes. See Rscript --help for more detail.
  • library(knitr) -- well, you can't knit without knowing how, obviously neither can R
  • knit2pdf( '/path/to/file', ...) lookup the ? help on the function or search for more examples online.
Serban Tanasa
  • 3,592
  • 2
  • 23
  • 45