| dat_trans | R Documentation | 
Perform data set transformation
dat_trans(x, method = "auto", na.rm = TRUE, add = 1)
vec_trans(x, method = "auto", na.rm = TRUE, add = 1)
| x | a matrix, data frame or vector. | 
| method | transformation method, including: "center", "auto", "range", "pareto", "vast", "level", "log", "log10", "sqrt" and "asinh". | 
| na.rm | a logical value indicating whether NA values should be stripped before the computation proceeds. | 
| add | a shift value for log transformation. | 
transformed data
Berg, R., Hoefsloot, H., Westerhuis, J., Smilde, A. and Werf, M. (2006), Centering, scaling, and transformations: improving the biological information content of metabolomics data, BMC Genomics, 7:142
 data(iris)
 ## transform an vector
 vec <- iris[, 1]
 dat_trans(vec, method = "auto")
 vec_trans(vec, method = "auto")
 ## transform a data frame
 mat <- iris[, 1:4]
 dat_trans(mat, method = "log")
 ## transform data frame under different conditions
 plyr::ddply(iris, ("Species"), function(x, method) {
   dat_trans(x[, 1:4], method = method)
 }, method = "range")
## use 'tidyverse'
library(dplyr)
library(tidyr)
library(purrr)
## transform whole data set
iris %>% mutate(across(where(is.numeric), ~ vec_trans(., method = "range")))
## transform data set within groups
iris %>% 
  group_by(Species) %>%
  mutate(across(where(is.numeric), ~ vec_trans(., method = "range")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.