[R] histogram breaks as labels

Albert Vilella avilella at gmail.com
Mon May 8 15:11:34 CEST 2006


On Mon, 2006-05-08 at 14:22 +0200, Dimitris Rizopoulos wrote:
> try something along these lines:
> 
> input <- rpois(1000, 5)
> myhist <- hist(input, breaks = 15, plot = FALSE)
> plot(myhist, labels = as.character(myhist$breaks[-1]), axes = FALSE)

it seems to give me the labels slided by one, but it seems to works
with:

plot(myhist, labels = as.character(myhist$breaks[-length(myhist
$breaks)]), axes = FALSE)

at least for the example I'm using,

Thanks Dimitris,

    Albert.


> 
> 
> I hope it helps.
> 
> Best,
> Dimitris
> 
> ----
> Dimitris Rizopoulos
> Ph.D. Student
> Biostatistical Centre
> School of Public Health
> Catholic University of Leuven
> 
> Address: Kapucijnenvoer 35, Leuven, Belgium
> Tel: +32/(0)16/336899
> Fax: +32/(0)16/337015
> Web: http://www.med.kuleuven.be/biostat/
>      http://www.student.kuleuven.be/~m0390867/dimitris.htm
> 
> 
> ----- Original Message ----- 
> From: "Albert Vilella" <avilella at gmail.com>
> To: <r-help at stat.math.ethz.ch>
> Sent: Monday, May 08, 2006 2:01 PM
> Subject: [R] histogram breaks as labels
> 
> 
> > Hi all,
> >
> > I would like to know if there is a way to have the diplay the breaks
> > of the hist (as myhist$breaks here in the example) as the labels,
> > instead of the myhist$counts:
> >
> > input = rpois(1000,5)
> > myhist = hist(input, breaks = 15, labels=TRUE, axes=FALSE)
> >
> > So that, instead of having:
> >
> > "94 140 187 181 145 117  68  42  15   5   1   5"
> >
> > on top of the columns, I have:
> >
> > "1  2  3  4  5  6  7  8  9 10 11 12 13"
> >
> > as in myhist$breaks.
> >
> > Thanks in advance,
> >
> >    Albert.
> >
> > ______________________________________________
> > 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
> > 
> 
> 
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>




More information about the R-help mailing list