normalizer | R Documentation |
The function will apply several transformations, and indicate the transformation that best approximates a normal distribution.
normalizer(x, plotit = FALSE, return_all = FALSE, ...)
x |
a numeric vector without absent data. |
plotit |
Logical If TRUE histograms of each transformation will be ploted. |
return_all |
Logical. If TRUE it will return all values. Default is FALSE, and only the selected vector is returned. |
... |
Other parameters passed to the |
The function will apply eigth different transformations to the data:
Square root
Natural logarithm
Cube root
Box Cox
Logarithm in the base 10
Inverse (1 / x)
Inverse Natural logarithm (revert the data, apply a natural logarithm and then invert it back)
Tukey Ladder of Powers (if the vector is between 3 and 5000 long)
The normalizer
function uses the standardized D value calculated by a
Kolmogorov-Smirnov test using the function stats::ks.test
to determine
the transformation that most approximate a normal distribution.
The function will return a list with transformed vector
(or the raw data) that is closer to a normal distribution and the D value.
If return_all
equals TRUE, than a list with all transformations
is returned.
Bruno Vilela (email: bvilela@wustl.edu)
# Example 1: library(letsR) x <- as.vector(na.exclude(values(temp))) x <- x / 100 x_t <- normalizer(x, plotit = TRUE) # Example 2: library(datasets) data(mtcars) mpg_t <- normalizer(mtcars$mpg, plotit = TRUE, return_all = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.