[R] Combining two histograms

Sean Davis sdavis2 at mail.nih.gov
Wed Feb 2 14:42:22 CET 2005


I have data like:

a <- rnorm(20000)
b <- rep(FALSE,20000)
b[sample(1:20000,15000)] <- TRUE

Using Lattice graphics, I can produce two side-by-side histograms quite 
easily by:

histogram(a | b)

However, I would like to produce a "single" histogram with two bars 
within each bin, one for each group, as the groups are in reality very 
slightly different from each other.  The difference isn't evident 
unless one "overlays" the two histograms in some manner.

Thanks,
Sean




More information about the R-help mailing list