Stop the script if any problem found
Usage
action_if_problem(x, message_text, problem_action = c("stop", "warning"))
Arguments
- x
A list containing the summary from
validate_rules()
.- message_text
The message to display when applying the action.
- problem_action
Select if you want to display warning or stop the code.
Examples
try({
validate_rules(mtcars, "hp high" = hp < 200) |>
action_if_problem("Here is the error", "stop")
})
#> [1] "Here is the error"
#> name items passes fails nNA error warning
#> <char> <int> <int> <int> <int> <lgcl> <lgcl>
#> 1: hp.high 32 25 7 0 FALSE FALSE
#> Error in action_if_problem(validate_rules(mtcars, `hp high` = hp < 200), :
#> Here is the error
validate_rules(mtcars, "hp high" = hp < 200) |>
action_if_problem("Here is the warning", "warning")
#> [1] "Here is the warning"
#> name items passes fails nNA error warning
#> <char> <int> <int> <int> <int> <lgcl> <lgcl>
#> 1: hp.high 32 25 7 0 FALSE FALSE
#> Warning: Here is the warning