[R] hist() bar width definition

peter dalgaard pdalgd at gmail.com
Fri Sep 11 17:56:10 CEST 2015


On 11 Sep 2015, at 15:00 , Ana Raquel Felizardo Rodrigues <arfelizardo at isa.utl.pt> wrote:

> Hi,
> 
> I have a realy dumb question about hist(). Is it possible to define classes width independently from breaks? I have breaks=c(0,2,100,max(mydata)), but would like the 3 bars to have the same width and to label x axe with 0, 2 and >100. Can anyone help me?

It's not a histogram then....

I think it is both practically and conceptually easier to do it as a barplot, as in

f <- cut(x, breaks=c(....))
levels(f) <-  c("0-2", "3-100", ">100") # or whatever...
barplot(table(f))

-pd 


> 
> Thank you all!
> 
> Ana Raquel Rodrigues
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list