batch execute R script

2019-04-10 19:28发布

问题:

I am unable to source a script from the windows command line.

Entering the following command: "C:\Program Files\RStudio\bin\rstudio.exe" CMD BATCH --vanilla --slave "E:\myfile.R"

Opens Rstudio and the script in question, but does not source. Documentation notes you may specify an output file but I just want the script to execute. Any suggestions?

回答1:

Agstudy's answer is all you need but as reference to others I only used two lines:

PATH C:\Program Files\R\R-3.1.0\bin;%path%
Rscript "E:\Dir With Spaces\myfile.R"

Note the path points to R and not Rstudio. The quotes in line 2 deal with Dir With Spaces.