Learn R Programming

Thresher (version 1.1.5)

unitize: Convert a Vector to Unit Length

Description

Rescales each column of a matrix to produce vectors of length one.

Usage

unitize(mat)

Value

A matrix of the same size as the input matrix.

Arguments

mat

A matrix of real numbers.

Author

Kevin R. Coombes <krc@silicovore.com>

Details

No details beyond the simple description are requires; it is implemented exactly the way you would suspect.

Examples

Run this code
simmat <- matrix(rnorm(12), 3, 4)
U <- unitize(simmat)
apply(U^2, 2, sum)  # check unit length
simmat/U            # view normalization factors

Run the code above in your browser using DataLab