[R] inconsistent behavior of summary function
Uwe Ligges
ligges at statistik.tu-dortmund.de
Tue Oct 4 18:19:15 CEST 2011
On 04.10.2011 16:42, Jeanne M. Spicer wrote:
> I'm not sure how returning an incorrect result is ever a 'positive' feature but at least the documentation could more clearly warn users that this method behaves differently in these cases -- summary(rock[,1]) vs summary(rock[,1:2]) -- and that the method can and does return incorrect results without any warning messages.
What are you talking about? Probably it appeared prior in this thread?
Please always cite.
Anyway, I guess you werre looking for
summary(rock[,1, drop=FALSE])
rock[,1] is implified to a vector whle rock[,1:2] is still a matrix or
data.frame (and since this is not cited, I do not know).
> I would encourage anyone teaching introductory R to look at the 'epicalc' package. The re-vamped function 'summ' in that package returns correct results regardless - summ(rock), summ(rock$area). In addition, when you only ask for one column you not only get the correct results, you also get a bonus distribution plot.
>
> I'd would like all of our students to use R, but little things like this are huge stumbling blocks for them.
Then you told them about summary() before telling how to deal with data
structures correctly. And that is te m,ost important part in learning R.
I know from my courses that applied people do not like that, but I
always managed to convince them this is the most impoertant topic to
learn about R.
Best,
Uwe Ligges
> -jeanne
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list