slack_df <- data_frame(x = 0:100)
slack_new_data <- data_frame(x = -10:110)
# this will fail the check both ends
if (FALSE) {
recipe(slack_df) %>%
check_range(x) %>%
prep() %>%
bake(slack_new_data)
}
# this will fail the check only at the upper end
if (FALSE) {
recipe(slack_df) %>%
check_range(x, slack_prop = c(0.1, 0.05)) %>%
prep() %>%
bake(slack_new_data)
}
# give a warning instead of an error
if (FALSE) {
recipe(slack_df) %>%
check_range(x, warn = TRUE) %>%
prep() %>%
bake(slack_new_data)
}
Run the code above in your browser using DataLab