更新时间:2023-12-01 11:36:16
尝试一下:
ped <- transform(ped, gender = ifelse(person %in% father,
'M',
ifelse(person %in% mother, 'F', NA)
))
而不是循环遍历各个值行,这使用矢量化。
Instead of looping over the individual values across the rows, this uses vectorization.