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

Seth Falcon sfalcon at fhcrc.org
Wed Oct 25 23:23:21 CEST 2006


Hi all,

In some circumstances, as.character applied to a list converts real
NA's into the string "NA".  Propagation of NAs is something R does
very well and unless there are good reasons for losing the NA, it
would improve the consistency w.r.t. NA handling for as.character to
behave differently.

Here's an example:

## Create a list with character, logical, and integer NA elements
v <- list(a=as.character(NA), b=NA, c=as.integer(NA))
sapply(v, is.na)

       a    b    c 
    TRUE TRUE TRUE 

sapply(as.character(v), is.na)

     <NA>    NA    NA 
     TRUE FALSE FALSE 

Thoughts?

+ seth

--
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org




More information about the R-devel mailing list