Skip to contents

Normalize numeric vector

Usage

normalization(x, method = "max_min", na_rm = TRUE, ...)

Arguments

x

Input numeric vector.

method

Method used for normalization.

na_rm

Whether to remove NA values, and if setting TRUE, using 0 instead.

...

Parameters for other methods.

Value

Normalized numeric vector

Examples

x <- c(runif(2), NA, -runif(2))
x
#> [1]  0.04134503  0.89385863          NA -0.51114883 -0.67691351
normalization(x, method = "max_min")
#> [1] 0.4572646 1.0000000 0.4309432 0.1055307 0.0000000
normalization(x, method = "maximum")
#> [1]  0.04625455  1.00000000  0.00000000 -0.57184527 -0.75729370
normalization(x, method = "sum")
#> [1]  0.01947237  0.42098288  0.00000000 -0.24073707 -0.31880768
normalization(x, method = "softmax")
#> [1] 0.15011510 0.60192594 0.14033773 0.06103198 0.04658925
normalization(x, method = "z_score")
#> [1]  0.14973106  1.53846314  0.08238061 -0.75027330 -1.02030151
normalization(x, method = "mad")
#> [1]  0.05455718  1.17949870  0.00000000 -0.67449076 -0.89322694
normalization(x, method = "unit_vector")
#> [1]  0.03353329  0.72497271  0.00000000 -0.41457222 -0.54901727
normalization(x, method = "unit_vector", na_rm = FALSE)
#> [1]  0.03353329  0.72497271          NA -0.41457222 -0.54901727