Learn R Programming

nprcgenekeepr (version 1.0.5)

kinMatrix2LongForm: Reformats a kinship matrix into a long-format table.

Description

Part of Group Formation

Usage

kinMatrix2LongForm(kinMatrix, rm.dups = FALSE)

Arguments

kinMatrix

numerical matrix of pairwise kinship values. The row and column names correspond to animal IDs.

rm.dups

logical value indication whether or not reverse-order ID pairs be filtered out? (i.e., "ID1 ID2 kin_val" and "ID2 ID1 kin_val" will be collapsed into a single entry if rm.dups = TRUE)

Value

A dataframe with columns id1, id2, and kinship. This is the kinship data reformatted from a matrix, to a long-format table.

Examples

Run this code
# NOT RUN {
library(nprcgenekeepr)
ped <- nprcgenekeepr::lacy1989Ped
ped$gen <- findGeneration(ped$id, ped$sire, ped$dam)
kmat <- kinship(ped$id, ped$sire, ped$dam, ped$gen)
reformattedKmat <- kinMatrix2LongForm(kmat, rm.dups = FALSE)
nrow(reformattedKmat)
reformattedNoDupsKmat <- kinMatrix2LongForm(kmat, rm.dups = TRUE)
nrow(reformattedNoDupsKmat)
# }

Run the code above in your browser using DataLab