Reputation: 800
How can I get Rstudio to save each plot in a separate file on disk when requesting multiple plots in an R script? this is easily done in R using savePlot command. It would be nice to use something that worked in both packages.
install.packages("RXKCD")
require(RXKCD)
getXKCD(which = "552")
savePlot("fun.emf","emf")
win.metafile("fun.wmf")
png("fun.png")
LOG:
> savePlot("fun.emf","emf") #this works in R but not in RStudio
Error in savePlot("fun.emf", "emf") :
can only copy from 'windows' devices
> win.metafile("fun.wmf") #File of size 0 is created
> png("fun.png") #File of size 0 is created
Thank you. Mary A. Marion
Upvotes: 1
Views: 564
Reputation: 1335
What I normally do (in Rstudio and in Sublime):
png("omg.png", 600, 600)
#pdf("omg.pdf", 7, 7)
plot(rnorm(10), rnorm(10))
dev.off()
For pdfs, I'd comment out the png function and I comment the pdf one.
Upvotes: 1