# 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))
}
Run the code above in your browser using DataLab