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

jeroen00ms jeroen.ooms at stat.ucla.edu
Mon Jul 11 18:08:15 CEST 2011

I am looking for a way to save a plot (graphics contents) to a file after the
plot has been calculated but before it has been rendered. More specifically,
assume that I made a plot that took a very long time to produce, I would
like to save this plot to a generic file that I can later, on a different
machine, render to either PDF, PNG, SVG using the usual R graphics devices,
without recalculating the graphical contents.

As a toy example, suppose this is my plot function:

testplot <- function(){
  Sys.sleep(10); #very long and complicated procedure

So the use case is that after running testplot() which took potentially 30
days to calculate, I would like to send a file to my colleagues that they
can load in R and send to their png or pdf or svg devices just as if they
would have made the plot themselves, without having to re-run the code.

View this message in context: http://r.789695.n4.nabble.com/Save-generic-plot-to-file-before-rendering-to-device-tp3659999p3659999.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list