[Rd] NA in character vectors
Fri, 15 Mar 2002 17:30:20 -0500
While R-1.5.0 is still unfrozen, I'd like to try again to generate interest in
my favorite pet peeve: NA's in character vectors. Last October I wrote:
> LETTERS[c(NA,2)] in S is c("","B"), but in R is c("NA","B").
We had an interesting discussion then, and I learned (from Duncan Murdoch and
Thomas Lumley) that R does have an internal code for missing char values
(R_NaString), but it gets easily confused with the string "NA". Check this:
R> z <- c(LETTERS[c(2,NA)], "NA", paste("NA"))
 FALSE TRUE TRUE FALSE
 FALSE TRUE TRUE TRUE
Thomas Lumley <firstname.lastname@example.org> suggested that this weird behavior
essentially arises because the parser converts "NA" to R_NaString, and so...
> It looks like we basically need to
> 1) stop the parser generating R_NaString from \"NA\"
> 2) Change PRINTNAME(R_NaString) to avoid ambiguity
While I still like the simple S-Plus model (""), Thomas's suggestions (with
PRINTNAME(R_NaString) = "<NA>" for example) would be OK too. Thanks for
-- David Brahm (email@example.com)
"I write this letter not to nag nor to whine, but to prod." - Lisa Simpson
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: firstname.lastname@example.org