zscore: Standardize matrix per column

Description Usage Arguments Value Examples

View source: R/lambda_functions.R

Description

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

Usage

1
zscore(X)

Arguments

X

Dataframe or matrix (-alike) containing data.

Value

The standardized dataframe.

Examples

1
2
3
4
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))

DMTL documentation built on Feb. 18, 2021, 5:06 p.m.