Rescale a numeric vector
center(x, ...) unit_range(x, ...) unit_length(x, na.rm = TRUE)
x | a numeric vector |
---|---|
... | additional arguments passed to |
na.rm | if |
a rescaled version of x
.
center
\(\frac{x - mean(x)}{sd(x)}\)
unit_range
\(\frac{x - min(x)}{max(x) - min(x)}\)
unit_length
\(\frac{x}{|| x ||}\)
https://en.wikipedia.org/wiki/Normalization_(statistics)
center(1:10)#> [1] -1.4863011 -1.1560120 -0.8257228 -0.4954337 -0.1651446 0.1651446 #> [7] 0.4954337 0.8257228 1.1560120 1.4863011unit_range(1:10)#> [1] 0.0000000 0.1111111 0.2222222 0.3333333 0.4444444 0.5555556 0.6666667 #> [8] 0.7777778 0.8888889 1.0000000unit_length(1:10)#> [1] 0.05096472 0.10192944 0.15289416 0.20385888 0.25482360 0.30578831 #> [7] 0.35675303 0.40771775 0.45868247 0.50964719