mksib: Generate variables (or lists) of siblings from a file of ids...

Description Usage Arguments Details Value Author(s) Examples

View source: R/mksib.R

Description

The function generates for each person lists of maternal half-sibs, paternal half-sibs and full sibs. Optionally these are expanded to separate columns in a data.table.

Usage

1
mksib(obj, ns = 3, expand.vars = TRUE)

Arguments

obj

A 3-column structure with column names id, pid (paternal id) and mid (maternal id).

ns

Integer. The maximal no of sibs of each type to include in the result if sibling ids are required in separate columns.

expand.vars

Logical. Should the sibling ids be returned in separate columns. If FALSE they will be returned i three columns of lists.

Details

There are no checks of persons being both mother and father, nor being its own parent and incest checks are not performed. In other words, the obj is assumed to be sane, but possibly immoral.

Value

A data.table with the columns of the obj and columns for ns maternal, paternal and full sibs, named ms1, ms2, ... ps1, ps2, ... fs1, fs2.

If expand.vars=FALSE there will instead be three columns of lists named msibs, psibs and fsibs.

Author(s)

Claus Thorn Ekstrøm, ekstrom@sund.ku.dk, Bendix Carstensen, b@bxc.dk

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library( data.table )
id <- 1:12
pid <- c(NA,  1, 1, 1, NA, 23, 45, 5, 5, 7, 12, NA)
mid <- c(NA, NA, 2, 2, 12, NA, 46, 6, 6, 6, NA, 12)
indd <- data.table( id, mid, pid )
indata <- copy( indd )
indata

str( xx <- mksib( indata ) )
xx

zz <- mksib( indata, 2, e=FALSE )
zz

ekstroem/networkR documentation built on July 25, 2020, 8:30 a.m.