Loop FOR with histogram() from lattice
If you have read the Posting Guide, you will know that you should have read ALL the FAQs before posting your question. http://cran.r-project.org/doc/FAQ/R-FAQ.html That said, this particular FAQ applies to any library that depends on grid graphics, including lattice and ggplot2. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity.
Xochitl CORMON <Xochitl.Cormon at ifremer.fr> wrote:
Hi Jim, Thank you a lot. Is it a FAQ concerning lattice or FOR loop in general? Regards, Xochitl C. Le 05/06/2013 10:55, Jim Holtman a ?crit :
This is an FAQ. you have to explicitly 'print' the histogram: print(histogram(~ Mpool[[2]]$LngtClas | Mpool[[2]]$SpCode, type =
"count", col = "lightgrey", xlab= "LngtClas", main = paste("Length
distribution per species for Mpool", "2", sep = "_")))
Sent from my iPad On Jun 5, 2013, at 4:37, Xochitl CORMON<Xochitl.Cormon at ifremer.fr>
wrote:
Hi all,
I'm encountering a problem I do not understand on my data:
library (lattice)
Mpool1<- Table[Table$Subarea %in% c("52E9", "51E9"),]
Mpool2<- Table[Table$Subarea %in% c("53F0", "52F0"),]
Mpool3<- Table[Table$Subarea %in% c("51F0", "50F0"),]
Mpool4<- Table[Table$Subarea %in% c("51F1", "52F1"),]
Mpool<- list(Mpool1, Mpool2, Mpool3, Mpool4)
histogram(~ Mpool[[2]]$LngtClas | Mpool[[2]]$SpCode, type = "count",
col = "lightgrey", xlab= "LngtClas", main = paste("Length distribution
per species for Mpool", "2", sep = "_"))
#### This part works perfectly and I obtain the graph reprensenting
Mpool2 length class count per species.
#### Now when I want to automatize this with a "for" loop nothing is
plotted.
for (i in c(2)){
windows()
histogram(~ Mpool[[i]]$LngtClas | Mpool[[i]]$SpCode, type = "count",
col = "lightgrey", xlab= "LngtClas", main = paste("Length distribution
per species for Mpool", i, sep = "_"))
print (i) } ### Running this loop I obtained windows filled grey (no plot drawn
at all) but the print (i) print a "2" as expected. I really dont understand what's wrong with the loop. There is no error message and no notification in R. You can find enclosed my data in txt file.
Thank you very much for any help, Xochitl C. <>< <>< <>< <>< Xochitl CORMON +33 (0)3 21 99 56 84 Doctorante en sciences halieutiques PhD student in fishery sciences <>< <>< <>< <>< IFREMER Centre Manche Mer du Nord 150 quai Gambetta 62200 Boulogne-sur-Mer <>< <>< <>< <>< <Table.txt>
______________________________________________ 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. ______________________________________________ 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.