[R] NA values in indexing
b.rowlingson at lancaster.ac.uk
Fri Mar 26 18:00:07 CET 2010
On Fri, Mar 26, 2010 at 4:15 PM, Matthew Dowle <mdowle at mdowle.plus.com> wrote:
> The type of 'NA' is logical. So x[NA] behaves more like x[TRUE] i.e. silent
>  "logical"
>  NA NA NA NA NA NA NA NA
>  101 NA 103 NA 105 NA 107 NA
>  NA
Ouch. What is happening is that a numeric vector containing NA has
become a logical vector of all NA because "‘NA’ is a logical constant
of length 1" [?NA]
Obviously R doesn't know that my c(NA,NA) came from c(4,NA,NA) and
not c(TRUE,NA,NA). And it prints them the same:
Oh well, one to remember. I've got an urge to go eat a baNANA now.
More information about the R-help