group_means: Compute column-wise mean in X for each factor level of Y

group_meansR Documentation

Compute column-wise mean in X for each factor level of Y

Description

This function computes group means for each factor level of Y in the provided data matrix X.

Usage

group_means(Y, X)

Arguments

Y

a vector of labels to compute means over disjoint sets

X

a data matrix from which to compute means

Value

a matrix with row names corresponding to factor levels of Y and column-wise means for each factor level

Examples

# Example data
X <- matrix(rnorm(50), 10, 5)
Y <- factor(rep(1:2, each = 5))

# Compute group means
gm <- group_means(Y, X)

bbuchsbaum/multivarious documentation built on April 15, 2024, 3:33 a.m.