powered by
Splits a continuous variable into n groups (either equidistant or with equal number of observations) and returns the group mean for every observation.
n
getGroups(x, n = NULL, equidistant = FALSE)
Numeric vector of the same length as x with the group mean assigned to each observation.
x
Numeric vector to be split.
Desired number of groups. If NULL, the function chooses roughly one group per 100 observations, constrained to 3 \(\le\) n \(\le\) 20.
NULL
If TRUE, intervals have equal width; otherwise (default) each interval contains roughly the same number of observations.
TRUE
if (FALSE) { x <- rnorm(1000, mean = 50, sd = 10) m <- getGroups(x, n = 10) }
Run the code above in your browser using DataLab