Learn R Programming

usefun (version 0.5.2)

normalize_to_range: Range normalization

Description

Normalize a vector, matrix or data.frame of numeric values in a specified range.

Usage

normalize_to_range(x, range = c(0, 1))

Value

the normalized data

Arguments

x

vector, matrix or data.frame with at least two different elements

range

vector of two elements specifying the desired normalized range. Default value is c(0,1)

Examples

Run this code
vec = 1:10
normalize_to_range(vec)
normalize_to_range(vec, range = c(-1,1))

mat = matrix(c(0,2,1), ncol = 3, nrow = 4)
normalize_to_range(mat, range = c(-5,5))

Run the code above in your browser using DataLab