Standardize (centering and scaling, Z-score) the data so that the
values are expressed in terms of standard deviation (i.e., mean = 0, SD = 1)
or Median Absolute Deviance (median = 0, MAD = 1). A normalization
scales all numeric variables in the 0 - 1 range.
# S3 method for data.frame
standardize(x, robust = FALSE, method = "default",
select = NULL, exclude = NULL, verbose = TRUE, force = FALSE,
...)
Object.
Logical, if TRUE
, centering is done by substracting the
median from the variables and divide it by the median absolute deviation
(MAD). If FALSE
, variables are standardized by substracting the
mean and divide it by the standard deviation (SD).
the
The method of standardization. For data.frames, can be "default"
(variables are divided by SD or MAD depending on robust
) or "2sd"
(divided by two times the deviation).
For a data frame, character vector of column names to be
standardized. If NULL
(the default), all variables will be
standardized.
For a data frame, character vector of column names to be excluded from standardization.
Toggle warnings on or off.
Logical, if TRUE
, forces standardization of factors as
well. Factors are converted to numerical values, with the lowest level
being the value 1
(unless the factor has numeric levels, which are
converted to the corresponding numeric value).
Arguments passed to or from other methods.
A standardized data.frame.
# NOT RUN {
summary(standardize(iris))
# }
Run the code above in your browser using DataLab