From 19b140cb5e72c1fa49d6bade4e449a61b4818579 Mon Sep 17 00:00:00 2001 From: Magnus Dehli Vigeland Date: Fri, 3 Jun 2022 11:31:04 +0200 Subject: [PATCH] In addChildren(), give better errors if wrong parental sex --- R/ped_modify.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/ped_modify.R b/R/ped_modify.R index 7d71735..e4388a6 100644 --- a/R/ped_modify.R +++ b/R/ped_modify.R @@ -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))