Re: [R] NA vs. <NA>

From: hadley wickham <h.wickham_at_gmail.com>
Date: Fri, 04 Apr 2008 11:09:53 -0500

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/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 04 Apr 2008 - 16:12:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Apr 2008 - 17:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive