I have a large data with 3 variables. Some observations have duplicates.
Example:
Name Code old_status new
Jose 11 1 1
Maria 22 0 0
Ben 11 1 1
Ben 44 0 1
Joey 11 1 1
Alex 11 1 1
Alex 33 0 1
Alex 44 0 1
Jhon 22 0 0
Jhon 33 0 0
I want to add a column called new where the results are binary, 0 and 1.
If the person has no duplicate, then the person retains its old_status. If the person has duplicates, the person's new status is 1, provided the code is 33 or 44 and that one of the old_status of the person is 1 (e.g. Alex), otherwise the status is 0 (e.g. Jhon). (See data)