Actually, the answer above is incorrect. It produces the error Error in if (test$year == 2019) { : the condition has length > 1
and if one uses ifelse then the error is Error in ifelse(test$year == 2018) : argument "yes" is missing, with no default
Can anyone clarify?