[R] boxplot statistics

Thomas Lumley tlumley at u.washington.edu
Tue Oct 4 18:11:59 CEST 2005


On Tue, 4 Oct 2005, Karin Lagesen wrote:
>
> First, how does boxplot determine the size of the box? And is the line
> inside the box the mean or the median (or something completely
> different?) And how does it determine how long out the whiskers should
> go?

Part of the problem is that there are lots of different definitions of the 
quartiles (quantile() has 9 of them). If the number of observations is one 
more than a multiple of 4 then all the definitions agree, otherwise they 
are slightly different.

For the case where the number of observations is one more than a multiple 
of 4 the line in the middle is the median, the ends of the box are the 
upper and lower quartiles, and the whiskers extend to the furthest point 
that is within 1.5 box lengths from the end of the box.

When the number of observations is not one more than a multiple of four 
this is all still true, but you have to be careful about which definition 
of "quartile" you mean, for which you can read either the book referenced on 
the help page, or the code.

 	-thomas




More information about the R-help mailing list