Learn R Programming

SciencesPo (version 1.3.9)

normalize: Unity-based normalization

Description

Normalizes as feature scaling min - max, or unity-based normalization typically used to bring the values into the range [0,1].

Usage

normalize(x, method = "range")

## S3 method for class 'ANY': normalize(x, method = "range")

Arguments

x
is a vector to be normalized.
method
A string for the method used for normalization. Default is method = "range", which brings the values into the range [0,1]. See details for other implemented methods.

Value

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

encoding

UTF-8

Details

This approach may also be generalized to restrict the range of values to any arbitrary values a and b, using: $$X' = a + \frac{(x - x_{min})(b - a)}{(x_{max} - x_{min})}$$.

See Also

svTransform, scale.

Examples

Run this code
x <- sample(10)
normalize(x)

# equivalently to
(x-min(x))/(max(x)-min(x))

Run the code above in your browser using DataLab