Skip to content

Commit

Permalink
In addChildren(), give better errors if wrong parental sex
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusdv committed Jun 3, 2022
1 parent 5ea9c69 commit 19b140c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/ped_modify.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ addChildren = function(x, father = NULL, mother = NULL, nch = NULL, sex = 1, ids

if(!father_exists && !mother_exists)
stop2("At least one parent must be an existing pedigree member")

if(father_exists && getSex(x, father) == 2)
stop2("Assigned father is female: ", father)
if(mother_exists && getSex(x, mother) == 1)
stop2("Assigned mother is male: ", mother)

if(!is.null(ids) && length(ids) != nch)
stop2("Length of 'ids' must equal the number of children")
if(any(ids %in% labs))
Expand Down

0 comments on commit 19b140c

Please sign in to comment.