Please does anyone know why the script below does not maintain the original order of the 'father' column? It rearranges the column and the trio would not match anymore. The data test has 3 columns (Child, father, mother). It is related to a previous post: Substitute the specific proportions of each group with another value in R Thank you.
test$father <- unlist(
tapply(test$father,test$father,
function(x) {
x[1:floor(length(x)*0.25)] <- 0
x
}
)
)