Hello,
I am trying to reformat a dataset that includes information on individuals' contacts know each other. My challenge is that most of the information I have found on this listserve about reshaping adjacency matrices relates to sociocentric data, where all of the individuals and all of their contacts are in one network. Here, I have egocentric data, so each person essentially has their own adjacency matrix. Currently, the data look like this:
ID refers to respondents, alter refers to contacts that they name, and know* refers to whether the alter in that row knows the alter that corresponds to the know variable suffix (row 1, column 3: Does alter 1 know alter 2?). Of note, alter 1 for respondent 7000 is a different person from alter 1 of respondent 7001; those alters are just the contacts listed first by the two respondents.
I am trying to create row-wise format that would look something like this:
Here, the From and To columns refer to alters. The prefix of the value refers to the respondent and the suffix after the underscore refers to the alter number from the first table (7000_1 is respondent 7000's first alter).
The second table is in "long" format, but so is the first, so I can't quite figure out what I'd have to do to reshape this.
Any help would be tremendously appreciated.
Thanks you!
Robbie Dembo
I am trying to reformat a dataset that includes information on individuals' contacts know each other. My challenge is that most of the information I have found on this listserve about reshaping adjacency matrices relates to sociocentric data, where all of the individuals and all of their contacts are in one network. Here, I have egocentric data, so each person essentially has their own adjacency matrix. Currently, the data look like this:
ID | Alter | Know2 | Know2 | Know4 |
7000 | 1 | No | No | No |
7000 | 2 | . | No | No |
7000 | 3 | . | . | No |
7000 | 4 | . | . | . |
7001 | 1 | Yes | . | . |
7001 | 2 | . | . | . |
I am trying to create row-wise format that would look something like this:
ID | From | To | Know |
7000 | 7000_1 | 7000_2 | No |
7000 | 7000_1 | 7000_3 | No |
7000 | 7000_1 | 7000_4 | No |
7000 | 7000_2 | 7000_3 | No |
7000 | 7000_2 | 7000_4 | No |
7000 | 7000_3 | 7000_4 | No |
7001 | 7001_1 | 7001_2 | Yes |
The second table is in "long" format, but so is the first, so I can't quite figure out what I'd have to do to reshape this.
Any help would be tremendously appreciated.
Thanks you!
Robbie Dembo
Comment