I wanted to run this example script: http://mazamascience.com/WorkingWithData/?p=912 from Windows command line. So I opened the command line and typed Rscript tryCatch.R 1
. However, I keep getting the error message Error: R not found
. I did set the PATH environment variable as C:\Programme\R\R-3.0.1\bin
. If I just type R.exe
, it does start R
, but it cannot find the packages that are to be loaded at start (e.g. package 'utils' in options<"defaultPackages"> was not found
). I guess I have to set another path to the libraries somewhere, but I haven't got any idea where to do this.
UPDATE: After explicitly typing PATH C:\Programme\R\R-3.0.1\bin
(rather than just adding this to the value of the environment variable PATH) it seems that R
is found. However, a new problem occurs: In normalizePath<path.expand(path), winslash, mustWork>: path[2] = "C:/Programme/R/R-3.0.1/library": Access denied
, the same than for the methods
library. Then: Calls: .First ... library -> .getRequiredPackages2 -> library -> normalizePath Execution stopped
. I'm using Windows 7 and I do have administrator rights.
Rscript
is very handy (R CMD BATCH
is the old way to ) specially under windows, But generally under I create a batch file to avoid all path's headache.For example say launcher.bat:
And open a console(using cmd) , go where you have stored your launcher.bat and launch it. Or from the R cosnole using
shell
:I've found out that it was a language-specific problem on Windows 7, similar to what is described here: https://stat.ethz.ch/pipermail/r-help/2011-May/276932.html
After changing
PATH
toC:\Program Files\R\R-3.0.1\bin
the script is properly executed from the command prompt.Thanks to everyone who tried to help!
I ran into this problem under windows 7, apparently, when setting environment variables>user variables the path is not added into the PATH, so the user must add this path in system variables > PATH at the end just add the path to your .EXE files and voila.