Learn R Programming

parameters (version 0.1.0)

standardize.data.frame: Data Standardization (Z-scores)

Description

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.

Usage

# S3 method for data.frame
standardize(x, robust = FALSE, method = "default",
  select = NULL, exclude = NULL, verbose = TRUE, force = FALSE,
  ...)

Arguments

x

Object.

robust

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

method

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).

select

For a data frame, character vector of column names to be standardized. If NULL (the default), all variables will be standardized.

exclude

For a data frame, character vector of column names to be excluded from standardization.

verbose

Toggle warnings on or off.

force

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.

Value

A standardized data.frame.

Examples

Run this code
# NOT RUN {
summary(standardize(iris))
# }

Run the code above in your browser using DataLab