add_sanity_check: Adds a sanity check to the list of already performed sanity...

Description Usage Arguments Value Examples

View source: R/main.R

Description

Adds a sanity check to the list of already performed sanity checks

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
add_sanity_check(
  fail_vec,
  description = "-",
  counter_meas = "-",
  data,
  data_name = checkmate::vname(x = data),
  example_size = 3,
  param_name = "-",
  call = h_deparsed_sys_call(which = -3),
  fail_callback
)

Arguments

fail_vec

logical vector where TRUE indicates that a fail has happend

description

(optional) of the sanity check. default is "-".

counter_meas

(optional) description of the counter measures that were applied to correct the problems. default is "-".

data

(optional) where the fails were found. Is used to store examples of failures. default is "-".

data_name

(optional) name of the data set that was used. defaults is the name of the object passed to data.

example_size

(optional) number failures to be extracted from the object passed to data. By default 3 random examples are extracted.

param_name

(optional) name of the parameter(s) that is used. This may be helpful for filtering the table of all performed sanity checks.

call

(optional) by default tracks the function that called add_sanity_check.

fail_callback

(optional) user-defined function that is called if any element of fail_vec is TRUE. This is helpful if an additional warning or error should be thrown or maybe a log-entry should be created.

Value

a list with three elements

entry_sanity_table

invisibly the sanity check that is stored internally with the other sanity checks

fail_vec

fail_vec as passed over to this function

fail

TRUE if any element of fail is TRUE. Otherwise FALSE.

All performed sanity checks can be fetched via get_sanity_checks

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
d <- data.frame(person_id = 1:4, bmi = c(18,23,-1,35), age = 31:34)
dummy_call <- function(x) {
  add_sanity_check(
    x$bmi < 15,
    description = "bmi above 15",
    counter_meas = "none",
    data = x,
    param_name = "bmi")
  add_sanity_check(
    x$bmi > 30,
    description = "bmi below 30",
    counter_meas = "none")
}
dummy_call(x = d)
get_sanity_checks()
add_sanity_check(
   d$bmi < 15,
   description = "bmi above 15",
   fail_callback = warning)

sanityTracker documentation built on April 22, 2020, 5:09 p.m.