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"
}
}
data.joinedis a dataframe, you don't need a for loop because R vectorises by default. You probably want to use something likedplyr::case_when(). - Phildata.joined$`actual goods issue date`[i]anddata.jointed$`target_date`[i]. What do you get? - Izzy