How to run an R script from the WIndows command line?

3

I have a test.r file in the folder: C: \ Users \ Documents \ R And I already added the R in the windows PATH: C: \ Program Files \ R \ R-3.0.2 \ bin

When in cmd I try the command R CMD teste.R Windows does not know which program to use to open the file. If I use the command R teste.R The following message appears: ARGUMENT'teste.R Ignored And the R is started in cmd. After starting R if I type source("teste.R") windows runs the script, but wanted to avoid this step of starting R in CMD.

    
asked by anonymous 22.02.2014 / 14:37

1 answer

3

You can use the argument BATCH of R CMD or Rscript :

R CMD BATCH teste.R

or

Rscript teste.R
    
22.02.2014 / 14:47