odd result of length() with factor arguments with NA (PR#354)

rnassar@duke.edu rnassar@duke.edu
Wed, 1 Dec 1999 03:17:15 +0100 (MET)


The following looks odd to me, but it may well be that I'm doing
something I shouldn't:

x <- c(rep("a",5),NA,rep("b",7))
X <- as.factor(x)
length(X)
# [1] 13
length(X[X=="a"])  
# [1] 6              I expected 5
length(X[X=="b"])
# [1] 8              I expected 7 
length(X[is.na(X)])
# [1] 1              yes
length(X[X=="d"])  
# [1] 1              but there is no "d"

Thank you.

Rashid Nassar

--please do not edit the information below--

Version:
 platform = i586-unknown-linux
 arch = i586
 os = linux
 system = i586, linux
 status = 
 major = 0
 minor = 90.0
 year = 1999
 month = November
 day = 22
 language = R

Search Path:
 .GlobalEnv, Autoloads, package:base

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