For an analysis of data from twins, I'd like to do some rearranging in my
dataframe. Currently, each twin has his or her own row. I'd like to add
several columns of the co-twin's data to each row. In other words, this is
the current situation:

FamilyID  ParticipantID  IQ  Digit_span
1             1          95  6
1             2          93  7
2             3          102 8
2             4          101 9
3             5          106 7
3             6          108 9

And this is what I'd like to have, only with even more co-twin data:

FamilyID  ParticipantID  IQ  Digit_span Co-twin_IQ Co-twin_Digit_span
1             1          95  6          93          7
1             2          93  7          95          6
2             3          102 8          101         9
2             4          101 9          102         8
3             5          106 7          108         9
3             6          108 9          106         7

I'm not sure how to tell R to take the specified values from the other row
with the same family ID and append them with a new name. Thanks for any
ideas you can offer me.

Jamie in Illinois

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to