I have a data frame like the one shown below. Each pair of ID numbers (e.g. 2891, 2892) corresponds to pair of twins.
ID zyg.x CDsum
1 2891 2 0
2 2892 2 5
3 4000 1 0
4 4001 1 0
5 4006 2 0
6 4007 2 3
I would like to reshape this data frame to make it look like this... Note that the zyg.x (zygosity) value is the same for each twin in the pair.
Twin Pair zyg CDsumTwin1 CDsumTwin2
1 pair1(2891,2892) 2 0 5
2 pair2(4000,4001) 1 0 0
3 pair3(4006,4007) 2 0 3
Any help would be much appreciated.