[R] Yet another batch mode question
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Tue Oct 9 08:32:25 CEST 2001
On Mon, 8 Oct 2001, Mark E. Fenner wrote:
> Hello all and thanks in advance,
>
> I know you can start R with either:
>
> 1. R CMD BATCH myfile.R
>
> or
>
> 2. R < myfile.R
Um, you can't: try it to see the fatal error.
> My question is this: what if I want multiple input files and/or command
> line arguments. For example, under unix you can run a script command (in
> a shell language, perl, or python) like:
>
> python myScript.py
>
> or better yet, if you have things set up right, you can place a
> #!/usr/bin/python line at the beginning of the file and then just type (at
> the shell command line):
>
> ./myScript.py
>
> Now, if I wanted to specify a file to work with and a method to use, I
> would just do:
>
> ./myScript.py file1 method1
>
> How could I get this behavior in R? With the commandArg() function I can
> retrieve the arguments at the command line, but I'm puzzling over the best
> way to implement this system at the command line so that it will be
> consistent regardless of how someone chooses to run the script (be it
> method 1 or 2 above).
At present 1 does not pass along further arguments, but sends R method 2
(well, with enough flags to make it work).
If you give 2 further arguments, you will get a strident warning like
auk% R foo
ARGUMENT 'foo' __ignored__
R : Copyright 2001, The R Development Core Team
...
> I suppose I could create a script file in {python, perl, bash, etc} that
> would simply take the arguments I want and provide them to R in a uniform
> manner but a "standalone" R method would be preferable.
Your examples are entirely Unix, so I am not sure if you are interested in
anything else, but R needs to be. Already on Windows R allows a file name
to be used as an extra argument: this is needed for file associations and
for drag-and-drop to work. We have considered allowing that on Unix too.
so that
R /path/to/.Rdata
and
R /path/to/somescript.R
might work. (Only the first is implemented on Windows at present.)
--
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