'How to use BoxCox transformation in the caret package in R?

#univariate transformations to solve skewness(boxcox)
library(caret)
describe(data_numeric)
trans_data <- preProcess(data_numeric, method = c("BoxCox"))

> dput(head(data_numeric))
structure(list(age = c(56, 57, 37, 40, 56, 45), duration = c(261, 
149, 226, 151, 307, 198), EmpVarRt = c(1.1, 1.1, 1.1, 1.1, 1.1, 
1.1), ConPrIdx = c(93.994, 93.994, 93.994, 93.994, 93.994, 93.994
), ConConIdx = c(-36.4, -36.4, -36.4, -36.4, -36.4, -36.4), euribor3m = c(4.857, 
4.857, 4.857, 4.857, 4.857, 4.857), campaign = c(1, 1, 1, 1, 
1, 1), pdays = c(999, 999, 999, 999, 999, 999), previous = c(0, 
0, 0, 0, 0, 0), nr_employed = c(5191, 5191, 5191, 5191, 5191, 
5191)), row.names = c(NA, 6L), class = "data.frame")

I want to transform the numeric variables in data_numeric using boxcox transformation in caret package, in order to solve skewness and identify outliers. R gave me an error

"Error in predict.BoxCoxTrans(bc[[i]], x[, i]) : newdata should be a numeric vector"

Can anyone help me with this?

Add: output of dput(head(data_numeric))



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source