How to run a R script from the Windows command line?

Asked

Viewed 5,683 times

3

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

When in the 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: TEST ARGUMENT. R ignored And the R is initiated in the cmd. After started the R if I type source("teste.R") windows runs the script, but wanted to avoid this step of starting R on CMD.

1 answer

3


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

R CMD BATCH teste.R

or

Rscript teste.R
  • 1

    in linux the output of R CMD BATCH teste.R is the file teste.Rout. Already the exit of Rscript teste.R goes to the terminal. This is the same behavior in windows?

  • Yeah, the same thing!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.