View source: R/standardize_variable.R
standardize_variable | R Documentation |
The following methods are supported:
"center": Simple centering subtracts the mean of the variable from all values. This effectively centers them around zero and can be useful when you want to remove the mean but not change the scale.
"zscore": Z-score normalization standardizes a variable to have a mean of 0 and standard deviation of 1. It is useful when comparing variables that have different units or scales, and is often used in regression, PCA, and t-tests.
"minmax": Min-Max scaling scales the variable so that its values fall between 0 and 1. It is useful for algorithms that require bounded inputs like neural networks, and for visualization.
"maxabs": Max Abs scaling scales each observation by the maximum absolute value of the variable. This is useful for data that's centered but not strictly positive, such as text data represented by word frequencies.
"robust": Robust scaling uses the median and the IQR, thus not influenced by outliers. It is ideal for data with outliers or when working with algorithms sensitive to outliers.
"quantile": Quantile scaling scales the data between the 1st quartile and the 3rd quartile. Sometimes also referred to as "robust" scaling, it can be useful for data with extreme outliers.
"unitvector": Unit Vector transformation scales the variable so that the resulting vector has a length (norm) of 1. This is useful when the scale of the variable is not informative, such as when dealing with text data.
"decimalscale": Decimal Scaling moves the decimal point of values based on the maximum absolute value in the dataset, which also rescales the data between -1 and 1.
"whitening": Whitening or Sphereing Transform de-correlates the features and scales them to have unit variance.
"manhattanscale": Manhattan Scaling scales data based on the L1 norm (sum of absolute values).
"rankscale": Rank Scaling replaces each data point with its rank in the sorted list of all data points. It's useful when you want to use the relative position of each data point rather than its exact value.
standardize_variable(x, method = "zscore")
x |
A numeric vector to be standardized. |
method |
A string specifying the standardization method to use. |
This function standardizes a numeric vector according to the specified method.
A numeric vector with the standardized values.
Izenman, Alan Julian. "Modern multivariate statistical techniques: Regression, classification, and manifold learning." (2008).
scale
## Not run:
data <- rnorm(100)
standardized_data <- standardize_variable(data, method = "zscore")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.