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. Default is FALSE.

add.suffix

The suffix of the centered variable(s). Default is "". You may set it to "_c", "_center", etc.

Value

A new data object containing the centered variable(s).

See Also

group_mean_center

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 0.8.0 Index]