[R] Yet another batch mode question
Mark E. Fenner
fenner at cs.pitt.edu
Tue Oct 9 15:57:12 CEST 2001
On Tue, 9 Oct 2001, Prof Brian D Ripley wrote:
> 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.
>
I did forget the "--no-save" or "--vanilla" or "--save" option that is
required for #2 but otherwise:
[mfenner at seneca testForList]$ cat test.R
x <- array(trunc(3*runif(100)), c(10,10))
mean(x)
[mfenner at seneca testForList]$cat results
Script started on Tue Oct 9 09:41:52 2001
[mfenner at seneca testForList]$ R --no-save < test.R
R : Copyright 2001, The R Development Core Team
Version 1.3.1 (2001-08-31)
<snip>
> x <- array(trunc(3*runif(100)), c(10,10))
>
> mean(x)
[1] 0.94
>
[mfenner at seneca testForList]$ R CMD BATCH test.R
[mfenner at seneca testForList]$ more test.Rout
R : Copyright 2001, The R Development Core Team
Version 1.3.1 (2001-08-31)
<snip>
> invisible(options(echo = TRUE))
> x <- array(trunc(3*runif(100)), c(10,10))
>
> mean(x)
[1] 0.8
> proc.time()
[1] 1.35 0.09 1.47 0.00 0.00
>
[mfenner at seneca testForList]$ exit
Script done on Tue Oct 9 09:42:43 2001
[mfenner at seneca testForList]$
In short, they both work for me. You can supress the echoing of commands
by placing a options(echo = FALSE) type line in your script file.
> 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
> ...
So, do people not use R in this fashion under Unix (as a general
rule)? That is, running R from the command line with a script and an
input file.
BTW, I am primarily interested in the Unix environment. Scripting under
Windows raises my blood pressure :) (unless it is in cygwin).
Regards,
Mark
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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