[R] Passing parameters with Rcmd BATCH

Prof Brian D Ripley ripley at stats.ox.ac.uk
Thu Jan 31 11:04:45 CET 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list