creating pairs for network analysis
问题 From my dataset I'm trying to make pairs based on a ranking. my data looks like ID grp rank 1 grp1 1 1 grp2 1 1 grp3 2 2 grp1 1 2 grp2 2 2 grp2 2 2 grp2 2 2 grp3 2 2 grp1 3 The output I am aiming for is the following: for each ID if rank = 1 then grp in source and destination are the same = grp If rank is different from 1 then source = take grp from previous rank destination = take group from current rank If more then one group exist for the same ranking then an additional line needs to be