In makeTwins(), usedID <- c(usedID, ID_twin1) runs before ID_twin1 is sampled, so usedID includes NA on the first iteration. That makes the filter !(ped$ID %in% usedID) evaluate to NA for all IDs (because %in% with NA yields NA), which can cause resample() to see NA candidates and fail or behave unpredictably. Only append ID_twin1 to usedID after it has a non-NA value (or drop NAs from usedID before using it in %in%).
Originally posted by @Copilot in #115
Originally posted by @Copilot in #115