Philipp
Philipp

Reputation: 31

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?

Upvotes: 3

Views: 2802

Answers (1)

Tommy
Tommy

Reputation: 40821

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...

Upvotes: 2

Related Questions