[R] Histogram binning
jim holtman
jholtman at gmail.com
Tue Aug 19 22:33:57 CEST 2008
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
>
> 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.)
>
> Montana Cooperative Fishery Research Unit
>
> Montana State University
>
> PO Box 173460
>
> Bozeman, MT 59717
>
> (406)994-6643
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list