min_max_scale {rearrr} | R Documentation |
Scale to a range
Description
Scales the values to a range with MinMax scaling.
Usage
min_max_scale(
x,
new_min,
new_max,
old_min = NULL,
old_max = NULL,
na.rm = FALSE
)
Arguments
x |
Numeric |
new_min |
Minimum value of target range. |
new_max |
Maximum value of target range. |
old_min |
Minimum value of original range. If |
old_max |
Maximum value of original range. If |
na.rm |
Whether missing values should be removed when calculating N.B. Ignored when both |
Value
Scaled version of `x`
.
Author(s)
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
See Also
Other scaling functions:
to_unit_length()
Examples
# Attach packages
library(rearrr)
# Set seed
set.seed(1)
# Create numeric vector
x <- runif(10)
# Scale
min_max_scale(x, new_min = -1, new_max = 0)
min_max_scale(x, new_min = -1, new_max = 0, old_max = 3)
[Package rearrr version 0.3.4 Index]