When I am plotting, I often plot to an eps
file and a png
file like this:
postscript(file=paste(dir, output, "_ggplot.eps", sep=""), onefile=FALSE, horizontal=FALSE, width=4.8, height=4.0)
# Plotting code
dev.off()
png(paste(dir, output, "_ggplot.png", sep=""), width=450, height=300)
# Plotting code
dev.off()
The problem is that the plotting code is repeated twice. Is it possible to specify multiple devices for plotting?
p <- qplot(1,1) ; l_ply(c("png", "pdf"), function(ext, ...) ggsave(paste("_ggplot.", ext, sep=""), p, ...))
could avoid duplication of code.