minmax_scaling: Compute the min-max scaling

Description Usage Arguments Value Examples

View source: R/utils.R

Description

minmax_scaling normalizes a given vector using the the min-max scaling method. More formally:

scaled = \frac{data -x_{min}}{x_{max} - x_{min}} \times (f_{max} - f_{min}) + f_{min}

Usage

1
minmax_scaling(data, xmin = NULL, xmax = NULL, fmin = 0, fmax = 1)

Arguments

data

Vector with numeric data to be scaled.

xmin

Optional minimum value, otherwise min(data) will be used.

xmax

Optional maximum value, otherwise max(data) will be used.

fmin

Optional minimum range value, default is 0.

fmax

Optional maximum range value, default is 1.

Value

The scaled data in the given range, default is between (0, 1). If xmin = xmax the input vector data is returned.

Examples

1
2
data <- c(-20, 0, 15, 20)
scaled <- minmax_scaling(data)

andreaskapou/mpgex documentation built on Nov. 25, 2017, 8:08 a.m.