relat: Relativize data

View source: R/launder.R

relatR Documentation

Relativize data

Description

Maps the elements of a numeric vector to the interval [0:1].

Usage

relat(x, na.rm = FALSE, default = 1, default.na = NaN)

Arguments

x

numeric vector.

na.rm

logical. Should NaNs be removed from x when calculating minimal and maximal values?

default

numeric. The default value(s) to use when all values in x are equal. Should lie between 0 and 1.

default.na

numeric. As default, but applied if minimal or maximal value are NaN. Not applicable if na.rm is true.

Value

The relativized vector α, such that x = (1-α)\min(x) + α\max(x) holds w.r.t. floating point inaccuracies.

Examples

relat(1:3)
relat(c(NaN, 2, 3, 4))
relat(c(NaN, 2, 3, 4), na.rm = TRUE)

pievos101/DFNET documentation built on Dec. 1, 2022, 3:44 p.m.