Learn R Programming

cNORM (version 3.3.1)

getGroups: 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)

Value

vector with group means for each observation

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

Examples

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

Run the code above in your browser using DataLab