Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Run knitr from a batch-file (windows)

I run some automatic reports each day with batch-files on my windows-computer. But how do I do this with a .rmd file and generate the html-output?

So, this works for me using a batchfile with a normal .R file:

"C:\R\R-3.0.1\bin\x64\Rscript.exe" --default-packages=methods 
"C:\R\R-3.0.1\bin\x64\Scripts\models.R"

But, this won't:

"C:\R\R-3.0.1\bin\x64\Rscript.exe" --default-packages=methods,knitr 
"C:\R\R-3.0.1\bin\x64\Scripts\test_knitr.Rmd"

I've tried some variations inspired by command-line like:

"C:\R\R-3.0.1\bin\x64\Rscript.exe" --default-packages=methods,knitr 
knit("C:\R\R-3.0.1\bin\x64\Scripts\test_knitr.Rmd")

But no succes so far! Im a total knitr/.rmd newbee, so I'm not even sure it can be done.

like image 414
Thorst Avatar asked Jan 12 '23 13:01

Thorst


1 Answers

I use something along the lines

Rscript -e "require ('knitr'); knit ('test.Rmd')"
like image 172
cbeleites unhappy with SX Avatar answered Jan 17 '23 07:01

cbeleites unhappy with SX