Learn R Programming

pointblank (version 0.7.0)

remove_tbl: Remove a data table associated with an agent or informant

Description

Removing an agent or informant's association to a data table can be done with the remove_tbl() function. This can be useful to ensure that the table data isn't unintentionally written to disk. It is usually best to avoid directly associating a table to an agent or informant through the tbl argument, instead opting for setting a table-prep formula (via create_agent() and create_informant()'s read_fn argument, or, with set_read_fn()). If necessary, the association to a table can be set again with set_tbl().

Usage

remove_tbl(x)

Arguments

x

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

Function ID

9-4

See Also

Other Object Ops: activate_steps(), deactivate_steps(), remove_read_fn(), remove_steps(), set_read_fn(), set_tbl(), x_read_disk(), x_write_disk()

Examples

Run this code
# NOT RUN {
# 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()
  
# In this case where `small_table`
# changes (and the aim is to have
# validations run periodically) it is
# better to obtain the table from the
# source with a table-prep formula;
# while doing this, the direct
# association to `small_table` can be
# removed with `remove_tbl()` so it's
# no longer part of the agent object
agent_2 <-
  agent_1 %>%
  remove_tbl() %>%
  set_read_fn(read_fn = ~ small_table) %>%
  interrogate()
  
# }

Run the code above in your browser using DataLab