I have a code like that in R
for (index in c(1:nrow(my_data) - 2)){
if (!is.na(my_data[index, 1]) && !is.na(my_data[index + 1, 1]) && !is.na(my_data[index + 2, 1])) {
print("yes")
}
}
but I have the error
Error in if (!is.na(my_data[index, 1]) && !is.na(my_data[index + 1, 1]) && :
missing value where TRUE/FALSE needed
What's wrong with this code?