Learn R Programming

pointblank (version 0.7.0)

get_data_extracts: Collect data extracts from a validation step

Description

In an agent-based workflow, after interrogation with interrogate() we can get the row data that didn't pass row-based validation steps with the get_data_extracts() function. The amount of data available in a particular extract depends on both the fraction of test units that didn't pass a validation step and the level of sampling or explicit collection from that set of units.

The availability of data extracts for each row-based validation step is depends on whether extract_failed is set to TRUE within the interrogate() call (it is by default). The amount of fail rows extracted depends on the collection parameters in interrogate(), and the default behavior is to collect up to the first 5000 fail rows.

Row-based validation steps are based on the validation functions of the form col_vals_*() and also include conjointly() and rows_distinct(). Only those types of validation steps can provide data extracts.

Usage

get_data_extracts(agent, i = NULL)

Arguments

agent

An agent object of class ptblank_agent. It should have had interrogate() called on it, such that the validation steps were carried out and any sample rows from non-passing validations could potentially be available in the object.

i

The validation step number, which is assigned to each validation step in the order of definition. If NULL (the default), all data extract tables will be provided in a list object.

Value

A list of tables if i is not provided, or, a standalone table if i is given.

Function ID

8-2

See Also

Other Post-interrogation: all_passed(), get_agent_x_list(), get_sundered_data(), write_testthat_file()

Examples

Run this code
# NOT RUN {
# Create a simple table with a
# column of numerical values
tbl <- 
  dplyr::tibble(a = c(5, 7, 8, 5))

# Create 2 simple validation steps
# that test whether values within
# column `a`
agent <-
  create_agent(tbl = tbl) %>%
  col_vals_between(vars(a), 4, 6) %>%
  col_vals_lte(vars(a), 7) %>%
  interrogate(
    extract_failed = TRUE,
    get_first_n = 10
  )

# Get row sample data for those rows
# in `tbl` that did not pass the first
# validation step (`col_vals_between`)
agent %>% get_data_extracts(i = 1)

# }

Run the code above in your browser using DataLab