[R] Histogram with uneven bins

jim holtman jholtman at gmail.com
Thu Apr 19 19:39:02 CEST 2007


will this work for you?

x <- runif(1000, 0, 40)
x.c <- cut(x, breaks=c(0, 1, 3, 6, 10, Inf))
barplot(table(x.c))


On 4/19/07, mtb954 at gmail.com <mtb954 at gmail.com> wrote:
> Hi R-helpers
>
> I would like to produce a histogram with uneven bins (e.g., 0, 1-2, 3-5,
> 6-10, 10-20, >20) but I would like the resulting bars to be the same width (
> i.e., a bar's width would not be proportional to its corresponding bin
> size).
>
> Also, the x and y axes of my histograms frequently (almost always, actually)
> extend beyond the axis labels (i.e., there are unlabeled bars). I would like
> to label each bar exactly with the range of values that corresponds to it (
> i.e., print a "0" underneath the 0 bin, print "1-2) underneath the 1-2 bin,
> etc.
>
> I'd appreciate any help you might be able to provide, thanks!
>
> Mark
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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 you are trying to solve?



More information about the R-help mailing list