[R] How to convert a string passed as an argument to a vector?

2009-08-28 Thread Peng Yu
Hi, $ cat commandArgs.R args=commandArgs(trailingOnly=TRUE) args[1]+10 I have the above code. But the following command line gives me an error. I am wondering what is the correct way to convert a string to a vector? $ Rscript commandArgs.R 1:3 args=commandArgs(trailingOnly=TRUE) args[1]+10

Re: [R] How to convert a string passed as an argument to a vector?

2009-08-28 Thread jim holtman
If you have it as a character string, then you have to evaluate it: x - '1:3' x + 10 Error in x + 10 : non-numeric argument to binary operator No suitable frames for recover() eval(parse(text=x))+10 [1] 11 12 13 On Fri, Aug 28, 2009 at 11:04 AM, Peng Yupengyu...@gmail.com wrote: Hi, $