z: Flexible standardization of variables

z.R Documentation

Flexible standardization of variables

Description

Generic function that standardizes a vector, matrix or dataframe by user-defined parameters.

Usage

z.(x, center = NULL, factor = 1)

Arguments

x

a vector, matrix, or dataframe.

center

numeric. Value around which values in x will be centered? If NULL, the mean of x is used.

factor

numeric. A scale multiplier (see details).

Details

For each item in x, subtract value specified by center and divide by scaling factor. The scaling factor is the standard deviation of x times factor. The default is z-score standardization (center around mean and divide by 1 standard deviation).

Author(s)

Jason Grafmiller

References

Gelman, A. & J. Hill. 2007. Data Analysis Using Regression and Multilevel/Hierarchical Models. New York: Cambridge University Press.

See Also

scale, c.

Examples

x <- rnorm(50, mean = 10, sd = 5)
z.(x)
z.(x, factor = 2)
z.(x, center = 2, factor = 1.5)

jasongraf1/JGmisc documentation built on March 21, 2022, 7:42 a.m.