I’m trying to use my R script in batch mode, but R doesn’t seem able to parse quoted parameters properly:
args=(commandArgs(TRUE))
for(i in 1:length(args)){
print(paste('ARG ',i,args[[i]],sep=" "))
}
Then if a parameter with spaces and quotes is supplied, like:
R CMD BATCH "--args foo=2 bar=3 's=string with spaces'" test-parameters.R output
the output is:
[1] "ARG 1 foo=2"
[1] "ARG 2 bar=3"
[1] "ARG 3 's=string"
[1] "ARG 4 with"
[1] "ARG 5 spaces'"
of course I’d like the third parameter to be s='string with spaces': is there a way to obtain that?
Thank you!
Yeah, R CMD BATCH acts a little weird.
Try this instead:
The –slave and –vanilla options might be replaced with more suitable options as needed.