I want to create a binary variable of 0 or 1, based on if one date variable is larger than another. Here is some example data
diagnosis_date1 diagnosis_date2
30-01-2018 12-05-2016
14-02-2013 06-07-2020
01-02-2009 21-11-2008
09-06-2012 16-10-2014
with the goal of then having a variable that indicates 1 if diagnosis_date1 is larger than date2 and 0 if the date is less than
diagnosis_date1 diagnosis_date2 condition
30-01-2018 12-05-2016 1
14-02-2013 06-07-2020 0
01-02-2009 21-11-2008 1
09-06-2012 16-10-2014 0
I have tried the following but it just produces all NAs, even though I am sure it worked in another dataset previously for something similar.
df$condition<- ifelse(df$diagnosis_date1 < df$diagnosis_date2, 1, 0)
Any help much appreciated :)