Code twin categories

Hi,
I have a beginner question about coding twin data. Lets say that my dataset has the following categorise:
MZ
DZ, same-sex
unknown
DZ, opposite-sex

How do I (in the easiest way) code them into neat categories such as the ones we have worked with:
MZf
DZf
Mzm
DZm
DZo

All the best

Hi @anonymous9 . So, you’ll want to define based on Sex and Zygosity. I like to do use math to code this. Assuming that zygosity is coded as 1 = MZ and 2 = DZ. Also, that sex is coded as 3 = Male and 4 = Female.

MATH HELPS CODING ZYGOSITY

1*3 = 3 = MZM (1)

1*4 = 4 = MZF (2)

2*3 = 6 = DZM (3)

2*4 = 8 = DZF (4)

3*3 = 9 = ODZ (5)

TwinData $zygroup5a ← TwinData$sexZ * TwinData$zygocity

library(car)
TwinData$zygroup5 ← recode(FinnTwinZyg$zygroup5a, “0=NA; 3=1; 4=2; 6=3; 8=4; 9=5”)

Remember to check and ensure that in opposite sex pairs, the same sex person is always the first twin (i.e., all twin 1 members of ODZ pairs are male and all twin 2 members are female).