A table-prep formula can be associated with an agent or informant with set_read_fn(). Should both a tbl and a read_fn be associated with the agent or informant, the read_fn will take priority. We can specify a value for read_fn with an RHS formula expression (e.g., ~ { <table reading code> }). The table-prep formula can removed with remove_read_fn() or replaced with set_read_fn().

set_read_fn(x, read_fn)

Arguments

x

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

read_fn

An R formula expression (e.g., ~ { <table reading code> }) that is used to prepare a table.

Function ID

9-5

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 reads in # `small_table` with a table-prep # formula; apply the actions, # add some validation steps and then # interrogate the data agent_1 <- create_agent( read_fn = ~ 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() # Change the table-prep formula to use # a mutated version of `small_table` # (one that removes duplicate rows); # then, interrogate the target table # again agent_2 <- agent_1 %>% set_read_fn( read_fn = ~ small_table %>% dplyr::distinct() ) %>% interrogate()