When analyzing numeric data, either discrete or continuous variables, it is often necessary or at least practical to normalize the values in order to get a more comprehensible scale to analyze the data in, this is, transforming the values to a \(0 ≤ x ≤ 1\) scale, where \(0\) is the lowest value and \(1\) the highest in the distribution.
We included two functions to normalize and rescale numeric vectors,
unit_normalization()
and
ab_range_normalization()
, respectively. The former takes a
numeric vector x
as input and outputs a normalized version
of the same distribution.
## [1] 0.000 0.025 0.050 0.075 0.100 0.125 0.150 0.175 0.200 0.225 0.250 0.275
## [13] 0.300 0.325 0.350 0.375 0.400 0.425 0.450 0.475 0.500 0.525 0.550 0.575
## [25] 0.600 0.625 0.650 0.675 0.700 0.725 0.750 0.775 0.800 0.825 0.850 0.875
## [37] 0.900 0.925 0.950 0.975 1.000
Similarly the ab_range_normalization()
function can be
used to rescale a numeric vector x
to an arbitrary range
between a
and b
. E.g.:
## [1] 1.000 3.475 5.950 8.425 10.900 13.375 15.850 18.325 20.800
## [10] 23.275 25.750 28.225 30.700 33.175 35.650 38.125 40.600 43.075
## [19] 45.550 48.025 50.500 52.975 55.450 57.925 60.400 62.875 65.350
## [28] 67.825 70.300 72.775 75.250 77.725 80.200 82.675 85.150 87.625
## [37] 90.100 92.575 95.050 97.525 100.000