transformDF: apply the transformVar() function to all numeric columns in a...

View source: R/Module_transformDF.R

transformDFR Documentation

apply the transformVar() function to all numeric columns in a data frame

Description

apply the transformVar() function to all numeric columns in a data frame

Usage

transformDF(X, type, logfirst = FALSE)

Arguments

X

is a data frame to transform using transformVar.

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

Details

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)

Value

A data frame with numeric columns transformed

Examples

transformDF(X = mtcars, type = "standardize", logfirst = FALSE)
transformDF(X = mtcars, type = "normalize", logfirst = TRUE)

SalmonForecastR/ForecastR-Package documentation built on March 10, 2023, 2:18 p.m.