Re: [R] Questions about histograms

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Sun, 10 Feb 2008 20:36:01 -0500

On 10/02/2008 8:14 PM, Andre Nathan wrote:
> Hello
>
> I'm doing some experiments with the various histogram functions and I
> have a two questions about the "prob" option and binning.
>
> First, here's a simple plot of my data using the default hist()
> function:
>

>> hist(data[,1], prob = TRUE, xlim = c(0, 35))

>
> http://go.sneakymustard.com/tmp/hist.jpg
>
> My first question is regarding the resulting plot from hist.scott() and
> hist.FD(), from the MASS package. I'm setting prob to TRUE in these
> functions, but as it can be seen in the images below, the value for the
> first bar of the histogram is well above 1.0. Shouldn't the total area
> be 1.0 in the case of prob = TRUE?
>
>> hist.scott(data[,1], prob = TRUE, xlim=c(0, 35))

It looks to me as though the area is one. The first bar is about 3.6 units high, and about 0.2 units wide: area is 0.72. There are no gaps between bars in an R histogram, so the gaps you see in this jpg are bars with zero height.

Duncan Murdoch

>
> http://go.sneakymustard.com/tmp/scott.jpg
>

>> hist.FD(data[,1], prob = TRUE, xlim=c(0, 35))

>
> http://go.sneakymustard.com/tmp/FD.jpg
>
> Is there anything I can do to "fix" these plots?
>
> My second question is related to binning. Is there a function or package
> that allows one to use logarithmic binning in R, that is, create bins
> such that the length of a bin is a multiple of the length of the one
> before it?
>
> Pointers to the appropriate docs are welcome, I've been searching for
> this and couldn't find any info.
>
> Best regards,
> Andre
>
> ______________________________________________
> 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.


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 Mon 11 Feb 2008 - 01:42:32 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 Mon 11 Feb 2008 - 02:30:14 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