[R] inconsistent behavior of mean, median, var

From: Richard M. Heiberger <rmh_at_temple.edu>
Date: Mon 22 Jan 2007 - 02:52:30 GMT


> mean(c("-1","0", "1"))

[1] NA
Warning message:
argument is not numeric or logical: returning NA in: mean.default(c("-1", "0", "1"))
> median(c("-1","0", "1"))

Error in median.default(c("-1", "0", "1")) :

        need numeric data
> var(c("-1","0", "1"))

[1] 1
>

Is the above intentional behavior? mean and median of character data give a warning and error. var gives the result of coercing the argument to numeric.



R-help@stat.math.ethz.ch 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. Received on Mon Jan 22 13:57:56 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 22 Jan 2007 - 04:30:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.