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:
@echo off
C:
PATH C:\Programme\R\R-3.0.1\bin;%path%
cd PATH_TO_YOUR_RSCRIPT
Rscript tryCatch.R 1
pause
And open a console(using cmd) , go where you have stored your launcher.bat and launch it. Or from the R cosnole using shell
:
shell('path_to_launcher\launcher.bat')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With