[R] color individual bar of histogram?
armstrong.whit at gmail.com
Tue Oct 28 20:28:43 CET 2008
That's great, Peter.
Thanks very much.
On Tue, Oct 28, 2008 at 3:13 PM, Peter Dalgaard
<P.Dalgaard at biostat.ku.dk> wrote:
> Whit Armstrong wrote:
>> Anyone know a quick way to color one bar of a histogram?
>> I want to mark the bar in which the most recent observation falls.
>> So, for instance:
>> x <- rnorm(100)
>> latest.ob <- x
>> ## how do I mark the bucket that latest.ob falls into?
> Something like this:
> x <- rnorm(100)
> (latest.ob <- x)
> h <- hist(x)
> bin <- as.numeric(cut(latest.ob, h$breaks)) # need as.numeric for bin+1
> lw <- h$breaks[bin]
> up <- h$breaks[bin+1]
> sz <- h$counts[bin]
> O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
> c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help