I have a script (call it Main.R ) that has the following code to find myself when I run it:
frame_files <- lapply(sys.frames(), function(x) x$ofile) frame_files <- Filter(Negate(is.null), frame_files) main.dir <- dirname(dirname(frame_files[[length(frame_files)]]))
This is used to get the directory above its own main.dir directory, which is used to call other scripts regarding this path.
I am interested in running this script from the command line, for example
R CMD BATCH Main.R
or
Rscript Main.R
Unfortunately, the above commands do not work when I call the script from the command line.
Is there any code that I could add to Main.R or an option to call R or Rscript that I can use instead?
In particular, the solution should work on Windows.
source share