group_mean {MLMusingR} | R Documentation |
Computes the group means of a variable by a specified cluster/group. Can also be used with factors that have two levels.
group_mean(x, grp, lm = FALSE)
x |
Variable to compute the mean for (e.g., |
grp |
Cluster/grouping variable (e.g., |
lm |
Compute reliability (lambda) adjusted means. |
Outputs a vector of group means.
data(mtcars)
#create a group mean aggregated variable
mtcars$mpg.barj <- group_mean(mtcars$mpg, mtcars$cyl)