[R] bwplot: how not to draw outliers

Deepayan Sarkar deepayan at stat.wisc.edu
Mon Jan 17 22:12:36 CET 2005


On Monday 17 January 2005 14:51, Sundar Dorai-Raj wrote:
> RenE J.V. Bertin wrote:
> > Hello, and (somewhat belated) best wishes for 2005.
> >
> > Can one order not to draw outliers in bwplot, or at least exclude
> > them from the vertical axis scaling? If so, how (or what doc do I
> > need to consult)? The options that have this effect in boxplot() do
> > not appear to have any effect with bwplot (although outline=FALSE
> > in boxplot does *not* change the scaling).
> >
> > Thanks,
> > RenE Bertin
>
> RenE,
>
> There may be other solutions but you can do this using the prepanel
> option to set the ylim:
>
> library(lattice)
> set.seed(1)
> z <- data.frame(x = rt(100, 1), g = rep(letters[1:4], each = 25))
> bwplot(x ~ g, z,
>         prepanel = function(x, y) {
>           bp <- boxplot(split(y, x), plot = FALSE)
>           ylim <- range(bp$stats)
>           list(ylim = ylim)
>         })
>
> If you actually want to exclude the points (rather than just prevent
> outliers from affecting the scale), you will have to modify the
> panel.bwplot function in addition to using the above.

Right. panel.bwplot calls 

       stats <- boxplot.stats(y[x == xval], coef = coef)

I guess it should have a 'do.out' argument as well. A workaround 
(without changing the panel function) might be to use something like

bwplot(voice.part ~ height, data = singer, 
       par.settings = list(plot.symbol = list(col = "transparent")))

(neither of these would change the limits, of course)

-Deepayan




More information about the R-help mailing list