[R] Yet another batch mode question

Mark E. Fenner fenner at cs.pitt.edu
Tue Oct 9 01:17:59 CEST 2001

Hello all and thanks in advance,

I know you can start R with either:

1.  R CMD BATCH myfile.R


2. R < myfile.R

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):


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

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.


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