Learn R Programming

kerntools (version 1.2.0)

cosnormX: Cosine normalization of a matrix

Description

Normalizes a numeric matrix dividing each row (if rows=TRUE) or column (if rows=FALSE) by their L2 norm. Thus, each row (or column) has unit norm.

Usage

cosnormX(X, rows = TRUE)

Value

Cosine-normalized X.

Arguments

X

Numeric matrix or data.frame of any size.

rows

If TRUE, the operation is done by row; otherwise, it is done by column. (Defaults: TRUE).

Examples

Run this code
dat <- matrix(rnorm(50),ncol=5,nrow=10)
cosnormX(dat)

Run the code above in your browser using DataLab