Hello!
How can I pass arguments with Rcmd BATCH and commandArgs() ?
"Rcmd BATCH myparameter input.R output"
and similar permutations do not work.
Thanks for your help!
Petra Steiner
-
---------------------------------------------------
Petra Steiner
Arbeitsbereich Linguistik
Universitaet Muenster
Huefferstrasse 27
48149 Muenster
Tel: 0251 / 83 39442
petra at marley.uni-muenster.de
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 31 Jan 2002, Petra Steiner wrote:> Hello! > > How can I pass arguments with Rcmd BATCH and commandArgs() ? > > "Rcmd BATCH myparameter input.R output" > > and similar permutations do not work.They do not work, and they are documented not to work: try Rcmd BATCH --help. A convenient way is to use environental variables, and the easiest way to do that is Rterm --restore --save < input.R > output MYPAR=foo and in input.R mypar <- Sys.getenv("MYPAR") My recollection is that you *can* add parameters to the command line with Rterm and use commandArgs(), but this is not a documented feature. Duncan Temple Lang has been promising it (on all ports of R) from time to time. (What does work on Windows but is undocumented (it supports file associations) is to append to the command line of Rgui or Rterm the path to a .RData file, which is used in place of the one in the working directory.) -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Prof. Ripley,
thanks for your answer. This might be useful for other novices:
Something like Rterm --restore --save < input.R > out COL=6
does the job.
In input.R:
co <- as.numeric(Sys.getenv("COL"))
But commandArgs() works as well for Rterm.
Regards,
Petra Steiner
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._