R/main.R
add_sanity_check.RdAdds a sanity check to the list of already performed sanity checks
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 )
| fail_vec | logical vector where |
|---|---|
| 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 |
| 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 |
a list with three elements
invisibly the sanity check that is stored internally with the other sanity checks
fail_vec as passed over to this function
TRUE if any element of fail is TRUE. Otherwise FALSE.
All performed sanity checks can be fetched via get_sanity_checks
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)#> $entry_sanity_table #> description additional_desc data_name n n_fail n_na counter_meas #> 1: bmi below 30 - 4 1 0 none #> fail_vec_str param_name call #> 1: x$bmi > 30 - dummy_call(x = d) #> #> $fail_vec #> [1] FALSE FALSE FALSE TRUE #> #> $fail #> [1] TRUE #>#> description additional_desc data_name n n_fail n_na counter_meas #> 1: bmi above 15 - x 4 1 0 none #> 2: bmi below 30 - 4 1 0 none #> fail_vec_str param_name call example #> 1: x$bmi < 15 bmi dummy_call(x = d) <data.frame[1x3]> #> 2: x$bmi > 30 - dummy_call(x = d)add_sanity_check( d$bmi < 15, description = "bmi above 15", fail_callback = warning)#> Warning: bmi above 15/-: FAILED#> $entry_sanity_table #> description additional_desc data_name n n_fail n_na counter_meas #> 1: bmi above 15 - 4 1 0 - #> fail_vec_str param_name call #> 1: d$bmi < 15 - eval(expr, envir, enclos) #> #> $fail_vec #> [1] FALSE FALSE TRUE FALSE #> #> $fail #> [1] TRUE #>