standardize: Standardize numeric variables

Description Usage Arguments Details Value Examples

View source: R/standardize.R

Description

Standardize the numeric variables in a data frame

Usage

1
standardize(data, mean = 0, sd = 1, include_dummy = FALSE)

Arguments

data

a data frame.

mean

mean of the transformed variables.

sd

standard deviation of the transformed variables.

include_dummy

logical. If TRUE, transform dummy coded (0,1) variables.

Details

standardize transforms all the numeric variables in a data frame to have the same mean and standard deviation. By default, this will be a mean of 0 and standard deviation of 1. Character variables and factors are left unchanged. By default, dummy coded variables are also left unchanged. Use include_dummy=TRUE to transform these variables as well.

Value

a data frame

Examples

1
2
3
4
head(cars74)

cars74_st <- standardize(cars74)
head(cars74_st)

Rkabacoff/qacr documentation built on March 20, 2021, 3:03 p.m.