[R] Error Missing values where true/false needed
Frederic Ntirenganya
ntfredo at gmail.com
Wed Nov 26 07:27:24 CET 2014
Hi PIKAL,
The error seems to be starnge to me because i access the indices of NAs.
Indices can't be non-applicable.
This is the output of indecs having the NA in my dataset. my dataset is
very big that's why I did not provide it.
> indicNAs <- which(data$Rain %in% NA)
> indicNAs
[1] 426 792 1158 1890 2256 2622 3354 3720 4086 4818 5184
5550 6282 6648 7014 7746 8112
[18] 8478 9210 9576 9942 10674 11040 11406 12138 12504 12870 13602
13968 14334 15066 15432 15798 16530
[35] 16896 17262 17994 18360 18726 19458 19824 20190
Regards,
Frederic.
Frederic Ntirenganya
Maseno University,
African Maths Initiative,
Kenya.
Mobile:(+254)718492836
Email: fredo at aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/
On Tue, Nov 25, 2014 at 3:51 PM, Michael Dewey <info at aghmed.fsnet.co.uk>
wrote:
> You do not tell us what you are trying to do but I think there is
> something wrong in the logic of your thinking as on the one hand you are
> selecting just precisely those elements of data$Rain which are NA and then
> testing whether any of them equals 60.
>
>
>
> On 25/11/2014 12:19, Frederic Ntirenganya wrote:
>
>> Dear All,
>>
>> I am getting this error and don't know why it comes. can you please help ?
>>
>> Error in if (data$Rain[i_NA] == 60) { :
>> missing value where TRUE/FALSE needed
>>
>> The loop is :
>>
>> indicNAs <- which(data$Rain %in% NA)
>> ind_nonleap = c() # NAs due to non leap years
>> ind_nonrecord = c() # NAs due to non recording values
>> for (i_NA in indicNAs ){
>> if(data$Rain[i_NA] == 60){
>> ind_nonleap <- append(ind_nonleap,i_NA)
>> }
>> else {
>> ind_nonrecord<-append(ind_nonrecord,i_NA)
>> }
>> #cat(ind_nonrecord)
>> #cat( ind_nonleap)
>> }
>> ind_nonleap
>>
>> Regards,
>> Frederic.
>>
>> Frederic Ntirenganya
>> Maseno University,
>> African Maths Initiative,
>> Kenya.
>> Mobile:(+254)718492836
>> Email: fredo at aims.ac.za
>> https://sites.google.com/a/aims.ac.za/fredo/
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>>
>> -----
>> No virus found in this message.
>> Checked by AVG - www.avg.com
>> Version: 2015.0.5577 / Virus Database: 4223/8627 - Release Date: 11/25/14
>>
>>
>>
> --
> Michael
> http://www.dewey.myzen.co.uk
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list