I am getting frustrated because my simple for loop does not work for reasons I cant understand, My data looks like this,
PERSON_ID EVENT
58 10000002174 C569
64 10000002207 C569
66 10000002210 C569
91 10000002676 C569
111 10000006286 C569
113 10000006288 C569
117 10000006293 C569
180 10000010009 C569
183 10000010011 C569
184 10000010011 C569
I want to change C569 to C5692 if one person has more than one C569.
PERSON_ID EVENT
58 10000002174 C569
64 10000002207 C569
66 10000002210 C569
91 10000002676 C569
111 10000006286 C569
113 10000006288 C569
117 10000006293 C569
180 10000010009 C569
183 10000010011 C569
184 10000010011 C5692
so result should look like this
for (i in 1:nrow(OV)){
if (OV[i,1] == OV[(i+1),1]){ OV[(i+1),2] <- "C5692"}
}
but this gives me error
Error in if (OV[i, 1] == OV[(i + 1), 1]) { :
missing value where TRUE/FALSE needed
could anybody enlighten me? thank you very much