# NOT RUN {
# Create an `action_levels()` list
# with fractional values for the
# `warn`, `stop`, and `notify` states
al <-
action_levels(
warn_at = 0.2,
stop_at = 0.8,
notify_at = 0.5
)
# Use the included `small_table` dataset
# for the validation example
small_table
# Validate that values in column
# `a` are always greater than `2` and
# apply the list of action levels (`al`)
agent <-
create_agent(tbl = small_table) %>%
col_vals_gt(vars(a), 2, actions = al) %>%
interrogate()
# The report from the agent will show
# that the `warn` state has been entered
# for the first and only validation step;
# Let's look at the *tibble* version of the
# agent report (accessible through the use
# of the `get_agent_report()` function)
agent %>%
get_agent_report(display_table = FALSE)
# In the context of using validation
# functions directly on data, their
# use is commonly to trigger warnings
# and raise errors. The following *will*
# provide a warning (but that's
# suppressed here) and the `small_table`
# data will be returned
suppressWarnings(
small_table %>%
col_vals_gt(vars(a), 2, actions = al)
)
# }
Run the code above in your browser using DataLab