Re-Randomize Twin Order

Posted on
No user picture. Hal Joined: 09/10/2021
Is there a code to re-randomize twin order?

Thanks!

Replied on Fri, 07/29/2022 - 09:56
Picture of user. AdminNeale Joined: 03/01/2013

I haven't got any myself, but presumably, it's pretty straightforward to put twin 1 variables in one vector, twin 2 variables in another, and then call runif(1) to choose whether to flip the order, possibly using a dummy vector, dummy<-twin1; twin1<-twin2; twin2<-dummy. Or simply write them to a new dataset c(twin1,twin2) or c(twin2,twin1).
Replied on Fri, 07/29/2022 - 09:58
Picture of user. AdminRobK Joined: 01/24/2014

One thing to add: you need to be careful if you have opposite-sex dizygotic twins in your dataset, because the script you're using might assume that, say, twin 1 is always the male and twin 2 is always the female.