group_center | R Documentation |
Also referred to as centering within cluster (or within context) or demeaning the variable.
By default, uses na.rm = TRUE
when computing group means.
group_center(x, grp)
x |
Variable to center (e.g., |
grp |
Cluster/grouping variable (e.g., |
A vector of group-mean centered variables.
data(mtcars)
#create a group centered variable
mtcars$mpg.gpc <- group_center(mtcars$mpg, mtcars$cyl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.