[R] bwplot: how not to draw outliers
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Mon Jan 17 22:14:06 CET 2005
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.
>
> --sundar
You may also want to try
library(Hmisc)
library(lattice)
bwplot(..., panel=panel.bpplot)
?panel.bpplot
--
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help
mailing list