[R] bwplot: how not to draw outliers

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Mon Jan 17 21:51:10 CET 2005



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.

--sundar




More information about the R-help mailing list