[R] Save generic plot to file (before rendering to device)

Greg Snow Greg.Snow at imail.org
Mon Jul 11 22:08:05 CEST 2011


Note the warning on the help page for recordPlot.  If your colleague is using a different version of R than you there could be problems.

Another approach (or the start to one that you could build on) is the plot2script function in the TeachingDemos package (which uses recordPlot internally). 

But it is probably best to save the resulting data from the long process, that could then be quickly plotted as others have mentioned.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Jeroen Ooms
> Sent: Monday, July 11, 2011 12:22 PM
> To: David Winsemius
> Cc: r-help at r-project.org
> Subject: Re: [R] Save generic plot to file (before rendering to device)
> 
> >
> > You can also save a data (or function) object to an .Rdata file with
> > save(objname, file="filename.Rdata")  and your colleagues could then
> > load("filename.Rdata") in R.
> >
> 
> Thanks for the responses. I found an old post by Gabor Grothendieck
> that
> shows what I want. Basically the trick is to save the displaylist to an
> object:
> 
> dev.control(displaylist="enable") # enable display list
> plot(1:10)
> myplot <- recordPlot() # load displaylist into variable
> 
> You can now store myplot and later fetch it and play it back via
> 
> print(myplot)
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list