[R] Error Missing values where true/false needed

Boris Steipe boris.steipe at utoronto.ca
Wed Nov 26 08:26:03 CET 2014

On Nov 26, 2014, at 1:27 AM, Frederic Ntirenganya <ntfredo at gmail.com> wrote:

> The error seems to be starnge to me because i access the indices of NAs.

No you don't. You access the contents of the cell via an index for which you have previously determined that the contents is NA. Then you compare that contents with 60.

The error is in the logic of these steps:
>> indicNAs <- which(data$Rain %in% NA)    # indices for NA
>>   for (i_NA in indicNAs ){              # i_NA is one of these indices
>>     if(data$Rain[i_NA] == 60){          # data$Rain[i_NA] contains ... NA ! Never 60.


More information about the R-help mailing list