[R] NA vs. <NA>

hadley wickham h.wickham at gmail.com
Fri Apr 4 18:09:53 CEST 2008


On Fri, Apr 4, 2008 at 11:00 AM, Muenchen, Robert A (Bob)
<muenchen at utk.edu> wrote:
> Dear R-Helpers,
>
>  Why does R show character missing values in vectors as NA and when
>  stored in a data frame as <NA>? I've searched but did not find an
>  explanation.

It's because that character vector is automatically coerced into a factor:

> factor(gender)
[1] f    f    f    <NA> m    m    m    m
Levels: f m

I'd imagine the display is different so you can tell the difference
between NA and level "NA".
(This isn't a problem for strings because they have quotes around them)

Hadley


-- 
http://had.co.nz/



More information about the R-help mailing list