R/MinMaxNorm.R

MinMaxNorm <- structure(function(
	##title<< 
	## Normalize to a range
	##description<<
	## Normalizes values to a given range.
	
	x,
	### values
	
	ext=c(0,1),
	### new minimum and maximum values
	
   ...
   ### further arguments (unused)

	##details<<
	## No details.
	
	##references<< No reference.	
) {  
	max <- max(x, na.rm=TRUE)
	min <- min(x, na.rm=TRUE)
	std <- (x - min) * ((ext[2] - ext[1]) / (max - min)) + ext[1]
	return(std)
	### vector with normalized values
}, ex=function() {

x <- rnorm(10, 0, 2)
n <- MinMaxNorm(x)
plot(x, n)

})

Try the ModelDataComp package in your browser

Any scripts or data that you put into this service are public.

ModelDataComp documentation built on Nov. 22, 2020, 3 a.m.