stnd_norm: Standardizes a vector to a N(0, 1) distribution

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/stnd_norm.R

Description

This function standardizes a vector by taking each element of the vector and subtracting the mean and dividing by the standard deviation of the vector.

Usage

1
stnd_norm(x, na.rm = TRUE, tol = 0.001)

Arguments

x

numeric vector

na.rm

logical, if TRUE NA's are removed for computing the mean and standard deviation.

tol

tolerance of similarity between elements in the vector, if each element is within the tolerance of each other a vector of zeros is returned

Details

You can set a tolerance level, which is required if the values in the vector to be standardized are equal. If all values in the vector are within the 'tol' level of each other the standardized values will be set to 0.

Value

Returns a vector the same length as x

Author(s)

Michael Malick

See Also

mean sd

Examples

1
2
3
4
5
x <- c(1, 2, 3, NA, 4, 5)
stnd_norm(x)

y <- rep(3.1, 10)
stnd_norm(y)

michaelmalick/r-malick documentation built on May 22, 2017, 6:37 a.m.