getGroups: Determine groups and group means

View source: R/utilities.R

getGroupsR Documentation

Determine groups and group means

Description

Helps to split the continuous explanatory variable into groups and assigns the group mean. The groups can be split either into groups of equal size (default) or equal number of observations.

Usage

getGroups(x, n = NULL, equidistant = FALSE)

Arguments

x

The continuous variable to be split

n

The number of groups; if NULL then the function determines a number of groups with usually 100 cases or 3 <= n <= 20.

equidistant

If set to TRUE, builds equidistant interval, otherwise (default) with equal number of observations

Value

vector with group means for each observation

Examples

x <- rnorm(1000, m = 50, sd = 10)
m <- getGroups(x, n = 10)


cNORM documentation built on Nov. 4, 2024, 5:07 p.m.