act_after_exposure {ruler}R Documentation

Act after exposure

Description

A wrapper for consistent application of some actions based on the data after exposure.

Usage

act_after_exposure(.tbl, .trigger, .actor)

Arguments

.tbl

Result of exposure, i.e. data frame with exposure attribute.

.trigger

Function which takes .tbl as argument and returns TRUE if some action needs to be performed.

.actor

Function which takes .tbl as argument and performs the action.

Details

Basically act_after_exposure() is doing the following:

It is a good idea that .actor should be doing one of two things:

See Also

any_breaker for trigger which returns TRUE in case any rule breaker is found in exposure.

assert_any_breaker for usage of act_after_exposure() in building data validation pipelines.

Examples

exposure_printer <- function(.tbl) {
  print(get_exposure(.tbl))
  .tbl
}
mtcars_exposed <- mtcars %>%
  expose(data_packs(. %>% dplyr::summarise(nrow_low = nrow(.) > 50))) %>%
  act_after_exposure(any_breaker, exposure_printer)

[Package ruler version 0.3.0 Index]