开发者

How do I resuscitate a ggplot that was saved to disk inside a list?

I created several hundred plots using ggplot and saved them all to a list. I saved the list to disk using:

save(list_of_plots,file="list_of_plots.rdata")

Now I want to display those plots and save some using ggsave. However, calling a list item just shows me components of the plot.

> names(plots00_t2[[1]])
[1] "data"        "layers"      "scales"      "mapping"     "options"    
[6] "coordinates" "facet"       "plot_env"   

Update: My dumb mistake was not load开发者_JS百科ing ggplot2 when I reopened these files. However, when attempting to display these plots, I get:

Error in get("make_aesthetics", env = x, inherits = TRUE)(x, ...) : 
  could not find function "calc_aesthetics"

So short of recreating these plots, how would I fix this?


the last version using the internal function calc_aesthetics was ggplot2 version 0.8.2. If possible, check which version of ggplot2 is used for creating the plots and load that one. Otherwise, try with version 0.8.2 or earlier.

Download the file from http://cran.r-project.org/src/contrib/Archive/ggplot2/ and save it somewhere on your computer (I used G:/Temp here). Then use this code to install and call the specific version :

install.packages(
  "G:Temp/ggplot2_0.8.2.tar.gz",
  lib="G:/Templibs",
  repos=NULL,
  type="source")

library(ggplot2,lib.loc="G:/Templibs")

After this, you should be able to print the graphs. See also this question and the help files of ?library and ?install.packages


It might happen that the code of ggplot2 was changed in meanwhile and "calc_aesthetics" is no longer available. In this case you should install an older version of ggplot2, to recover your work.

Though, the above is quite unlikely. The problem seems to stem from the fact that some parts of your plots have not been saved properly.

You should produce the traceback(), it might cast some light on the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜