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

nums <- c(runif(2), NA, -runif(2))
nums
#> [1]  0.7689241  0.3299883         NA -0.1344190 -0.5893607
normalization(nums, method = "max_min")
#> [1] 1.0000000 0.6768455 0.4339007 0.3349384 0.0000000
normalization(nums, method = "maximum")
#> [1]  1.0000000  0.4291559  0.0000000 -0.1748144 -0.7664744
normalization(nums, method = "sum")
#> [1]  0.42186177  0.18104446  0.00000000 -0.07374751 -0.32334626
normalization(nums, method = "softmax")
#> [1] 0.53122745 0.22436873 0.11736890 0.09014101 0.03689391
normalization(nums, method = "z_score")
#> [1]  1.3625453  0.5006459 -0.1473230 -0.4112697 -1.3045985
normalization(nums, method = "mad")
#> [1]  1.5716685  0.6744908  0.0000000 -0.2747503 -1.2046437
normalization(nums, method = "unit_vector")
#> [1]  0.7448972  0.3196770  0.0000000 -0.1302188 -0.5709447
normalization(nums, method = "unit_vector", na_rm = FALSE)
#> [1]  0.7448972  0.3196770         NA -0.1302188 -0.5709447