[R] for loop for automatic pdf generation

stephen sefick ssefick at gmail.com
Tue Dec 15 14:32:18 CET 2009


Sorry for not reading the FAQ- that solved the problem.


#loop to spit out PDFs
list.names <- as.character(unique(braggxsec[,"Creek"]))
pdf("~/Desktop/base_pdf_xsec/braggxsec.pdf")
for(i in 1:length(list.names)){
f <- 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())
print(f)
}
dev.off()

On Tue, Dec 15, 2009 at 7:22 AM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be> wrote:
> Dear Stephen,
>
> You need to print() the plot explicitly. This is FAQ 7.22
> (http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis
> -graphics-not-work_003f)
>
> HTH,
>
> Thierry
>
> ------------------------------------------------------------------------
> ----
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek
> team Biometrie & Kwaliteitszorg
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> Research Institute for Nature and Forest
> team Biometrics & Quality Assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> tel. + 32 54/436 185
> Thierry.Onkelinx at inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to
> say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of
> data.
> ~ John Tukey
>
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> Namens stephen sefick
> Verzonden: dinsdag 15 december 2009 14:17
> Aan: r-help at r-project.org
> Onderwerp: [R] for loop for automatic pdf generation
>
> 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=bre
> aks)+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
>
> ______________________________________________
> R-help at 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.
>
> Druk dit bericht a.u.b. niet onnodig af.
> Please do not print this message unnecessarily.
>
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
> en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
> door een geldig ondertekend document. The views expressed in  this message
> and any annex are purely those of the writer and may not be regarded as stating
> an official position of INBO, as long as the message is not confirmed by a duly
> signed document.
>



-- 
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