IDch | R Documentation |
Retrieves IDs of children of ego(s).
IDch(idego, d = NULL, keep_ego = FALSE)
idego |
ID of ego(s). If the vector idego includes missing elements (NA), they are removed. |
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 |
Logical variable. If TRUE, a dataframe of parent-child and father-child dyads is produced. It includes, for each ego (parent), ego's ID and the IDs of ego's children. |
Two cases:
keep_ego=FALSE: IDch() returns the IDs of children. If ego has no children or IDs of children are not included in database, the missing data symbol NA is returned. The vector idego may include the IDs of egos who form a couple. In that case, the IDs of their children are included only once to prevent double-counting.
keep_ego=TRUE: IDch() returns a dataframe of parent-child dyads. If idego includes the IDs of egos who form a couple, then the IDs of their children are included twice, in the mother-child dyads and in the father-child dyads. To select the father-child dyads, select the male egos. The dataframe of parent-child dyads include childless females and males. The dyad has the ID of the female(male) and NA instead of the ID of the child. The object returned has the following columns:
ID of ego (parent of child)
ID of child
# Load the data
data(dLH,package=("Families"))
IDch(idego=1)
set.seed(43)
id <- sample (dLH$ID[dLH$gen==1],10)
id2 <- IDch(idego=sort(id),keep_ego=TRUE)
id3 <- IDch(id2$idch,keep_ego=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.