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