[R] quantile() and boxplot.stats()

Achim Zeileis zeileis at ci.tuwien.ac.at
Tue May 14 19:44:31 CEST 2002


"Vladimir N. Kutinsky" wrote:
> 
> Hello,
> 
> I faced something I can't understand. When I use boxplot.stats(1:10) and
> quantiles(1:10) the results are different for 25% and 75%:
> 
> > boxplot.stats(1:10)
> $stats
> [1]  1.0  3.0  5.5  8.0 10.0
> 
> > quantile(1:10)
>    0%   25%   50%   75%  100%
>  1.00  3.25  5.50  7.75 10.00
> 
> Actually, I expected the value 3 for 25% and 8 for 75% as results of
> quantile(1:10). Can you please explain me why it isn't so.

The two ``hinges'' in boxplots are defined differently. They are
versions of the first and third quartile, but they are identical only
for odd n. This is explained in help(boxplot.stats)

Details:

     The two ``hinges'' are versions of the first first and third
     quartile, i.e. close to `quantile(x, c(1,3)/4)'.  The hinges equal
     the quartiles for odd n (where `n <- length(x)') and differ for
     even n. Where the quartiles only equal observations for `n %% 4 ==
     1' (n = 1 mod 4), the hinges do so additionally for `n %% 4 == 2'
     (n = 2 mod 4), and are in the middle of two observations
     otherwise.


> Regards,
> Vlad
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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