[R] Batch Execution of R

Thomas Lumley thomas at biostat.washington.edu
Sat Aug 12 19:07:50 CEST 2000


On Sat, 12 Aug 2000, Prof Brian D Ripley wrote:

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

> 
> You cannot specify a plot file from the command line, but you can specify

In fact you can: the commandArgs() function returns command line arguments
and you can smuggle in an output file name as an option

If you have infile.R as
  filename<-gsub("-o=","",grep("-o=",commandArgs(),value=T))
  print(filename)
  bitmap(file=filename)
  plot(rnorm(10))
  dev.off()

and do
 
R BATCH --slave --no-save -o=output.png infile.R

then you will get the file saved to output.png.  Passing options in this
way does cause R to give "WARNING: unknown option" but this is harmless
(and in the above example doesn't even appear since we don't save the
text output).

You would have a problem if we added a -o option to R, so it might be
safer to use
	--outputPNGfilename=output.png
or something of the sort


	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

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