group_mean: Computes the group mean of a variable

View source: R/group_mean.R

group_meanR 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., dataframe$varname).

grp

Cluster/grouping variable (e.g., dataframe$cluster).

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)

MLMusingR documentation built on May 29, 2024, 7:35 a.m.