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

act_after_exposure(.tbl, .trigger, .actor)



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


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


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


Basically act_after_exposure() is doing the following:

  • Check that .tbl has a proper exposure attribute.

  • Compute whether to perform intended action by computing .trigger(.tbl).

  • If trigger results in TRUE then .actor(.tbl) is returned. In other case .tbl is returned.

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

  • Making side effects. For example throwing an error (if condition in .trigger is met), printing some information and so on. In this case it should return .tbl to be used properly inside a pipe.

  • Changing .tbl based on exposure information. In this case it should return the imputed version of .tbl.

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.


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)
#> Exposure #> #> Packs info: #> # A tibble: 1 x 4 #> name type fun remove_obeyers #> <chr> <chr> <list> <lgl> #> 1 data_pack__1 data_pack <data_pck> TRUE #> #> Tidy data validation report: #> # A tibble: 1 x 5 #> pack rule var id value #> <chr> <chr> <chr> <int> <lgl> #> 1 data_pack__1 nrow_low .all 0 FALSE