[Rd] [FORGED] recordPlot/replayPlot not working with saveRDS/readRDS
Paul Murrell
paul at stat.auckland.ac.nz
Mon Apr 2 23:41:56 CEST 2018
Hi
What you are doing "wrong" is loading a recordedplot into the same
session that it was created in. The saveRDS()/readRDS() works if you
save in one R session and then read in a different R session. The
assumption is that if you are still in the same session that created the
recordedplot you still have the recordedplot (e.g., you can just do
replayPlot(r) instead of replayPlot(r2). Is that a bad assumption ?
Paul
On 03/04/18 05:23, Winston Chang wrote:
> 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?
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-devel
mailing list