[R] sum(is.na(c(...)) -> negative number; bug or feature?
Barnet Wagman
wagman at enteract.com
Mon May 24 19:15:41 CEST 1999
As I understand it, sum() treats a logical vectors as 1's and 0's, so
that
> is.logical(c(FALSE,TRUE,FALSE))
[1] TRUE
> sum(c(FALSE,TRUE,FALSE))
[1] 1
However, summing the results of an is.na() yields a
negative number. Eg
> is.na(c(1,NA,3))
[1] FALSE TRUE FALSE
> is.logical(is.na(c(1,NA,3)))
[1] TRUE
> sum(is.na(c(1,NA,3)))
[1] -1
(This is from R Version 0.64.0, under Redhat Linux 5.2 (compiled from
scratch
using egcs-g77-1.0.3a-14, although I can't imagine that's relevant).
Is this a bug, or is there something about sum() that I'm missing?
Thanks
--------------------
Barnet Wagman
wagman at enteract.com
773-645-8369
1361 N. Hoyne
Chicago, IL 60622
---------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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