[R] for loop for automatic pdf generation

stephen sefick ssefick at gmail.com
Tue Dec 15 14:17:21 CET 2009


I know this is not reproducible, but I don't want to clog up mail
boxes with the data frame.  I would be happy to send this off list.  I
am sure that I am missing something simple. The plotting works if I
just paste the call to qplot into R and replace the [i] with a number.
  Thanks for all of your help in advance.


#loop to spit out PDFs
list.names <- as.character(unique(braggxsec[,"Creek"]))
for(i in 1:length(list.names)){
	pdf(paste("~/Desktop/base_pdf_xsec/", list.names[i], ".pdf", sep=""))
	qplot(measurment_num, value , data=subset(braggxsec.melt,
Creek==list.names[i]), colour=variable, geom="line", xlab="meters
across the channel", ylab="meters from bankfull", col="black",
linetype=variable,
main=list.names[i])+facet_grid(station~Creek)+scale_y_reverse(breaks=breaks)+scale_x_reverse()+theme_bw()+
opts(panel.grid.minor = theme_blank(), panel.grid.major=theme_blank())
	dev.off()
}

-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

								-K. Mullis




More information about the R-help mailing list