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

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to