Learn R Programming

nprcgenekeepr (version 3.0.0)

checkParentAge: Check parent ages against a minimum age

Description

Ensure parents are sufficiently older than offspring

Usage

checkParentAge(
  sb,
  minSireAge = NULL,
  minDamAge = NULL,
  minParentAge = lifecycle::deprecated(),
  reportErrors = FALSE
)

Value

A dataframe containing rows for each animal where one or more parent was younger than the minimum breeding age (minSireAge or minDamAge, or the species floor when they are NULL) at the animal's birth. It contains all of the columns in the original sb dataframe, with exit converted to character and the rows reordered, plus the following added columns:

  1. sireBirth -- sire's birth date

  2. sireAge -- age of sire in years on the date indicated by birth.

  3. damBirth -- dam's birth date

  4. damAge -- age of dam in years on the date indicated by birth.

Arguments

sb

A dataframe containing a table of pedigree and demographic information. It needs the columns id, sire, dam, birth and exit; species is optional (see minSireAge). Without exit the function fails with an uninformative error.

minSireAge

numeric minimum age in years for a male to have sired an offspring. NULL (default) looks up the floor for each sire's species via getSpeciesMinBreedingAge (falling back to 2 years when the species is missing or unknown); a supplied value overrides that floor for all sires. The check is not performed for animals with missing birth dates.

minDamAge

numeric minimum age in years for a female to have borne an offspring. NULL (default) looks up the floor for each dam's species via getSpeciesMinBreedingAge (falling back to 2 years when the species is missing or unknown); a supplied value overrides that floor for all dams.

minParentAge

[Deprecated] Deprecated scalar minimum parent age. Supplying it sets both minSireAge and minDamAge; use those sex-specific parameters instead.

reportErrors

logical value. If TRUE, NULL is returned instead of stopping (or returning sb) when the input cannot be checked: the data frame has no rows, lacks id, sire or dam, or birth is not of class Date, POSIXct or character. It does not change the result for valid input.

Examples

Run this code
library(nprcgenekeepr)
qcPed <- nprcgenekeepr::qcPed
checkParentAge(qcPed, minSireAge = 2L, minDamAge = 2L)
checkParentAge(qcPed, minSireAge = 3L, minDamAge = 3L)
checkParentAge(qcPed, minSireAge = 5L, minDamAge = 5L)
checkParentAge(qcPed, minSireAge = 6L, minDamAge = 6L)
head(checkParentAge(qcPed, minSireAge = 10L, minDamAge = 10L))

Run the code above in your browser using DataLab