View source: R/Module_transformDF.R
transformDF | R Documentation |
apply the transformVar() function to all numeric columns in a data frame
transformDF(X, type, logfirst = FALSE)
X |
is a data frame to transform using |
type |
"none", "standardize" (rescale to 0-1), or "normalize" (rescale to mean=0, sd =1) |
logfirst |
if TRUE, do a log-transform BEFORE applying either standardize or normalize |
If any zeroes in the data, then the log-transform causes problems. Using the strategy from Perry et al 2021 (https://journals.plos.org/plosone/article/comments?id=10.1371/journal.pone.0245941) which replaces 0 with a random value greater than 0 and less than one-half of the lowest non-zero value in the data for that variable. If the data has negative values, a constant equal to min(x)* 1.01 is added to all values (i.e. smallest value is a bit larger than 0)
A data frame with numeric columns transformed
transformDF(X = mtcars, type = "standardize", logfirst = FALSE) transformDF(X = mtcars, type = "normalize", logfirst = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.