[R] help matching observations for social network data

Holly Shakya hollymaya at gmail.com
Wed Mar 21 05:14:52 CET 2012


Greetings R folks, 

I am stuck on a problem that I suspect can be solved somewhat easily. 

I have social network data stored in dyads as below, where the numbers representing ego and alter are identifiers, so that number 1 as an ego is the same person as number 1 as an alter etc. 


      ego alter
1      1     2
2      1     3
3      2     1
4      2     4
5      3     1
6      3     2
7      3     4
8      3     6
9      4     1
10   5     3
11    5     6
12    6     4

What I would like to do is to create new dyads which match up the ego with the alter's alters as below (preferably removing dyads in which ego and alter2 are the same):

     ego alter2
1      1     4
2      1     2
3      1     4
4      1     6
5      2     3
6      2     1
7      3     2
8      3     1
9      3     4
10    3     1
11    3     4
12    4     2
13    4     3
14    5     1
15    5     2
16    5     4
17    5     6
18    5     4
19    6     1


Any suggestions as to how to do this would be greatly appreciated. 

Holly


More information about the R-help mailing list