When I use pdf(\"somefile.pdf\")
to save my plots to a pdf file, everything seems to work. No error messages or whatsoever. Still the result is screwed (file size i
Did you remember to close the file via dev.off()
before trying to view it?
(See also: problem saving pdf file in R with ggplot2 )
The pdf and png devices work a little different. The pdf device by default will put multiple plots into a single file, so it will not finalize the file until you tell it that you are finished creating the plots (with dev.off). The png device will put 1 plot in 1 file, so will create multiple files for multiple plots. So as soon as you start a second plot, the 1st file will be finalized and can be opened and used. You still need dev.off to finalize the last file after the last plot.