# NOT RUN {
# ---------------------------------------------------------------------------
original_names <- colnames(mtcars)
test <- mtcars
bad_test <- test[, -c(3, 4)]
# All good
check_column_names(test, original_names)
# Missing 2 columns
check_column_names(bad_test, original_names)
# Will error
try(validate_column_names(bad_test, original_names))
# ---------------------------------------------------------------------------
# Special error when `.outcome` is missing
train <- iris[1:100,]
test <- iris[101:150,]
train_x <- subset(train, select = -Species)
train_y <- train$Species
# Here, y is a vector
processed <- mold(train_x, train_y)
# So the default column name is `".outcome"`
processed$outcomes
# It doesn't affect forge() normally
forge(test, processed$blueprint)
# But if the outcome is requested, and `".outcome"`
# is not present in `new_data`, an error is thrown
# with very specific instructions
try(forge(test, processed$blueprint, outcomes = TRUE))
# To get this to work, just create an .outcome column in new_data
test$.outcome <- test$Species
forge(test, processed$blueprint, outcomes = TRUE)
# }
Run the code above in your browser using DataLab