normalize_whole: Normalise a whole matrix or vector between 0 and 1

View source: R/number_tools.R

normalize_wholeR Documentation

Normalise a whole matrix or vector between 0 and 1

Description

Normalise a whole matrix or vector between 0 and 1

Usage

normalize_whole(mat, from_zero = FALSE)

normalise_whole(mat, from_zero = FALSE)

Arguments

mat

(Numeric) A matrix or a vector.

from_zero

(Logical, default FALSE) If FALSE, the smallest value in the matrix will be set to 0. If TRUE, the smallest value in the matrix will be somewhere between 0 and 1.

Value

A matrix.

Authors

Examples

mat <- matrix(1:4, ncol = 2)

#>      [,1] [,2]
#> [1,]    1    3
#> [2,]    2    4

normalize_whole(mat, from_zero = TRUE)

#>      [,1] [,2]
#> [1,] 0.25 0.75
#> [2,] 0.50 1.00

normalize_whole(mat, from_zero = FALSE)

#>           [,1]      [,2]
#> [1,] 0.0000000 0.6666667
#> [2,] 0.3333333 1.0000000


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.