[R] relative frequencies for hist()

Wolski wolski at molgen.mpg.de
Sat Aug 21 20:00:15 CEST 2004


Hi!

d$counts/length(a)


And of course you can if it is what you want.

d$density<-d$counts/length(a)
plot(d,freq=F)


Sincerely Eryk


*********** REPLY SEPARATOR  ***********

On 8/21/2004 at 7:10 PM Steffen Katzner wrote:

>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
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



Dipl. bio-chem. Eryk Witold Wolski    @    MPI-Moleculare Genetic   
Ihnestrasse 63-73 14195 Berlin       'v'    
tel: 0049-30-83875219               /   \    
mail: wolski at molgen.mpg.de        ---W-W----    http://www.molgen.mpg.de/~wolski




More information about the R-help mailing list