[R] How to save graphics in portable way in batch mode?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Sep 30 15:13:36 CEST 2004


"Khamenia, Valery" <V.Khamenia at biovision-discovery.de> writes:

> Hi all,
> 
> What is the right portable way to save graphics 
> in batch mode?
> 
> Remarks:
> 
>   1. Problem is STFWed and RTFMed. In particular a short note 
>      about png() is found in R-FAQ. In fact, there were stated 
>      that png() is not reliable under Linux in batch mode.
> 
>   2. savePlot under windows is quite convenient, but 
>      not supplied under Linux.
> 
>   3. pdf() + postscript() < savePlot()
>      Indeed, savePlot does support much more image formats 
>      and is flexible in changing type of output via its
>      argument.
> 
>   4. The scheme 
> 
>      "postscript(); plot(); dev.off();" 
> 
>      makes R-scripts not really nice. Indeed, if one's script 
>      had about 15 plot calls then in order to save graphics 
>      one need to add 15 times the postscript() in prior of 
>      plot() call and then 15 times the dev.off() as epilogue 
>      to plot() call.
> 
>   5. Hm, one could create function similar to Sweave() 
>      (see R-1.9.1\src\library\utils\R\Sweave.R) and 
>      benefit from automatic name generation and saving.
>      But it is quite unnatural, isn't it?
>       
> so, it would be nice to know what is the "right way".

Looks like you may have RTFM but didn't RTWFM (or even RTWHP). Check
out the "onefile" argument in postscript().


> P.S. BTW, will be there any specific changes in R-2.x?

The sources are available....

E.g. https://svn.r-project.org/R/trunk/NEWS

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list