, . Rprofile Rprofile.site (. " " ), , . , , .
Rprofile Rprofile.site ( /etc R):
Args <- commandArgs(trailingOnly=TRUE)
if(length(Args)>0 & sum(grepl(" -f ",commandArgs()))==0 ){
if(grepl("(?i).r$",Args[1])){
File <- Args[1]
Args <- Args[-1]
tryCatch(source(File) , error=function(e) print(e) )
}
}
:
Rgui --args myscript.r arg1 arg2
Rscript myscript.r arg1 arg2
R --args myscript.r arg1 arg2
R -f myscript.r --args arg1 arg2
-args , @iterator. Args, ( .GlobalEnv!). , . script, :
print(Args)
Rgui R, File, , .
, rProfile . . -f --args, .
: "-f", "-f", "path/to/new-files/".