rescale: Rescale any numerical variable from min-max to 0-1.

Description Usage Arguments Author(s) Examples

View source: R/rescale.R

Description

Rescale any numerical variable from min-max to 0-1.

Usage

1
rescale(x, backward = F)

Arguments

x
backward

Author(s)

Joost van de Weijer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x, backward = F)
{
    if (!backward)
        structure((x - min(x, na.rm = T))/(max(x, na.rm = T) -
            min(x, na.rm = T)), range = range(x, na.rm = T))
    else structure(x * (attr(x, which = "range")[2] - attr(x,
        which = "range")[1]) + attr(x, which = "range")[1], range = attr(x,
        which = "range"))
  }

vdweijer/supply documentation built on June 28, 2021, 7:45 a.m.