I have a data with three variables. Patient ID as ID, Visit as Visit, and a third variable as Var. I have two visits and I would like to subset the IDs:
- IDs that have missing value of Var in the Visit 2
- IDs had a value 2 for Var in the Visit 1 but 1 in the Visit 2 and vice versa
ID Visit Var
1 1 2
1 2 2
2 1 1
2 2 2
3 1 2
3 2 1
4 1 2
4 2 NA