View source: R/bruceR-stats_4_regress.R
| group_mean_center | R Documentation | 
Compute group-mean centered variables. Usually used for HLM level-1 predictors.
group_mean_center(
  data,
  vars = setdiff(names(data), by),
  by,
  std = FALSE,
  add.suffix = "",
  add.group.mean = "_mean"
)
data | 
 Data object.  | 
vars | 
 Variable(s) to be centered.  | 
by | 
 Grouping variable.  | 
std | 
 Standardized or not. Defaults to   | 
add.suffix | 
 The suffix of the centered variable(s). Defaults to   | 
add.group.mean | 
 The suffix of the variable name(s) of group means. Defaults to   | 
A new data object containing the centered variable(s).
grand_mean_center()
d = data.table(x=1:9, g=rep(1:3, each=3))
d.c = group_mean_center(d, "x", by="g")
d.c
d.c = group_mean_center(d, "x", by="g", add.suffix="_c")
d.c
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.