[R] R hist density wrong?
Luca Cerone
luca.cerone at gmail.com
Wed Nov 18 09:49:00 CET 2015
Dear all,
this is probably a very naive question but I can't understand what
hist() means by density.
A very simple example:
h <- hist(c(1,1,2,3), plot=F)
h$counts
[1] 2 1 0 1
h$density
[1] 1.0 0.5 0.0 0.5
The counts are as I expect, but density is quite puzzling for me.
I would have expected to obtain the probability of that bin (i.e. 0.5,
0.25, 0, 0.25),
but I can't understand how those numbers come out.
Sometimes sum(h$density) is equal to 1 as I would expect, though.
What am I misunderstanding here?
Thanks a lot for the help!
Cheers,
Luca
More information about the R-help
mailing list