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

About this list Date view Thread view Subject view Author view Attachment view

From: Achim Zeileis (zeileis@ci.tuwien.ac.at)
Date: Wed 15 May 2002 - 03:44:31 EST


Message-id: <3CE14CFF.FB62CEE7@ci.tuwien.ac.at>


"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@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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 16 Oct 2002 - 11:57:16 EST