[R] Bug in boxplot.stats?

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Sep 25 16:25:49 CEST 2001


It's just rounding errors.  60 is exactly 1.5x the IQR from 78.
Look at the whole output:

$stats
[1]  60  78  80  90 100

$n
[1] 18

$conf
[1] 75.53109 84.46891

$out
[1]  50 120  39 140

vs

$stats
[1]  7.8  7.8  8.0  9.0 10.0

$n
[1] 18

$conf
[1] 7.553109 8.446891

$out
[1]  5.0 12.0  6.0  3.9 14.0

Given that a point is sitting exactly on the boundary, it's arbitrary
whether it gets put inside or outside, and decided by rounding errors.



On Tue, 25 Sep 2001, Trenkler, Dietrich wrote:

> Is this a bug?

No.

>
> >"xx" <- c(50, 79, 120, 78, 90, 100, 78, 80,
> + 90, 80, 60, 39, 90, 85, 140, 100, 80, 80)
> > boxplot.stats(xx)$stats
> [1]  60  78  80  90 100
> > boxplot.stats(0.1*xx)$stats
> [1]  7.8  7.8  8.0  9.0 10.0
>
> I suppose  the way the numbers in 0.1*xx are internally stored may
> cause this problem:
>
> > formatC(0.1*xx[2],format="f",digits=16)
> [1] "7.9000000000000004"
>
> Version:
>  platform = i386-pc-mingw32
>  arch = x86
>  os = Win32
>  system = x86, Win32
>  status =
>  major = 1
>  minor = 3.1
>  year = 2001
>  month = 08
>  day = 31
>  language = R
>
> Windows NT 4.0 (build 1381) Service Pack 6
>
>    --- D.Trenkler ---
>
> ****************************************************************************
> *****
>    Dr. Dietrich Trenkler        (dtrenkler at nts6.oec.uni-osnabrueck.de)
>    Statistik / Empirische Wirtschaftsforschung
>    Universitaet Osnabrueck
>    Rolandstrasse 8                                Phone: +49(0) 541-969-2753
>    D-49069 Osnabrueck                          Fax  : +49(0) 541-969-2744
>    GERMANY
> ****************************************************************************
> *****
>
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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