Hi there, I am analyzing some data at the dyadic level, and would like to create some identifiers columns to represent the actors, the partners, and their dyads.
The raw data table goes like this:
I would like to have a table with the ID columns as the one below. there are some requirements for the ID columns.
1. Each actor or partner should have a unique ID.
2. The actor_ID should correspond with the partner_ID. For example, when Adam is the "actor", his actor_ID is "1", thus, when Adam becomes the "partner", his partner_ID should still be "1". This example is highlighted in red below. The example in red.
3. Each dyad should have a unique ID regardless of the order of actor and partner. That is, for the dyad of Adam and Raddi, the dyad_ID is "1" no matter (Adam is the actor and Raddi is the partner) or (Raddi is the actor and Adam is the partner). This example is highlighted in green.
Does anyone know how to generate these ID columns?
The raw data table 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 |
1. Each actor or partner should have a unique ID.
2. The actor_ID should correspond with the partner_ID. For example, when Adam is the "actor", his actor_ID is "1", thus, when Adam becomes the "partner", his partner_ID should still be "1". This example is highlighted in red below. The example in red.
3. Each dyad should have a unique ID regardless of the order of actor and partner. That is, for the dyad of Adam and Raddi, the dyad_ID is "1" no matter (Adam is the actor and Raddi is the partner) or (Raddi is the actor and Adam is the partner). This example is highlighted in green.
Does anyone know how to generate these ID columns?
teamID | actorName | partnerName | actor_ID | patner_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