2021年1月20日星期三

R: Error in if ... { : missing value where TRUE/FALSE needed

I am trying to run the following if statement where the two if statement will display "Y" otherwise return "N". However I am getting the following error: Error in if (data.joined$actual goods issue date[i] > data.joined$target date[i]) { : missing value where TRUE/FALSE needed

for(i in 1:nrow(data.joined)){    if(data.joined$`actual goods issue date`[i] > data.joined$`target date`[i]) {      data.joined$late.delivery.test[i] <- "Y"    } else if(is.na(data.joined$`actual goods issue date`[i]) == TRUE && today() > data.joined$`target date`[i]) {      data.joined$late.delivery.test[i] <- "Y"    } else {      data.joined$late.delivery.test[i] <- "N"    }  }  
https://stackoverflow.com/questions/65819506/r-error-in-if-missing-value-where-true-false-needed January 21, 2021 at 08:17AM

没有评论:

发表评论