Ben Cox | 19 Aug 22:16
Favicon

Histogram binning

I am trying to produce frequencies in defined intervals however I can't seem
to figure out how to get R to bin my data the way I want it to.

I have several thousand lengths of fish that I want to be binned as follows:

Ex.

Length      Bin

209         200

219         210

431         430

727         720

That is, bins with any length equal to or greater than the lower cutoff, but
smaller than the next higher cutoff should be included.  I have tried using
the right=FALSE and include.lowest in the hist function but it still puts
lengths that is greater than the cutoff into the next bin.

All software seems to bin right, but fish nerds do it a little different.

Thanks!                              

Ben Cox

Graduate Research Assistant (M.S.)

(Continue reading)

jim holtman | 19 Aug 22:33

Re: Histogram binning

Is this what you want:

cuts <- c(0,209,429,719,1500)
x <- runif(1000,0,1447)
barplot(table(cut(x, breaks=cuts)))

On Tue, Aug 19, 2008 at 4:17 PM, Ben Cox <cox <at> montana.edu> wrote:
> I am trying to produce frequencies in defined intervals however I can't seem
> to figure out how to get R to bin my data the way I want it to.
>
>
>
> I have several thousand lengths of fish that I want to be binned as follows:
>
>
>
>
> Ex.
>
>
>
> Length      Bin
>
>
>
> 209         200
>
> 219         210
>
> 431         430
(Continue reading)


Gmane