Learn R Programming

lgspline (version 0.2.0)

std: Standardize Vector to Z-Scores

Description

Centers a vector by its sample mean, then scales it by its sample standard deviation \((\text{x}-\text{mean}(\text{x}))/\text{sd}(\text{x})\).

Usage

std(x)

Value

Standardized vector with sample mean 0 and standard deviation 1

Arguments

x

Numeric vector to standardize

Examples

Run this code
x <- c(1, 2, 3, 4, 5)
std(x)
print(mean(x))
print(sd(x))

Run the code above in your browser using DataLab