[Rd] 1.4.0: mean/sum of logicals
Torsten Hothorn
Torsten.Hothorn@rzmail.uni-erlangen.de
Fri, 5 Oct 2001 13:20:54 +0200 (MEST)
the NEWS file in 1.4.0-devel states:
o mean() has `data frame' method applying mean column-by-column.
When applied to non-numeric data mean() now returns NA rather
than a confusing error message (for compatibility with S4).
which means:
R> mean(c(TRUE, FALSE))
[1] NA
Warning message:
argument is not numeric: returning NA in: mean.default(c(TRUE, FALSE))
but:
R> sum(c(TRUE, FALSE))
[1] 1
?sum states:
sum(..., na.rm=FALSE)
Arguments:
...: numeric vectors.
and clearly
R> is.numeric(c(TRUE, FALSE))
[1] FALSE
this is confusing, isn't it? I think that `sum' and `mean' should take the
same arguments (and one probably will not allow to sum up logicals) or am
I missing something?
Torsten
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._