We are hiring ! See our job offers.
swh:1:snp:0f920b1e114986636ba2e45b5c1a83473fb6cf12
Raw File
Tip revision: 893e2d90fd8569e5f0295334c9a1844e95d7911b authored by Piotr Romanski on 11 April 2009, 00:00:00 UTC
version 0.18
Tip revision: 893e2d9
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