I'm trying to write many graphs to one olocation, but instead its writing a bunch of blank pictures:
my code looks like:
titleplot<-NULL
for(i in 1:99){
titleplot<-colnames(data[i])
mypath <- file.path("C:","Users","user.ME","Desktop","graph outputs", paste("myplot_", titleplot, ".jpg", sep = ""))
plot(data[,i],type="l", main =titleplot)
jpeg(file=mypath)
dev.off()
}
Does anyone know why this would happen or how I can remedy this?
You are supposed to put your jpeg
command before you call your plot
command.
jpeg(file=mypath)
plot(...)
dev.off()
Combination of the answers from Mohammed Shaker and asb gives this really simple code:
for (i in dev.list()[1]:dev.list()[length(dev.list())]) {
dev.off()
}
This removes all open graphics devices:
> dev.list()
NULL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With