Saving a ggplot2 object to be rendered on another system

I haven't seen this question anywhere in the past three years, so I was looking for a more up-to-date answer. I have about ten plots that I have created in ggplot2 that I am going to do to publish on the web. I was unable to make sense of the articles and posts I read regarding the lack of anti-aliasing in Windows R lines. Ideally I could just render them on my Windows laptop and export directly from it.The next best thing I think could be easier is to somehow save the plots as objects and load them on my Mac and render there. I know I can run the scripts used for them on my Mac and go through the full process, but I have quite a few dependencies (specifically file locations, etc. for my data) that I would have to edit. before I could even run them.This is my current plan, but I'm sure there is a better way. If anyone has any suggestions please send my way and thanks!

+3


source to share


1 answer


Use save

and load

, both are available from the R base:

save(p,file='~/p.Rdata')

      

and on another computer:



load('~/p.Rdata')

      

where p

is your plot, for example:

p <- ggplot(data.frame(x=1:5,y=runif(5))) + aes(x=x,y=y) + geom_point()

      

+1


source







All Articles