Dear List,

I am trying to make a histogram with following data:

dput(a)
c(1, 0, 1.5, 1, 0, 0, 0, 1, 1.5, 0, 0, 1, 0, 0, 0, 1, 1, 2, 1,
0, 0, 0, 1, 1, 1, 0, 1, 0.5, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0,
0, 0, 0, 0, 1, 1, 1, 0, 0, 1.5, 0, 0, 0, 0, 1, 0, 0, 0.5, 0,
0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 0, 0, 0, 1, 1, 0,
0, 0, 1.5)

So, I did

hist(a, freq = FALSE, breaks = 5)
but the first bar height is going above 1!
I did some checking

check <- hist(a, freq = FALSE, breaks = 5)
check$density

#[1] 1.146341 0.707317 0.097561 0.048780

first bar went above 1, however, the values should be
check$counts/length(a)
#[1] 0.57317 0.35366 0.04878 0.02439
sum(check$counts/length(a))
#[1] 1


What am I going wrong here?

Thank you for your time!

Regards,

Vikram.

sessionInfo()

R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252
 LC_MONETARY=English_India.1252
[4] LC_NUMERIC=C                   LC_TIME=English_India.1252
.
.
.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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