The function scales numeric objects to specific ranges.

scale2(x, lower = -1.5, upper = 1.5)

Arguments

x

Numeric, vector or matrix.

lower

The upper range.

upper

The lower range.

Value

A scaled numeric vector or matrix, scaled to the range provided in lower

and upper.

Examples

set.seed(123)
x <- runif(5)
scale2(x, -1, 1)
#> [1] -1.0000000  0.5338810 -0.6281167  0.8240135  1.0000000
scale2(x, 0, 10)
#> [1]  0.000000  7.669405  1.859417  9.120068 10.000000