powered by
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)
Outputs a vector of group means.
Variable to compute the mean for (e.g., dataframe$varname).
dataframe$varname
Cluster/grouping variable (e.g., dataframe$cluster).
dataframe$cluster
Compute reliability (lambda) adjusted means.
data(mtcars) #create a group mean aggregated variable mtcars$mpg.barj <- group_mean(mtcars$mpg, mtcars$cyl)
Run the code above in your browser using DataLab