https://github.com/cran/FSelector
Raw File
Tip revision: 3e594f8fd8b56d6c609b1857ad9b41d057235295 authored by Lars Kotthoff on 16 February 2021, 17:20 UTC
version 0.33
Tip revision: 3e594f8
normalize.R
normalize.min.max <- function(data) {
	attr_count = dim(data)[2]
	if(attr_count == 0)
		return(data)
	for(i in 1:attr_count) {
		if(!is.numeric(data[, i]))
			next()
		if(!any(complete.cases(data[, i])))
			next()
		mm = range(data[, i], na.rm = TRUE)
		minimum = mm[1]
		maximum = mm[2]
		if(minimum == maximum)
			data[, i] = data[, i] / minimum
		else
			data[, i] = (data[, i] - minimum) / (maximum - minimum)
	}

	return(data)
}
back to top