[R] Questions about histograms

Andre Nathan andre at digirati.com.br
Mon Feb 11 02:14:28 CET 2008


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))

  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



More information about the R-help mailing list