Learn R Programming

DMTL (version 0.1.2)

zscore: Standardize matrix per column

Description

This function standardized each column of a dataframe or matrix (-alike) to have \(mean = 0\) and \(sd = 1\).

Usage

zscore(X)

Arguments

X

Dataframe or matrix (-alike) containing data.

Value

The standardized dataframe.

Examples

Run this code
# NOT RUN {
X <- matrix(rnorm(100, 0.2, 0.3), nrow = 20)
X_std <- zscore(X)
print(apply(X_std, 2, mean))
print(apply(X_std, 2, sd))

# }

Run the code above in your browser using DataLab