normalize: Vector rescaling

View source: R/scoring.R

normalizeR Documentation

Vector rescaling

Description

Rescale a vector within a new range.

Usage

normalize(x, new.min, new.max, x.min = min(x), x.max = max(x))
normalise(x, new.min, new.max, x.min = min(x), x.max = max(x))

Arguments

x

Numeric vector or single value.

new.min

New minimum.

new.max

New maximum.

x.min

Current minimum.

x.max

Current maximum.

Details

The function rescale the data by using the formula:

a + (b - a) * (x - min(x))/(max(x) - min(x))

where a is the new minimum of x and b the new maximum.

Examples

x <- 5:15
normalize(x, 0, 10)
normalize(x, -5, 5)

DavideMassidda/testing documentation built on Oct. 12, 2023, 4:32 p.m.