grpss (version 3.0.1)

Scale: Scale a matrix-like object

Description

Scales the columns of a numeric matrix.

Usage

Scale(X, type = c("standardize", "normalize", "none"))

Arguments

X
A numeric matrix.
type
The scaling type. See details.

Value

  • A scaled numeric matrix.

Details

This function is similar to scale in base package, but it can also normalize the columns of a matrix. Suppose $x$ is one of the columns in matrix X. The "standardize" is defined as $$standardize = (x - mean(x))/sd(x)$$ and the "normalize" is defined as $$normalize = (x - min(x))/(max(x) - min(x)).$$ The "none" is just to keep the original values. It is designed for the grpss function in purpose.

Examples

x <- matrix(1:18, ncol = 3)
Scale(x)  # standardization
Scale(x, type = "normalize")  # normalization
Scale(x, type = "none")  # do nothing