[R] Question about histogram

Longe longeliver at gmail.com
Thu Jan 13 19:37:01 CET 2011


Dear list,

I'm new to R, please bear with my silly questions.  I'm trying to get an 
understanding of why the results I get from a call to hist() are not as 
I thought I would get.  When I use the parameter freq=FALSE, I think the 
plot will contain bars that none of them is larger than 1, because 
they're probabilities.  But for my code, the bars exceeded 1.

The actual data seems immaterial.  I tried with dummy data:

 > hist(runif(1000), freq=FALSE)

and the histogram includes bars well over 1 in height.  The man page 
says that freq=FALSE produces densities, so that the total area is 1.  
Clearly if all the values are between 0 and 1, as is the case here, some 
of the bars stand out above 1, for the area to be 1.  I thought that it 
is the sum of the bar heights that would be 1, so that the bars reflect 
probabilities for each interval, rather than densities.  So, the answer 
to my question would be "because it's densities, not probabilities", but 
then the question is, why densities and not probabilities?

Regards,
L.



More information about the R-help mailing list