[Rd] NA handling in as.character applied to a list

Michael Toews mwtoews at sfu.ca
Thu Oct 26 03:54:10 CEST 2006


Also, Splus 7 has a different behaviour from R:
 > sapply(v, is.na)
 a b c
 F T T
 > sapply(as.character(v), is.na)
[1] F F F
 > as.character(v)
[1] "\"NA\"" "NA"     "NA"

In R, it remains logical: if it isn't in character mode, then 
as.character always turns NA's into "NA"'s. If that behaviour is not 
desired, and you want to keep character NA's as true NA's, then you can 
test from the original object.

I agree that is dangerous to change the behaviour of simple things like 
this, and don't recommend any change in behaviour. However, this isn't 
documented, so here is my suggested patch for ?as.character . (Edit this 
as necessary).
+mt



More information about the R-devel mailing list