Aydemir, Zava (FID)
2007-Jul-18 20:00 UTC
[R] passing a parameter to a file from command line
Hi, I have a file fileFoo.R, say that contains these two lines, invoking function foo that is specified in "foo_details.R": source("foo_details.R") foo(parameter1) I want to specify and pass parameter1 in my command line when invoking R in linux: R --no-save <fileFoo.R. How can I do that? And how can I retrieve the value of parameter1 in my fileFoo.R function (something analogous to perl: my $parameter1=$ARGV[0])? Thank you Zava -------------------------------------------------------- This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
Look at the commandArgs function to see if that does what you want. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of > Aydemir, Zava (FID) > Sent: Wednesday, July 18, 2007 2:00 PM > To: R-help at stat.math.ethz.ch > Subject: [R] passing a parameter to a file from command line > > Hi, > > I have a file fileFoo.R, say that contains these two lines, > invoking function foo that is specified in "foo_details.R": > > source("foo_details.R") > foo(parameter1) > > > I want to specify and pass parameter1 in my command line when > invoking R > in linux: R --no-save <fileFoo.R. > > How can I do that? > And how can I retrieve the value of parameter1 in my > fileFoo.R function (something analogous to perl: my > $parameter1=$ARGV[0])? > > Thank you > > Zava > -------------------------------------------------------- > > This is not an offer (or solicitation of an offer) to > buy/se...{{dropped}} > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >