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

About this list Date view Thread view Subject view Author view Other groups

Subject: odd result of length() with factor arguments with NA (PR#354)
rnassar@duke.edu
Date: Wed 01 Dec 1999 - 12:17:15 EST


Message-Id: <199912010217.DAA03249@pubhealth.ku.dk>

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


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:11 EST