https://stackoverflow.com/a/11304431/91590
As per @naught101's suggestion - for a 5x7 (inch!) pdf file which is a convenient size to be pasted into an A4 Word document, the following works well:
dev.copy2pdf(file="example.pdf", width = 7, height = 5)
Better yet, as an easily-called function with default dimensions:
dopdf <- function(filename = "dopdf.pdf", pdf.width = 7, pdf.height = 5) {
dev.copy2pdf(file=filename, width = pdf.width, height = pdf.height)
}
While using ggplot2 would have let me save using the ggsave function, dev.copy2pdf is a good generic solution (answering my original question).
http://statistics.berkeley.edu/computing/saving-plots-r
For example, to create a png file called myplot.png from a graph that is displayed by R, type
dev.copy(png,'myplot.png') dev.off()
Primarily for print: http://gforge.se/2013/02/exporting-nice-plots-in-r/