Description Usage Arguments Details Value Examples
Scale a data frame or matrix
1 |
data |
a data frame or matrix |
scale.type |
one of "sample.sd" (default),"pop.sd", "median", "huber", "YJ", or "npn". pop.sd centers by the mean and population standard deviation, while sample.sd uses the R default of the sample standard deviation formula as in base::scale. "median" uses the median as the center and median absolute deviation as the scale. "huber" uses Huber's robust estimates of location and scale (relying on the MASS::hubers function). "YJ" performs the Yeo-Johnson transformation on the numeric variables. This is a generalization of the Box-Cox transformation which allows for transforming variables with negative values. "npn" performs the non-paranormal transform, which in my opinion is preferable to the Yeo-Johnson/Box-Cox transform. The non-paranormal transform takes the rank of each value in a vector X and divides it by the number of samples+1 to obtain a vector Q, ie Q=rank(x)/(n + 1). It then plugs each observation in Q into the normal quantile function and scaled by the standard deviation. This results in a normally distributed, scaled, and centered, data set. |
an improvement of the base R scale function. This function takes a data frame or matrix of mixed variable types and scales the numeric columns according to one of several options.
A matrix or data frame
1 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.