[R] relative frequencies for hist()

Steffen Katzner steffen.katzner at mail.gwdg.de
Sat Aug 21 19:10:56 CEST 2004


I have problems getting a histogram with relative frequencies on the y-axis.

Here is an example data set:

 > a <- c(4.626, 4.627, 4.627, 4.628, 4.629, 4.629, 4.630, 4.631, 4.632, 
             4.632)
 > d = hist(a,freq=F)
 > d$density
[1] 299.9999 100.0000 200.0000 100.0000 100.0000 200.0000

The obtained densities are given by counts/(total n * bin width), with 
bin width being 0.001 in this case.

Is there any way to get a histogram with relative frequencies 
irrespective of bin width, i.e. counts/total n ? It doesn't seem to work 
for truehist() either.

Thanks.
Steffen




More information about the R-help mailing list