mean_center: Mean Center Numeric Variables

Description Usage Arguments Value Examples

View source: R/mean_center.R

Description

Function to mean center predictor variables.

Usage

1

Arguments

x

A numeric vector.

Value

A numeric vector containing x minus the mean of x. Note that NA's are ignored.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# load mtcars data
data(mtcars)

# Mean center a single numeric variable
(mtcars$c_mpg <- mean_center(mtcars$mpg))

# Mean center multiple numeric variables
centered <- do.call(cbind, lapply(mtcars[c("mpg", "hp")], mean_center))
colnames(centered) <- c("c_mpg", "c_hp")
mtcars2 <- cbind(mtcars, centered)

brad-cannell/bfuncs documentation built on Oct. 20, 2018, 2:39 a.m.