I have a dataset contains 3 different vars like this:
id gender phase
a1 m 1
a1 m 2
a1 m 3
b2 m 1
b2 f 2
b2 m 3
c3 f 1
c3 f 2
c3 f 3
...
Notice that for id==b2, phase==2, the gender is accidentally marked as "f", it should be consistent with other phases as gender=="m" because the gender cannot be changed during the study phases.So if I want to run a R code to detect which ids have such issue, how should I accomplish that goal? Thanks a lot~~