I have a data frame with a variable listing dates when event X took place for each individual. That date represents the first day of an event which can last up to a certain number of days. I have another variable Z, which is also a date. I want to see if date Z crosses over with date X + the potential range and create a New Variable listing "Cross_Over" and "No_Cross_Over".
The below appears to work but is very laborious. Is there a quicker way to do this?
df$NewVar <- ifelse(df$X == d1$Z | df$X == df$Z -2 | df$X == df$Z -1| df$X == df$Z +1| df$X == df$Z +2, "Cross_OVer", "No_Cross_Over")