View source: R/transform_data.R
| transform_data | R Documentation |
Applies a transformation (log, sqrt, inverse, Box-Cox, Yeo-Johnson) or standardization (z-score, centering, scaling, min-max, robust scaling) to selected numeric columns. Group-wise transformation is supported.
transform_data(data, cols = NULL, method = "log", group = NULL,
lambda = 1.0, verbose = FALSE)
data |
A data frame or matrix containing numeric variables. |
cols |
The column indices or names of selected variables. If NULL, all columns are used. |
method |
Transformation method. One of |
group |
Optional grouping column for group-wise transformation. |
lambda |
Parameter for Box-Cox and Yeo-Johnson transformations (default 1.0). |
verbose |
Logical; if |
For "boxcox", values must be positive. For "yeojohnson", both positive and negative values are allowed. Standardization methods ignore NA values.
A data frame with transformed variables.
# Log transformation
transform_data(data[1:100, c(1, 4, 17:19)], cols = 3:5, method = "log")
# Z-score standardization by group
transform_data(data[1:100, c(1, 4, 17:19)], cols = 3:5, method = "zscore", group = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.