Learn R Programming

rbvs (version 1.0.2)

standardise: Standardise data

Description

Standardises the columns of a numeric matrix x (similar to R-function scale). If x is a vector, it is treated as a 1-column matrix.

Usage

standardise(x, scale = TRUE)

Arguments

x
A numeric matrix (or vector).
scale
A logical; if TRUE each column of x is divided by the square root of the sum of its centred squares.

Value

Matrix with centred (and optionally scaled) columns.

Details

This function is much faster than scale.

Examples

Run this code
x <- matrix(rnorm(100*10), nrow = 100, ncol = 10)
x <- standardise(x)
standard.deviations <- apply(x,2,sd)
print(standard.deviations)

Run the code above in your browser using DataLab