[R] problems hist() and density
Jan Teichmann
jan.teichmann at googlemail.com
Mon Jul 27 09:20:58 CEST 2009
Thank you. I'm sorry for my question. Sure, I've to integrate a density
function to get the probabilities... I didn't noticed the small breaks
and that's why I was confused. I expected a histogram with probabilities
for the realizations.
Am Sonntag, den 26.07.2009, 14:27 -0400 schrieb jim holtman:
> "sums to one" I should have said.
>
> On Sun, Jul 26, 2009 at 7:43 AM, Jan
> Teichmann<jan.teichmann at googlemail.com> wrote:
> > Hello,
> >
> > I have a problem with the hist() function and showing densities. The
> > densities sum to 50 and not to 1! I use R version 2.9.1 (2009-06-26) and
> > I load the seqinR library.
> >
> > My data is the following vector:
> > [1] 0.1400000 0.2000000 0.2200000 0.2828283 0.1600000 0.1600000
> > 0.3600000
> > [8] 0.1600000 0.2200000 0.2600000 0.2000000 0.3000000 0.2200000
> > 0.2342342
> > [15] 0.1800000 0.2200000 0.1600000 0.2300000 0.2000000 0.2200000
> > 0.2400000
> > [22] 0.2000000 0.2200000 0.2200000 0.2600000 0.2000000 0.1600000
> > 0.2200000
> > [29] 0.2342342 0.2000000 0.2200000 0.2000000 0.2000000 0.1400000
> > 0.1800000
> > [36] 0.2200000 0.1600000 0.1600000 0.1400000 0.2200000 0.2000000
> > 0.2871287
> > [43] 0.2900000 0.2000000 0.1836735 0.2000000 0.2000000 0.2900000
> > 0.2400000
> > [50] 0.2200000 0.2800000 0.2000000 0.2745098 0.2200000 0.2300000
> > 0.1800000
> > [57] 0.2300000 0.1800000 0.2600000 0.2200000 0.2222222 0.2200000
> > 0.2600000
> > [64] 0.2200000 0.2200000 0.2600000 0.2200000 0.2000000 0.2200000
> >
> > I use the following command:
> > tmp <- hist(data, freq=FALSE, plot=FALSE)
> >
> > and that's the result:
> > $breaks
> > [1] 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36
> >
> > $counts
> > [1] 10 4 15 19 8 5 2 5 0 0 1
> >
> > $intensities
> > [1] 7.2463754 2.8985507 10.8695652 13.7681159 5.7971014 3.6231884
> > [7] 1.4492754 3.6231884 0.0000000 0.0000000 0.7246377
> >
> > $density
> > [1] 7.2463754 2.8985507 10.8695652 13.7681159 5.7971014 3.6231884
> > [7] 1.4492754 3.6231884 0.0000000 0.0000000 0.7246377
> >
> > $mids
> > [1] 0.15 0.17 0.19 0.21 0.23 0.25 0.27 0.29 0.31 0.33 0.35
> >
> > $xname
> > [1] "data"
> >
> > $equidist
> > [1] TRUE
> >
> > attr(,"class")
> > [1] "histogram"
> >
> > ______________________________________________
> > R-help at 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.
> >
> >
>
>
>
More information about the R-help
mailing list