Peng Yu
2009-Aug-20 01:21 UTC
[R] Command line option to an R script running through Rscript
Hi, I know that I can use the following script to get the command line options for an R script. But the output shows two many irrelevant arguments. For example, I only want to pass "a", "b" and "c" to the script. The first 5 elements in the variable 'args' are not what I want. I am wondering what is the correct way to pass command line options to an R script. Regards, Peng $ Rscript args.R a b c> args=commandArgs() > args[1] "/usr/local/lib64/R/bin/exec/R" "--slave" [3] "--no-restore" "--file=args.R" [5] "--args" "a" [7] "b" "c">
David Winsemius
2009-Aug-20 01:34 UTC
[R] Command line option to an R script running through Rscript
On Aug 19, 2009, at 9:21 PM, Peng Yu wrote:> Hi, > > I know that I can use the following script to get the command line > options for an R script. But the output shows two many irrelevantThat would be "too many".> arguments. For example, I only want to pass "a", "b" and "c" to the > script. The first 5 elements in the variable 'args' are not what I > want. I am wondering what is the correct way to pass command line > options to an R script. > > Regards, > Peng > > $ Rscript args.R a b c >> args=commandArgs() >> args > [1] "/usr/local/lib64/R/bin/exec/R" "--slave" > [3] "--no-restore" "--file=args.R" > [5] "--args" "a" > [7] "b" "c" >> >?commandArgs commandArgs(trailingOnly=TRUE) -- David Winsemius, MD Heritage Laboratories West Hartford, CT
Maybe Matching Threads
- How to convert a string passed as an argument to a vector?
- Rscript, hashbang, and arguments
- Is it possible to detect whether running as Rscript?
- pasar argumentos de consola a un script de R que contiene source
- Why this statement does not print anything in an if-statement that includes 'q()'?