简体   繁体   中英

arguments in R CMD BATCH mode from Shell

I want to call a R script from a Shell script with R CMD BATCH --no-save --no-restore . How I can transfer a parameter (for example $1 ) from the Shell script into the R script?

As I wrote elsewhere, the BATCH command acts a bit weird sometimes, so I just use the --file command directly:

R --slave --vanilla --file=myScript.R --args foo=2 bar=3 "s=string with spaces" > output.txt

...and then in myScript.R I use args <- commandArgs(TRUE) to get the extra arguments foo etc...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM