BBmisc (version 1.10)

normalize: Normalizes numeric data to a given scale.


Currently implemented for numeric vectors, numeric matrices and data.frame. For matrixes one can operate on rows or columns For data.frames, only the numeric columns are touched, all others are left unchanged. For constant vectors / rows / columns most methods fail, special behaviour for this case is implemented.

The method also handles NAs in in x and leaves them untouched.


normalize(x, method = "standardize", range = c(0, 1), margin = 1L, on.constant = "quiet")


[numeric | matrix | data.frame] Input vector.
[character(1)] Normalizing method. Available are: “center”: Subtract mean. “scale”: Divide by standard deviation. “standardize”: Center and scale. “range”: Scale to a given range.
[numeric(2)] Range for method “range”. The first value represents the replacement for the min value, the second is the substitute for the max value. So it is possible to reverse the order by giving range = c(1,0). Default is c(0,1).
[integer(1)] 1 = rows, 2 = cols. Same is in apply Default is 1.
[character(1)] How should constant vectors be treated? Only used, of “method != center”, since this methods does not fail for constant vectors. Possible actions are: “quiet”: Depending on the method, treat them quietly: “scale”: No division by standard deviation is done, input values. will be returned untouched. “standardize”: Only the mean is subtracted, no division is done. “range”: All values are mapped to the mean of the given range. “warn”: Same behaviour as “quiet”, but print a warning message. “stop”: Stop with an error.


[numeric | matrix | data.frame].

See Also