[R] Inconsistency among mean, median, max, var

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Sat Mar 30 21:25:02 CET 2002


On Sat, 30 Mar 2002 ggrothendieck at yifan.net wrote:

> I found a strange inconsistency:

Well, these do work as documented, and I don't find it even ordinarily
inconsistent.

> If m is a matrix and d is a data frame then
>
> - mean(m), median(m), max(m) and max(d) all return a single value
>
> but
>
> - mean(d) returns the column means
> - median(d) fails
> - both var(m) and var(d)  return the variance covariance matrix
>
> You pretty much have to experiment to figure this out since much of this
> behavior is not readily obvious from the help files.

I don't think that is even 1% fair:

?mean clearly says what it does for a data frame.
?median clearly says it only works for numeric vectors.
?var clearly says that it works for `a numeric vector, matrix or data
frame'

Whatever is the problem with that?

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