[R] Error Missing values where true/false needed

Michael Dewey info at aghmed.fsnet.co.uk
Tue Nov 25 13:51:18 CET 2014


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



More information about the R-help mailing list