Rscript is a non-interactive variant of the standard R command, just designed for this kind of use.
For example, under windows you can define a launcher.bat
like this :
PATH PATH_TO_R/R-version/bin;%path%
cd PATH_TO_R_SCRIPT
Rscript myscript.R arg1 arg2
In myscript.R you add the code to read the arguments:
args <- commandArgs(trailingOnly = TRUE)
arg1 <- as.character(args[1])
arg2 <- as.numeric(args[2])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…