I have a data set that includes three variables, a person ID, a family ID, and a neighborhood ID. To help fix ideas, the structure of the data looks like this:
What I'd like to do is randomly pair each person with another person in their neighborhood who isn't also in their family. Any advice on how to proceed -- even if it's only enough to get me on the right track -- would be very much appreciated.
Code:
person_id family_id neigh_id 1 1 1 2 1 1 3 2 1 4 2 1 5 3 1 6 3 1 7 4 2 8 4 2 9 5 2 10 5 2 11 6 2 12 6 2
Comment