# NOT RUN {
x = nuclearPed(father = "fa", mother = "mo", children = "ch")
stopifnot(all.equal(
getSex(x, named = TRUE),
c(fa = 1, mo = 2, ch = 1)
))
# Make child female
setSex(x, ids = "ch", sex = 2)
# Same, using a named vector
setSex(x, sex = c(ch = 2))
# Swapping sex is sometimes easier,
# since spouses are dealt with automatically
swapSex(x, ids = "fa")
# setting/getting sex in a pedlist
y = list(singleton(1, sex = 2), singleton(2), singleton(3))
sx = getSex(y, named = TRUE)
y2 = setSex(y, sex = sx)
stopifnot(identical(y, y2))
# }
Run the code above in your browser using DataLab