Stephen Lake <slake@hsph.harvard.edu> wrote:
> > vec <- letters[1:5]
> > vec[4] <- NA
> > vec
> [1] "a" "b" "c" "NA" "e"
> > is.na(vec)
> [1] F F F F F
But note this behavior:
S> vec[c(1,NA,3)]
[1] "a" "" "c"
suggesting that in S-Plus, "" is the analog of numeric NA. You could write:
S> vec <- letters[1:5]
S> vec[4] <- ""
S> vec
[1] "a" "b" "c" "" "e"
S> vec==""
[1] F F F T F
The string "NA" is certainly a bad choice, as it might represent the ticker for
Nabisco, the initials of Neil Armstrong, the symbol for Nitric Acid,... But
you might also think "" is a bad choice if "" is a valid value for your
variable.
Note the R developers went down a different path, and created a true "missing"
character element <NA> in R.
--
-- David Brahm (brahm@alum.mit.edu)
|