rscript
Rscript: There is no package called …?
In short, the value returned by calling Sys.getenv(‘R_LIBS_USER’) in R.exe needs to be the same as the value returned by calling this at the command line: Rscript.exe -e “Sys.getenv(‘R_LIBS_USER’)” and the above value needs to be included in this command line call: Rscript.exe -e “.libPaths()” Note that the values of R_LIBS_USER may be differ between … Read more
Rscript does not load methods package, R does — why, and what are the consequences?
According to ?Rscript the methods package isn’t loaded because, “The default for Rscript omits methods as it takes about 60% of the startup time.”
Passing command line arguments to R CMD BATCH
My impression is that R CMD BATCH is a bit of a relict. In any case, the more recent Rscript executable (available on all platforms), together with commandArgs() makes processing command line arguments pretty easy. As an example, here is a little script — call it “myScript.R”: ## myScript.R args <- commandArgs(trailingOnly = TRUE) rnorm(n=as.numeric(args[1]), … Read more
Determine path of the executing script
Here there is a simple solution for the problem. This command: script.dir <- dirname(sys.frame(1)$ofile) returns the path of the current script file. It works after the script was saved.