On Wed, 2007-04-25 at 13:21 -0400, Mike Huber wrote:
> Hi,
> 
> I'm looking to automate the generation of some graphs in R.  I can't seem to
> figure out how to script R, and change the output device of hist() or plot()
> to create a .gif or .png file.  This seems like something that is probably
> really simple, and I've just overlooked the call do do it.  Can anyone point
> me in the right direction, or maybe send a sample script?

To plot multiple PNG files

m <- matrix(runif(100*10), nrow=10)
png(filename = 'plot%03d.png')
for (i in 1:nrow(m)) {
  plot(m[i,])
}
dev.off()

To plot multiple graphs as individual pages of a PDF file

m <- matrix(runif(100*10), nrow=10)
pdf(file = 'plot.pdf')
for (i in 1:nrow(m)) {
  plot(m[i,])
}
dev.off()

HTH,

-------------------------------------------------------------------
Rajarshi Guha <[EMAIL PROTECTED]>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
-------------------------------------------------------------------
In matrimony, to hesitate is sometimes to be saved.
-- Butler

______________________________________________
[email protected] 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.

Reply via email to