I have a question regarding the bake
function. My dataset consists of 2 variables: the dependent CHURN_FLAG and the independent amount of resources MT_RESOURCES.
When I perform the bake
function, I get this error:
"Error in select(., -CHURN_FLAG) : unused argument (-CHURN_FLAG)"
This is the code I use:
MT_RESOURCES <- c(10, 20, 34, 5, 20, 9, 10, 60, 5, 1)
CHURN_FLAG <- c("YES","YES","YES","NO","YES","NO","YES","YES","NO","NO")
ddata <- data.frame(MT_RESOURCES, CHURN_FLAG)
glimpse(ddata)
Output:
Rows: 10 Columns: 2 $ MT_RESOURCES <dbl> 10, 20, 34, 49, 20, 44, 10, 60, 44, 1 $ CHURN_FLAG <chr> "YES", "NO", "YES", "YES", "NO", "NO", "NO", "YES", "NO", "NO"
Code:
rec_obj <- recipe(CHURN_FLAG ~ ., data = ddata) %>%
step_center(all_predictors(), -all_outcomes()) %>%
step_scale(all_predictors(), -all_outcomes()) %>%
prep(data = ddata)
Output:
role #variables outcome 1 predictor 1
Training data contained 10 data points and no missing data.
Operations:
- Centering for MT_RESOURCES [trained]
- Scaling for MT_RESOURCES [trained]
Code:
x_ddata <- bake(rec_obj, newdata = ddata) %>% select(-CHURN_FLAG)
Output:
Error in select(., -CHURN_FLAG) : unused argument (-CHURN_FLAG)
CodePudding user response:
You may have another package like MASS masking the Select function. Try specify the package the function comes from.
dplyr::select(-CHURN_FLAG)
CodePudding user response:
You need new_data
with the underscore.