[R] outliers in boxplot

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri May 12 20:19:21 CEST 2000


Angelo Canty wrote:
> 
> Hi All,
> 
> I'm trying to draw a number of sidee-by-side boxplots with quite a
> large number of outliers.  The default in R is to plot these using
> the current value of par("pch").  I would like to plot them as
> horizontal lines of length k times the width of the boxes.  Essentially
> what I want is the equivalent of the S-Plus parameters
> outline=T, outwex=k
> which do not seem to exist in the R version of boxplot.
>
> Also the helpfile for boxplot says that graphical parameters can be
> passed but the pch parameter is ignored if supplied. Is this
> intentional?

You are right, outline=T and outwex=k does not exist. 
And not all grahical parameters can be passed (e.g. pch or lty).

To change "pch", try something like
  par(pch="*")
  boxplot(.)


If you want to plot outliers as lines, you should have a deeper look
into that method:
To produce the plot, bxp(.) is called by boxplot.default(.).
So you should modify that function.

Example:

   temp <- boxplot(c(1:5, 10))
   temp  
   ## necessary informations for bxp(.) 
   ## (e.g.  median, ..., outliers)
   my.bxp <- bxp  ## Make your own boxplot function
   fix(my.bxp)  ## modify it (described below)
   my.bxp(temp) ## and draw the plot :-)


In my.bxp(.) you have to change line 30:

   ## Replace:
   points(rep(x, length(out)), out, col = border) # draws outliers
   ## by something like:
   if (length(out) > 0) 
       segments(x - wid/2, out, x + wid/2, out, col = border)
   ## "wid" is length of the lines here.




Regards,
Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list