[R] label outliers in boxplot and/or bwplot

Deepayan Sarkar deepayan at stat.wisc.edu
Sat Feb 12 04:43:13 CET 2005


On Friday 11 February 2005 21:20, John Fox wrote:
> Dear Christoph,
>
> (I don't believe that this question was answered; my apologies if it
> was.)
>
> > -----Original Message-----
> > From: r-help-bounces at stat.math.ethz.ch
> > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> > Christoph Lehmann
> > Sent: Friday, February 11, 2005 8:44 AM
> > To: r-help at stat.math.ethz.ch
> > Subject: [R] label outliers in boxplot and/or bwplot
> >
> > Hi
> >
> > Is there a way to lable (e.g. observation-number) the
> > outliers in a boxplot?
>
> You can use identify() with horizontal coordinates at 1 (and at
> successive integers for parallel boxplots); e.g.,
>
> x <- c(rnorm(98), 8, 10)
> boxplot(x)
> identify(rep(1, 100), x)
>
> > and in a bwplot?
>
> Not to my knowledge.

Actually, it turns out that the obvious analog works with bwplot too 
(though it's a bit weird that you can 'identify' points that are not 
actually plotted). See below.

> I hope this helps.
>  John
>
> > thanks a lot
> >
> > Christoph
> >
> >
> > P.S. identify() is not available with bwplot, is it?

There's panel.identify(). You could use it as part of your panel 
function, but in this case it might be more natural to do it after the 
fact, as in:

bwplot(x)
trellis.focus("panel", 1, 1)
panel.identify()
trellis.unfocus()

This has the added advantage that you don't have to specify 'x' and 'y' 
explicitly, they're taken from the corresponding panel data.

Deepayan




More information about the R-help mailing list