prep.transform {mdatools}R Documentation

Transformation

Description

Transforms values from using any mathematical function (e.g. log).

Usage

prep.transform(data, fun, ...)

Arguments

data

a matrix with data values

fun

reference to a transformation function, e.g. 'log' or 'function(x) x^2'.

...

optional parameters for the transformation function

Value

data matrix with transformed values

Examples

# 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))
}


[Package mdatools version 0.14.1 Index]