# NOT RUN {
dat.ml <- data.frame(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
group = c(1, 1, 1, 2, 2, 2, 3, 3, 3),
x = c(4, 2, 5, 6, 3, 4, 1, 3, 4))
# Compute group means and expand to match the input x
group.scores(dat.ml$x, group = dat.ml$group)
# Compute standard deviation for each group and expand to match the input x
group.scores(dat.ml$x, group = dat.ml$group, fun = "sd")
# Compute group means without expanding the vector
group.scores(dat.ml$x, group = dat.ml$group, expand = FALSE)
# }
Run the code above in your browser using DataLab