Skip to contents

Transform values in x such that the mean is approximately 0 and the standard deviation is approximately 1. Note that this is a whole-cloth reimplemntation of a function of the same name from the rethinking package by Dr. Richard McElreath.

Usage

standardize(x)

Arguments

x

A vector of values to be scaled.

Examples

x <- rnorm(1000, mean = 3, sd = 4)
z <- standardize(x)

mean(z)
#> [1] -3.870005e-17
sd(z)
#> [1] 1