unitize: Convert a Vector to Unit Length

Description Usage Arguments Details Value Author(s) Examples

View source: R/04-reaper.R

Description

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

Usage

1
unitize(mat)

Arguments

mat

A matrix of real numbers.

Details

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

Value

A matrix of the same size as the input matrix.

Author(s)

Kevin R. Coombes <krc@silicovore.com>

Examples

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

Example output

Loading required package: ClassDiscovery
Loading required package: cluster
Loading required package: oompaBase
Loading required package: PCDimension
[1] 1 1 1 1
         [,1]      [,2]      [,3]     [,4]
[1,] 1.991993 0.8474555 0.7620035 2.664581
[2,] 1.991993 0.8474555 0.7620035 2.664581
[3,] 1.991993 0.8474555 0.7620035 2.664581

Thresher documentation built on Jan. 11, 2020, 9:24 a.m.