lwjohnst86 / famnet

Characterizing a Family Network
Other
0 stars 0 forks source link

Function to determine grandparents #3

Open lwjohnst86 opened 6 years ago

omarsilverman commented 6 years ago

To identify any other family relation (different from siblings) is necessary to use the left join function. We have to create one data table renaming the original id-fid-mid with grandparent, uncles, etc labels.

Pgp <- DT1[,c("id","fid","mid")]
names(Pgp) <- c("fid","Fgp","Fgm")

#left join
DT2 <- Pgp[DT1, on="fid"]

#Maternal Grandparents 
Mgp <- DT1[,c("id","fid","mid")]
names(Mgp) <- c("mid","Mgp","Mgm")

DT3 <- Mgp[DT1, on="mid"]