grand_mean_center {bruceR} | R Documentation |
Grand-mean centering.
Description
Compute grand-mean centered variables. Usually used for GLM interaction-term predictors and HLM level-2 predictors.
Usage
grand_mean_center(data, vars = names(data), std = FALSE, add.suffix = "")
Arguments
data |
Data object. |
vars |
Variable(s) to be centered. |
std |
Standardized or not. Defaults to |
add.suffix |
The suffix of the centered variable(s).
Defaults to |
Value
A new data object containing the centered variable(s).
See Also
Examples
d = data.table(a=1:5, b=6:10)
d.c = grand_mean_center(d, "a")
d.c
d.c = grand_mean_center(d, c("a", "b"), add.suffix="_center")
d.c
[Package bruceR version 2024.6 Index]