From winstonchang1 at gmail.com  Mon Apr  2 19:23:06 2018
From: winstonchang1 at gmail.com (Winston Chang)
Date: Mon, 2 Apr 2018 12:23:06 -0500
Subject: [Rd] recordPlot/replayPlot not working with saveRDS/readRDS
Message-ID: <CAFOpNVE7oyo1P_JUeQbXcO_YbabXRcMoogeV=3ULesoX5BdfdQ@mail.gmail.com>

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?



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