# NOT RUN {
if (interactive()) {
# Create an `action_levels()` list
# with absolute values for the
# `warn`, and `notify` states (with
# thresholds of 1 and 2 'fail' units)
al <-
action_levels(
warn_at = 1,
notify_at = 2
)
# In a workflow that involves an
# `agent` object, we can make use of
# the `end_fns` argument and
# programmatically email the report
# with the `email_blast()` function,
# however, an alternate workflow is to
# produce the email object and choose
# to send outside of the pointblank API;
# the `email_create()` function lets
# us do this with an `agent` object
email_object_1 <-
create_agent(
read_fn = ~ small_table,
tbl_name = "small_table",
label = "An example.",
actions = al
) %>%
col_vals_gt(vars(a), value = 1) %>%
col_vals_lt(vars(a), value = 7) %>%
interrogate() %>%
email_create()
# We can view the HTML email just
# by printing `email_object`; it
# should appear in the Viewer
# The `email_create()` function can
# also be used on an agent x-list to
# get the same email message object
email_object_2 <-
create_agent(
read_fn = ~ small_table,
tbl_name = "small_table",
label = "An example.",
actions = al
) %>%
col_vals_gt(vars(a), value = 5) %>%
col_vals_lt(vars(b), value = 5) %>%
interrogate() %>%
get_agent_x_list() %>%
email_create()
# An information report that's
# produced by the informant can
# made into an email message object;
# let's create an informant and use
# `email_create()`
email_object_3 <-
create_informant(
read_fn = ~ small_table,
tbl_name = "small_table",
label = "An example."
) %>%
info_tabular(
info = "A simple table in the
*Examples* section of the function
called `email_create()`."
) %>%
info_columns(
columns = vars(a),
info = "Numbers. On the high side."
) %>%
info_columns(
columns = vars(b),
info = "Lower numbers. Zeroes, even."
) %>%
incorporate() %>%
email_create()
}
# }
Run the code above in your browser using DataLab