[R] Wrong Q3 + Mean.
Joshua Wiley
jwiley.psych at gmail.com
Wed May 16 10:42:27 CEST 2012
On Wed, May 16, 2012 at 12:22 AM, Retep32 <retepdeluxe at web.de> wrote:
> Hi.
>
>> a
> [1] 13 13 14 14 15 15 16 20 21 26
>> summary(a)
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> 13.0 14.0 15.0 16.7 19.0 26.0
>> mean(a)
> [1] 16.7
>> quantile(a)
> 0% 25% 50% 75% 100%
> 13 14 15 19 26
>
> Clearly, this is not right. My Instructor and I have no idea why the program
Really? It is not at all clear to me what makes this "not right".
Have you tried looking at the documentation for quantile? (which you
can access by typing ?quantile or help("quantile") ) There are
multiple algorithms to calculate quantiles which in practice often
yield quite similar results, but, particularly for very small datasets
such as are common for class exercises, and a few other cases do
behave rather differently. You can caompare the 9 varieties by
running this:
sapply(1:9, function(i) quantile(a, type = i))
which for me yields:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
0% 13 13 13 13.0 13 13.00 13 13.00000 13.0000
25% 14 14 13 13.5 14 13.75 14 13.91667 13.9375
50% 15 15 15 15.0 15 15.00 15 15.00000 15.0000
75% 20 20 20 18.0 20 20.25 19 20.08333 20.0625
100% 26 26 26 26.0 26 26.00 26 26.00000 26.0000
Perhaps one of those is what you are looking for (rows are quantiles,
each column uses a different algorithm, types 1 through 9,
respectively).
Hope this helps,
Josh
> does that. I removed the program from the computer , installed it again and
> it still shows the mistake. It is also strange, that I chose "english" as
> installlanguage, but the program is in german (my OS is in german).
>
> Pls help, because otherwise i cannot solve any problems with R.
>
> Using Win7 and R version 2.15.0 (2012-03-30).
>
> Retep
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Wrong-Q3-Mean-tp4630223.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/
More information about the R-help
mailing list