Setting a data table to an agent or informant with set_tbl() replaces any associated table (a data frame, a tibble, objects of class tbl_dbi or tbl_spark). If a data table is associated with an agent or informant through the tbl argument and the same object has a table-prep formula (settable in create_agent() and create_informant()'s read_fn argument or with set_read_fn()), the table-prep formula will take precedence. If this is undesirable, it be removed with the remove_read_fn() function. The association to a table can be removed with with remove_tbl().

set_tbl(x, tbl)

Arguments

x

An agent object of class ptblank_agent, or, an informant of class ptblank_informant.

tbl

The input table for the agent. This can be a data frame, a tibble, a tbl_dbi object, or a tbl_spark object. Any table already associated with the agent or informant will be overwritten.

Function ID

9-3

See also

Examples

# Set proportional failure thresholds # to the `warn`, `stop`, and `notify` # states using `action_levels()` al <- action_levels( warn_at = 0.10, stop_at = 0.25, notify_at = 0.35 ) # Create an agent that has # `small_table` set as the target # table via `tbl`; apply the actions, # add some validation steps and then # interrogate the data agent_1 <- create_agent( tbl = small_table, tbl_name = "small_table", label = "An example.", actions = al ) %>% col_exists(vars(date, date_time)) %>% col_vals_regex( vars(b), "[0-9]-[a-z]{3}-[0-9]{3}" ) %>% rows_distinct() %>% interrogate() # Replace the agent's association to # `small_table` with a mutated version # of it (one that removes duplicate rows); # then, interrogate the new target table agent_2 <- agent_1 %>% set_tbl( tbl = small_table %>% dplyr::distinct() ) %>% interrogate()