IDgch: IDs of grandchildren of ego

View source: R/IDgch.R

IDgchR Documentation

IDs of grandchildren of ego

Description

Retrieves ID of grandchildren of ego or vector of egos

Usage

IDgch(idego, d = NULL, keep_ego = FALSE)

Arguments

idego

ID of ego(s)

d

Name of database. If d is missing, the dataset dLH in the global environment (R workspace) is used. If no dLH in the global environment, the database dLH distributed with the Families package is used.

keep_ego

If keep_ego=TRUE, parent-child-grandchild triads are shown.

Value

Two cases:

  • keep_ego=FALSE: The function IDgch() returns the IDs of grandchildren. If ego has no grandchildren or IDs of grandchildren are not included in database, the missing data symbol NA is returned.

  • keep_ego=TRUE: IDgch() returns a data frame of child-parent-grandparent triads. A triad consists of:

    • idego ID of grandparent (ego)

    • idch ID of child

    • idgch ID of grandchild

    • gp lineage: maternal grandfather, paternal grandmother, etc.

    • idMOM ID of mother of grandchild

    • idDAD ID of father of grandchild

Examples


# Load data
data(dLH,package="Families")
IDch(IDch(dLH$ID[dLH$sex=="Female" & dLH$gen==1]))[1]

set.seed(51)
id <- sample (dLH$ID[dLH$gen==1],10)
id2 <- IDgch(idego=sort(id),keep_ego=TRUE)


Families documentation built on May 29, 2024, 3:06 a.m.