Subject: Re: [R] Passing parameters with Rcmd BATCH
From: [email-masked]
To: [email-masked]
Cc: [email-masked]
Date: Thu, 31 Jan 2002 02:04:45 -0800 (PST)

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,                  [email-masked]
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: [email-masked]
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._