[Rd] recordPlot/replayPlot not working with saveRDS/readRDS

Winston Chang winstonchang1 at gmail.com
Mon Apr 2 19:23:06 CEST 2018


The documentation for recordPlot says the following:

> As of R 3.3.0, it is possible (again) to replay a plot from another R session using, for example, saveRDS and readRDS.

However, I haven't been able to save and restore a plot displaylist
and have it work within the same R session, using R 3.4.3 or 3.3.3.
Here's an example:

# Save displaylist for a simple plot
png('test.png')
dev.control(displaylist ="enable")
plot(1:5, 1:5)
r <- recordPlot()
dev.off()

# Replay plot. This works.
png('test1.png')
replayPlot(r)
dev.off()

#  Save the plot and load it, then try to replay it. This does not work.
saveRDS(r, 'recordedplot.rds')
r2 <- readRDS('recordedplot.rds')
png('test2.png')
replayPlot(r2)  ## Error: NULL value passed as symbol address
dev.off()


Is there something that I'm doing wrong here?



More information about the R-devel mailing list