# NOT RUN {
# Create a simple table with two
# columns of numerical values
tbl <-
dplyr::tibble(
a = c(5, 7, 6, 5, 8, 7),
b = c(7, 1, 0, 0, 0, 3)
)
# 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(
# tbl = tbl,
# actions = al
# ) %>%
# col_vals_gt(vars(a), 5) %>%
# col_vals_lt(vars(b), 5) %>%
# 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(
# tbl = tbl,
# actions = al
# ) %>%
# col_vals_gt(vars(a), 5) %>%
# col_vals_lt(vars(b), 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(
# tbl = tbl
# ) %>%
# 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