Checks that the elements of a column belong to a certain set

sc_col_elements(object, col, feasible_elements, ...)

Arguments

object

table with a column specified by col

col

name as a character of the column which is checked

feasible_elements

vector with characters that are feasible for col. Note that an element that is NA it is always counted as a fail if feasible_elements does not explicitly contains NA.

...

further parameters that are passed to add_sanity_check.

Value

see return object of add_sanity_check

Examples

d <- data.frame(type = letters[1:4], nmb = 1:4) dummy_call <- function(x) { sc_col_elements(object = d, col = "type", feasible_elements = letters[2:4]) } dummy_call(x = d) get_sanity_checks()
#> description additional_desc data_name #> 1: bmi above 15 - x #> 2: bmi below 30 - #> 3: bmi above 15 - #> 4: - Elements in 'type' should contain only 'b', 'c', 'd'. d #> 5: - Elements in 'type' should contain only 'b', 'c', 'd'. d #> n n_fail n_na counter_meas fail_vec_str #> 1: 4 1 0 none x$bmi < 15 #> 2: 4 1 0 none x$bmi > 30 #> 3: 4 1 0 - d$bmi < 15 #> 4: 4 1 0 - !(object[[col]] %in% feasible_elements) #> 5: 4 1 0 - !(object[[col]] %in% feasible_elements) #> param_name call example #> 1: bmi dummy_call(x = d) <data.frame[1x3]> #> 2: - dummy_call(x = d) #> 3: - eval(expr, envir, enclos) #> 4: type eval(expr, envir, enclos) <data.frame[1x2]> #> 5: type dummy_call(x = d) <data.frame[1x2]>