Hi, When using ggplot, take a look at facet_wrap and geom_histogram.
regards, Paul On 10/17/2011 12:14 PM, Sarah Goslee wrote: > Hi, > > On Mon, Oct 17, 2011 at 8:07 AM, a217 <aj...@case.edu> wrote: >> I have a dataframe in the general format: >> >> chr1 0.5 >> chr1 0 >> chr1 0.75 >> chr2 0 >> chr2 0 >> chr3 1 >> chr3 1 >> chr3 0.5 >> chr7 0.75 >> chr9 1 >> chr9 1 >> chr22 0.5 >> chr22 0.5 > Using dput to give us some reproducible data would be even better. > >> where the first column is the chromosome location and the second column is >> some value. What I'd like to do is have a histogram created for each chr >> location (i.e. a separate histogram for chr1, chr2, chr3, chr7, chr9, and >> chr22). I am just having a hard time getting everything to work out and am >> hoping for some suggestions. > And telling us what you've tried would also help. > > par(mfrow=c(2,3)) > hist(mydata[mydata[,1] == "chr1", 2]) > hist(mydata[mydata[,1] == "chr2", 2]) > hist(mydata[mydata[,1] == "chr3", 2]) > hist(mydata[mydata[,1] == "chr7", 2]) > hist(mydata[mydata[,1] == "chr9", 2]) > hist(mydata[mydata[,1] == "chr22", 2]) > > > So obviously that is completely untested because I don't have your > sample data, but might give you the idea. > > Sarah -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 ______________________________________________ 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.