On Sat, 2010-07-17 at 14:52 -0400, linda.s wrote: > > Open a new device before plotting, do your plotting, close the device. > > > > For example, using a PDF device via pdf(): > > > > pdf("my_plots.pdf", height = 8, width = 8, pointsize = 10, > > version = "1.4", onefile = TRUE) > > for(i in 1:10) { > > y <- rnorm(100) > > x <- rnorm(100) > > plot(y ~ x) > > } > > dev.off() > > > > The last line (dev.off() is very important as the file will not be valid > > pdf without closing the device. > > > > HTH > > > > G > > I got the error: > > pdf("my_plots.pdf", height = 8, width = 8, pointsize = 10, > + version = "1.4", onefile = TRUE) > > for(i in 1:10) { > + y <- rnorm(100) > + x <- rnorm(100) > + plot(y ~ x) > + } > > dev.off() > null device > 1
If by "error" you mean "null device \n 1", that is a notice informing you what the now current plotting device is, i.e. in this cases there isn't one. Did you look in your current working directory (see what that is by using getwd() ) for a pdf named "my_plots.pdf"? G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.