[R] Superposed histograms

Damon Wischik djw1005 at cam.ac.uk
Fri Jan 10 11:42:03 CET 2003


I woud like to plot cumulative histograms. Specifically,
I have data like
    Sex     M   M   F   M   F   F   M   F
    Height  6   6.3 6.1 5.5 7.2 6.2 5.9 6.0  ....
and I want to plot a histogram of the distribution of all heights,
colouring the histogram bars according to sex, for example
   
  |    o   
  |   oo  o  
  | o oo ** o   o = observations of women
  | o o*o***o   * = observations of men
  | *o*******
  |----------

(And I want this in a Trellis plot, and with more than two groups of
observations.) How should I do this? I tried looking for imaginitive
combinations of panel.superpose and panel.histogram. I suppose if I called
panel.histogram for the cumulative data first, then panel.histogram for
just the data on men, with a different colour, I could achieve the effect. 
But I'd need to superpose the accumulated data, and panel.superpose seems
to only separate the data by group, not accumulate data by group.

Damon Wischik.




More information about the R-help mailing list