Learn R Programming

jvcoords (version 1.0.3)

standardize: Standardize data

Description

Standardize each column of a data matrix and return the results as an object of class coords.

Usage

standardize(x, compute.scores = TRUE)

Arguments

x

A data matrix, rows are observations, columns are variables.

compute.scores

Whether to compute the scores (i.e. x in the new basis).

Value

An object of class coords, with the following additional components added:

y

if compute.scores==TRUE, this is x expressed in the new basis

Details

This function standardizes the columns of x by subtracting the mean of each column and then dividing by the standard deviation. The transformed data is stored in the $y field of the returned coords object.

If compute.scores is set to FALSE, only the information required for the toCoords() and fromCoords() to work is stored in the returned coords object; otherwise the scores (transformed data) will be stored in the $y field of the coords object.

See Also

coords; alternative implementation scale

Examples

Run this code
# NOT RUN {
  w <- standardize(iris[, 1:4])
  colMeans(w$y)
  apply(w$y, 2, sd)
# }

Run the code above in your browser using DataLab