Reputation: 1190
I'd like to know if it's possible to pass a string as a command line argument to execute in R?
I've attempted it already and I think it's parsing based on space, regardless of quotation marks.
./R_Script.r abc.bed def.bed "cat bedgraph 1,2"
Upvotes: 0
Views: 782
Reputation: 18323
It shouldn't be parsing based on space. I'm also not sure why you are trying to execute your R script file directly, rather than using Rscript
and passing the script file. If your R_Script.r
file contains only one line: commandArgs()
, then running this line:
Rscript --vanilla R_Script.r "first second"
should get you:
[1] "/usr/local/lib/R/bin/exec/R" "--slave"
[3] "--no-restore" "--vanilla"
[5] "--file=R_Script.r" "--args"
[7] "first second"
As you can see, the 7th element of the list is first second
, so it isn't parsing the space.
Upvotes: 3