Hi there, I am analyzing some data at the dyadic level. There are multiple matched dyads of actors and partners, how can I create unique identifiers (IDs) for each actor, partner, and dyad?
the raw data goes like this:
I would like to add three ID columns to represent actors, partners, and their dyads. There are a few requirements:
1. each actor and partner should have a unique ID.
2. the actor_ID should be corresponding to the partner_ID. for example, when "Adam" is the actor, he is assigned with "1" in the actor_ID, thus, in the partner_ID, the "partner" "Adam" should be also assigned "1". The example of this requirement is in red in the following table.
3. each dyad should have a unique ID. This may be the hardest part. For example, the dyad_ID should be "1" for both the combinations of [ Adam" (the actor) and "Raddi" (the partner) ] and [ "Raddi" (the actor) and "Adam" (the partner) ]. The example of this requirement is in blue in the following table.
The ideal new table is as below, does anyone can help me?
the raw data goes like this:
teamID | actorName | partnerName |
1 | Adam | Raddi |
1 | Adam | Samatha |
1 | Adam | JoJo |
1 | Raddi | Adam |
1 | Raddi | Samatha |
1 | Raddi | JoJo |
1 | Samatha | Adam |
1 | Samatha | Raddi |
1 | Samatha | JoJo |
1 | JoJo | Adam |
1 | JoJo | Raddi |
1 | JoJo | Samatha |
2 | Nix | Kim |
2 | Nix | Susan |
2 | Kim | Nix |
2 | Kim | Susan |
2 | Susan | Nix |
2 | Susan | Kim |
I would like to add three ID columns to represent actors, partners, and their dyads. There are a few requirements:
1. each actor and partner should have a unique ID.
2. the actor_ID should be corresponding to the partner_ID. for example, when "Adam" is the actor, he is assigned with "1" in the actor_ID, thus, in the partner_ID, the "partner" "Adam" should be also assigned "1". The example of this requirement is in red in the following table.
3. each dyad should have a unique ID. This may be the hardest part. For example, the dyad_ID should be "1" for both the combinations of [ Adam" (the actor) and "Raddi" (the partner) ] and [ "Raddi" (the actor) and "Adam" (the partner) ]. The example of this requirement is in blue in the following table.
The ideal new table is as below, does anyone can help me?
teamID | actorName | partnerName | actor_ID | partner_ID | dyad_ID |
1 | Adam | Raddi | 1 | 2 | 1 |
1 | Adam | Samatha | 1 | 3 | 2 |
1 | Adam | JoJo | 1 | 4 | 3 |
1 | Raddi | Adam | 2 | 1 | 1 |
1 | Raddi | Samatha | 2 | 3 | 4 |
1 | Raddi | JoJo | 2 | 4 | 5 |
1 | Samatha | Adam | 3 | 1 | 2 |
1 | Samatha | Raddi | 3 | 2 | 4 |
1 | Samatha | JoJo | 3 | 4 | 6 |
1 | JoJo | Adam | 4 | 1 | 3 |
1 | JoJo | Raddi | 4 | 2 | 5 |
1 | JoJo | Samatha | 4 | 3 | 6 |
2 | Nix | Kim | 5 | 6 | 7 |
2 | Nix | Susan | 5 | 7 | 8 |
2 | Kim | Nix | 6 | 5 | 7 |
2 | Kim | Susan | 6 | 7 | 9 |
2 | Susan | Nix | 7 | 5 | 8 |
2 | Susan | Kim | 7 | 6 | 9 |
Comment