Re: [R] Bug with hist() ?

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Thu, 31 Jan 2008 12:50:35 +0100

>>>>> "NS" == Ng Stanley <stanleyngkl_at_gmail.com> >>>>> on Thu, 31 Jan 2008 16:56:26 +0800 writes:

    NS> Hi,
    NS> Is this a bug from hist() ? The total density is greater than 1.

no, the bug is in your thinking...

Hint: 2 * 1/2 = 1

>> test

    NS> [1]  0.05077802 -0.50585520 -0.98053648 -0.35513059  0.86767129  0.61736097
    NS> [7]  0.14264062  0.26243841 -0.41477782  0.64172618  0.87230953 -0.62570629
    NS> [13]  0.43596467 -0.93214106 -0.26781599

>> h <- hist(test, freq = FALSE, main="Histogram of correlation", ylab =
    NS> "Frequency", xlab = "Correlation", ylim =c(0.0, 1.0))
>> h$breaks

    NS> [1] -1.0 -0.5 0.0 0.5 1.0
>> h$density

    NS> [1] 0.5333332 0.4000000 0.5333333 0.5333333
>> h$counts

    NS> [1] 4 3 4 4

    NS> Thanks
    NS> Stanley

    NS> [[alternative HTML version deleted]]

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

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. Received on Thu 31 Jan 2008 - 12:01:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 Jan 2008 - 13:30:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive