SciencesPo (version 1.3.8)

normalize: Unity-based normalization

Description

Normalizes as feature scaling, min - max, or unity-based normalization. Typically used to bring all values into the range [0,1]. However, this can be generalized to restrict the range of values in the dataset between any arbitrary points a and b, using: $$X' = a + \frac{(x - x_{min})(b - a)}{(x_{max} - x_{min})}$$.

Usage

normalize(x, range, domain, ...)

## S3 method for class 'factor': normalize(x, range, domain = range(1:nlevels(x)), ...)

## S3 method for class 'numeric': normalize(x, range = c(0, 1), domain = range(x, na.rm = TRUE), ...)

## S3 method for class 'default': normalize(x, range = c(0, 1), domain, ...)

## S3 method for class 'character': normalize(x, range = c(0, 1), domain, ...)

Arguments

x
is a vector to be normalized.
range
is a numeric vector of length 2 for min and max values, default is c(0,1).
domain
a numeric vector of length 2.
...
further arguments passed to or used by other methods.

Value

  • Normalized values in an object of the same class as var.

encoding

UTF-8

See Also

svTransform, new.range.

scale.

Examples

Run this code
x <- sample(10)
normalize(x, range=c(0,1))
normalize(x)

Run the code above in your browser using DataCamp Workspace