Learn R Programming

fastR (version 1.1)

Standardisation: Standardisation

Description

Standardisation

Usage

standardise(x, center = TRUE, scale = TRUE)

Arguments

x
A matrix with data. It has to be matrix, if it is data.frame for example the function does not turn it into a matrix.
center
Should the data be centred as well? TRUE or FALSE.
scale
Should the columns have unit variance, yes (TRUE) or no (FALSE)?

Value

A matrix with the standardised data.

Details

Similar to R's built in functions "scale" there is the option for centering or scaling only or both (default).

See Also

colVars, cova, cora

Examples

Run this code
x <-matrix( rnorm( 10000 * 100), ncol = 100 )
system.time( scale(x)[1:10000, ] )
system.time( standardise(x) )
a1 <- standardise(x)
a2 <- scale(x)[1:10000, ]
all.equal(a1, a2)

Run the code above in your browser using DataLab