I can use ggplot2 to store the output of ggplot command to an object and call that object within grid.arrange to write to a file in an R script, as below:
p<-ggplot(x, aes(x=Date, y=Date)) + geom_bar(aes(x=Date,y=Data)
png("data.png", height=700, width=650)
grid.arrange(p, main=textGrob("Data"), gp=gpar(cex=2)
dev.off()
I am creating bunch of forecast graphs using plot but I cannot do the same thing. Any one has any suggestion how can I write the ouput of plot to a png file in a script?