1 May 2009 04:28
Re: Evaluating content of command line arguments
Gabor Grothendieck <ggrothendieck <at> gmail.com>
2009-05-01 02:28:49 GMT
2009-05-01 02:28:49 GMT
Check out the getopt package. On Thu, Apr 30, 2009 at 10:10 PM, JiHO <jo.lists <at> gmail.com> wrote: > Hello everyone, > > I am writing an R script which will be provided with command line arguments > by a shell script. I read them with commandArgs() but I have an issue to > make that fool proof. > > For example, with test.R containing: > > args=commandArgs(trailingOnly=TRUE) > args > > I get: > > $ Rscript test_commandLineArgs.R 3 4 5 > [1] "3" "4" "5" > > Now, to make the input more flexible and robust, I want to pass *named* > arguments, so that the R script does not depend on the order of arguments > passed and can check which are present/absent etc. I.e. > > $ Rscript test_commandLineArgs.R foo=3 bar=4 5 > [1] "foo=3" "bar=4" > > But I am stuck on how to actually execute the code within those strings so > as to get two variables foo and bar equal to 3 and 4 respectively. I looked > at eval, deparse, substitute and all that but did not find anything. Is that > possible?(Continue reading)
RSS Feed