Standard: Rescale values to a standard normal scale

Normal: Rescale values to a standard (0-1) scale

Log: Rescale values to a natural log scale

Point-scale: Rescale values to a new point scale

rescale_standard(x, na_omit = TRUE)

rescale_normal(x, na_omit = TRUE)

rescale_log(x, na_omit = TRUE)

rescale_pointscale(x, lower, upper, lower0 = NULL, upper0 = NULL,
  na_omit = TRUE)

Arguments

x

Input vector

na_omit

Logical indicating whether to drop missing (NA) values. Default is TRUE.

lower

Min value of new scale. Only applicable for pointscales.

upper

Max value of new scale. Only applicable for pointscales.

lower0

Min value of old scale. If NULL, defaults to min of input. Only applicable for pointscales.

upper0

Max value of old scale. If NULL, defaults to max of input Only applicable for pointscales.

Value

Rescaled vector

Examples

## randomly sample 10 values ranging from -10 to 100 x <- sample(-10:100, 10) ## rescale to 0-1 scale rescale_standard(x)
#> [1] 0.89795918 0.93877551 0.61224490 0.44897959 1.00000000 0.87755102 #> [7] 0.18367347 0.79591837 0.07142857 0.00000000
## rescale to normal distribution (z-scores) rescale_normal(x)
#> [1] 0.8259388 0.9328565 0.0775153 -0.3501553 1.0932330 0.7724800 #> [7] -1.0451200 0.5586447 -1.3391436 -1.5262495
## rescale to logged distribution (natural log) rescale_log(x)
#> [1] 1.949390 1.968483 1.785330 1.653213 1.995635 1.939519 1.278754 1.897627 #> [9] 0.903090 0.000000
## rescale to new point scale rescale_pointscale(x, 1, 7, lower0 = -10, upper0 = 100)
#> [1] 6.018182 6.236364 4.490909 3.618182 6.563636 5.909091 2.200000 5.472727 #> [9] 1.600000 1.218182