Learn R Programming

cwhmisc (version 2.0.1)

normalize: Normalize vectors

Description

Normalize the columns of a matrix.

Usage

normalize(x)

Arguments

x
the matrix containing the vectors to be normalized as columns.

Value

  • The matrix containing the normalized vectors as columns. If you want to normalize the rows of a matrix, use t(normalize(t(x)))

Examples

Run this code
x <- matrix(rnorm(30),nrow=6)
  normalize(x)
  t(normalize(t(x)))  # normalize the *rows* of x

Run the code above in your browser using DataLab