Skip to contents

This function normalizes the rows of the input matrix x by dividing each row by its L2 norm (Euclidean norm).

Usage

normalize(x)

Arguments

x

Numeric matrix.

Value

Numeric matrix with normalized rows.

Examples

normalize(matrix(c(1,2,3,4,5,6), nrow = 2, byrow = TRUE))
#>           [,1]      [,2]
#> [1,] 0.2672612 0.4558423
#> [2,] 0.5345225 0.5698029
#> [3,] 0.8017837 0.6837635