set.seed(313)
examples <- matrix(exp(rnorm(40)), ncol = 2)
examples <- as.data.frame(examples)
rec <- recipe(~ V1 + V2, data = examples)
log_trans <- rec %>%
step_log(all_numeric_predictors())
log_obj <- prep(log_trans, training = examples)
transformed_te <- bake(log_obj, examples)
plot(examples$V1, transformed_te$V1)
tidy(log_trans, number = 1)
tidy(log_obj, number = 1)
# using the signed argument with negative values
examples2 <- matrix(rnorm(40, sd = 5), ncol = 2)
examples2 <- as.data.frame(examples2)
recipe(~ V1 + V2, data = examples2) %>%
step_log(all_numeric_predictors()) %>%
prep(training = examples2) %>%
bake(examples2)
recipe(~ V1 + V2, data = examples2) %>%
step_log(all_numeric_predictors(), signed = TRUE) %>%
prep(training = examples2) %>%
bake(examples2)
Run the code above in your browser using DataLab