I have longitudinal patient data in R. I would like to create the new_dummy variable just like I demonstrated in the table below. I would like the dummy_variable value to be 0 if the consultation_date variable is smaller than the registration_date variable and to be 1 if the consultation_date variable is bigger than the registration_date variable.
patid | consultation_date | registration_date | new_dummy |
---|---|---|---|
1 | 07/07/2016 | 07/07/2018 | 0 |
1 | 07/07/2019 | 07/07/2018 | 1 |
2 | 14/08/2016 | 07/09/2016 | 0 |
3 | 07/05/2015 | 19/02/2016 | 0 |
3 | 02/12/2016 | 19/02/2016 | 1 |