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

ggrothendieck@yifan.net ggrothendieck at yifan.net
Sat Mar 30 20:53:46 CET 2002



I found a strange inconsistency:

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.

Even after you have figured it out, its pretty hard to remember.

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