Transformation
Transforms values from using any mathematical function (e.g. log).
prep.transform(data, fun, ...)
data
: a matrix with data valuesfun
: reference to a transformation function, e.g. log
or function(x) x^2
....
: optional parameters for the transformation functiondata matrix with transformed values
# generate a matrix with two columns y <- cbind(rnorm(100, 10, 1), rnorm(100, 20, 2)) # apply log transformation py1 = prep.transform(y, log) # apply power transformation py2 = prep.transform(y, function(x) x^-1.25) # show distributions par(mfrow = c(2, 3)) for (i in 1:2) { hist(y[, i], main = paste0("Original values, column #", i)) hist(py1[, i], main = paste0("Log-transformed, column #", i)) hist(py2[, i], main = paste0("Power-transformed, column #", i)) }