[R] NA's in if statement

lindsayv@unbc.ca lindsayv at unbc.ca
Fri Feb 11 22:34:56 CET 2005


Hello,

I am having trouble dealing with NA values in if statements such as:
i<-1
for(i in 1:length(dat$wdir)){
if (dat$wspd[i]==0){
dat$wdir[i]<-0
}
}

I get the following error due to the presence of NS values in the data:
Error in if (dat$wspd[i] == 0) { : missing value where TRUE/FALSE needed

Sorry if this is an old question but I was unable to resolve this from the
info on na.action etc. or old archives.

Thank you for any suggestions,

Vera Lindsay




More information about the R-help mailing list