[R] Batch Execution of R

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sat Aug 12 08:41:35 CEST 2000


On Fri, 11 Aug 2000, John D. Funk, Jr. wrote:

> R Team:
> 
> This is most likely a trivial question, but after searching docs for
> several weeks and digging through Rweb and RCGI, I could not clearly
> identify the method to call an R method from Linux or Win32 systems and
> send the output to a file.  I would like to implement R as part of an

There is R BATCH on Linux, and equivalents for Windows in the rw-FAQ.

> online client-server application for a geographically spaced engineering
> team an would like to know how to run R like this:
> 
> jdf at vertigo$ R -infile="infile.R" -o="outplot.png"
> 
> where infile.R is a source script and
> outplot.png is a graphic produced by the script.

You need something like

R --restore --no-save < infile.R > outfile.Rout

(Rterm not R on Windows.)

You cannot specify a plot file from the command line, but you can specify
it from within the input script. For example, the V&R chapter scripts
contain things like

library(MASS)
options(width=65, digits=5, height=9999)
postscript(file="ch05.ps", width=8, height=6, pointsize=9)
...

I note that you are asking for png, and if you ensure that your script
will only produce one plot, you can use

bitmap(file="outplot.png", type="png256", width=4, height=3, ....)

at the start of your file.  (I suggest using the bitmap not png
device for batch use as the latter uses the graphics system. You do need
ghostscript installed to use bitmap: see its help page.)

You can control where text output goes from within the script by the sink()
function.

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