| stratified_boxcox | R Documentation | 
Create Box-Cox transformation using different optimal lambda values for each stratum
stratified_boxcox(
  data,
  value_col,
  strat_cols,
  plot = FALSE,
  return = "values",
  buffer = 0,
  inverse = FALSE,
  lambdas = NULL
)
data | 
 data.frame containing the data  | 
value_col | 
 character, name of column with values to be transformed  | 
strat_cols | 
 character (vector), name(s) of columns to stratify by  | 
plot | 
 logical, should the lambda distribution be plotted?  | 
return | 
 character, either "values" or "lambdas"  | 
buffer | 
 numeric, buffer value to be added before transformation, used to ensure all positive values  | 
inverse | 
 logical, if TRUE, the function reverses the transformation given a list of lambdas  | 
lambdas | 
 if inverse == TRUE: Nested list of lambdas used in original transformation. Can be obtained by using return = "lambdas" on untransformed data  | 
if "values", vector of transformed values, if "lambdas" nested named list of used lambdas. The buffer will be equal for all strata
J. Peter Marquardt
data <- data.frame("value" = c(1:50, rnorm(50, 100, 10)),
                   "strat_var" = rep(c(1,2), each = 50),
                   "strat_var2" = rep(c(1, 2), 50))
lambdas <- stratified_boxcox(data = data, value_col = "value",
                             strat_cols = c("strat_var", "strat_var2"),
                             return = "lambdas")
data$value_boxed <- stratified_boxcox(data = data, value_col = "value",
                                      strat_cols = c("strat_var", "strat_var2"),
                                      return = "values")
data$value_unboxed <- stratified_boxcox(data = data, value_col = "value_boxed",
                                        strat_cols = c("strat_var", "strat_var2"),
                                        inverse = TRUE, lambdas = lambdas)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.