Range a variable into [0-1], assigning 0 to the min and 1 to the max of the input variable. All NA values will be removed.

range01(var)

Arguments

var

numeric input vector

Value

vector with the values scaled into the 0 to 1 range

Examples

range01(mtcars$cyl)
#> [1] 0.5 0.5 0.0 0.5 1.0 0.5 1.0 0.0 0.0 0.5 0.5 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 #> [20] 0.0 0.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 1.0 0.5 1.0 0.0