Hello list
Is there a way of identifying from within R whether a script has been source(d)
from Rgui.exe or via Rscript.exe in batch mode?
For the code I have I use the commandArgs() function to pick up command line
args when running in batch mode via Rscript.exe
However I like to get the code working manually first using source("MyRCode.r")
I'd like to be able to put something at the top of the file that discriminates
between the two running modes eg
#Rscript.exe --slave -e source('MyRCode.r') "some_data_file.txt"
if(batchmode = TRUE){
#get arguments for script from command line
foo <- commandArgs() #where commandArgs() returns "some_data_file.txt"
}
if(batchmode == FALSE){
#no command line usage so need to manually supply starting arguments for script
foo <- "some_data_file.txt"
}
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.