[R] <NA> to NA
Marc Schwartz
marc_schwartz at me.com
Mon Mar 31 20:44:56 CEST 2014
On Mar 31, 2014, at 1:29 PM, eliza botto <eliza_botto at hotmail.com> wrote:
> Dear useRs,
> Sorry for such a ridiculous question but i really need to know that what is the difference between <NA> and NA and how to convert <NA> to NA.
> Thankyou very much in advance
> Eliza
<NA> is the printed output that you would typically get when "NA" is an element in a factor:
> factor(NA)
[1] <NA>
> is.na(factor(NA))
[1] TRUE
> NA
[1] NA
> is.na(NA)
[1] TRUE
See ?factor for additional details.
It is, other than the displayed output, the same as a 'normal' NA, which is to say that the value is missing and otherwise undefined.
The behavior appears to evolve from the use of ?encodeString, which is called within print.factor:
> encodeString(NA)
[1] "<NA>"
> encodeString(NA, na.encode = FALSE)
[1] NA
The default for the 'na.encode' argument is TRUE, so you get the formatting of the NA as you observe for factors.
Regards,
Marc Schwartz
More information about the R-help
mailing list