[R] BATCH versus pasting commands

Prof Brian D Ripley
Fri, 08 Feb 2002 08:06:55 -0000

On Fri, 8 Feb 2002, David Scott wrote:

>
>
> I have a problem with trying to run a batch job. I am looping over a
> number of variables in a dataframe, doing some plots and wilcoxon tests.
> Then I restrict to a subset of the data, and do the same thing.
>
> Because of missing data, some of the wilcoxon tests fall over, so I have
> used try to get past them. Using R CMD BATCH, the job terminates with a
> syntax error after the first loop is completed. If I just paste the whole
> file into R, it runs through without a problem. I can break it up into two
> command files and use a shell script, but I would welcome and
> explanation of why I have the problem. Any other workarounds would
> interest me too.

The setting of error recovery is different under interactive and batch use.
R BATCH is batch use (of course) but so is R < infile.

To change that under batch use

1) Use options(error==expression(NULL)) to get continuation past errors,

or

2) wrap the test that might fail in a try() construct.

Option 2) is of course safer and so preferred.


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