Checks that all elements from the specified columns are not NA

sc_cols_non_NA(object, cols = names(object), ..., unk_cols_callback = stop)

Arguments

object

table with a columns specified by cols

cols

vector of characters of columns that are checked for NAs

...

further parameters that are passed to add_sanity_check.

unk_cols_callback

user-defined function that is called if some of the cols are not contained in the object. This is helpful if an additional warning or error should be thrown or maybe a log-entry should be created. Default is the function stop

Value

a list where every element is an object returned by add_sanity_check for each column specified in cols that exists in object

Examples

iris[c(1,3,5,7,9), 1] <- NA dummy_call <- function(x) { sc_cols_non_NA(object = iris, description = "No NAs expected in iris") } dummy_call(x = iris) get_sanity_checks()
#> description #> 1: bmi above 15 #> 2: bmi below 30 #> 3: bmi above 15 #> 4: - #> 5: - #> 6: - #> 7: - #> 8: Measurements are expected to be bounded from below #> 9: Measurements are expected to be bounded from below #> 10: No NAs expected in iris #> 11: No NAs expected in iris #> 12: No NAs expected in iris #> 13: No NAs expected in iris #> 14: No NAs expected in iris #> additional_desc data_name n n_fail #> 1: - x 4 1 #> 2: - 4 1 #> 3: - 4 1 #> 4: Elements in 'type' should contain only 'b', 'c', 'd'. d 4 1 #> 5: Elements in 'type' should contain only 'b', 'c', 'd'. d 4 1 #> 6: Elements in 'Sepal.Length' should be in [1, 7.9). iris 150 1 #> 7: Elements in 'Petal.Length' should be in [1, 7.9). iris 150 0 #> 8: Elements in 'a' should be in (0.2, Inf). d 4 3 #> 9: Elements in 'b' should be in (0.2, Inf). d 4 0 #> 10: Check that column 'Sepal.Length' does not contain NA iris 150 5 #> 11: Check that column 'Sepal.Width' does not contain NA iris 150 0 #> 12: Check that column 'Petal.Length' does not contain NA iris 150 0 #> 13: Check that column 'Petal.Width' does not contain NA iris 150 0 #> 14: Check that column 'Species' does not contain NA iris 150 0 #> n_na counter_meas #> 1: 0 none #> 2: 0 none #> 3: 0 - #> 4: 0 - #> 5: 0 - #> 6: 0 - #> 7: 0 - #> 8: 0 - #> 9: 0 - #> 10: 0 - #> 11: 0 - #> 12: 0 - #> 13: 0 - #> 14: 0 - #> fail_vec_str #> 1: x$bmi < 15 #> 2: x$bmi > 30 #> 3: d$bmi < 15 #> 4: !(object[[col]] %in% feasible_elements) #> 5: !(object[[col]] %in% feasible_elements) #> 6: sapply(object[[col]], function(x) !checkmate::qtest(x = x, rules = rule)) #> 7: sapply(object[[col]], function(x) !checkmate::qtest(x = x, rules = rule)) #> 8: sapply(object[[col]], function(x) !checkmate::qtest(x = x, rules = rule)) #> 9: sapply(object[[col]], function(x) !checkmate::qtest(x = x, rules = rule)) #> 10: is.na(object[[col]]) #> 11: is.na(object[[col]]) #> 12: is.na(object[[col]]) #> 13: is.na(object[[col]]) #> 14: is.na(object[[col]]) #> 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]> #> 6: Sepal.Length dummy_call(x = d) <data.frame[1x5]> #> 7: Petal.Length dummy_call(x = d) #> 8: a dummy_call(x = d) <data.frame[3x2]> #> 9: b dummy_call(x = d) #> 10: Sepal.Length dummy_call(x = iris) <data.frame[3x5]> #> 11: Sepal.Width dummy_call(x = iris) #> 12: Petal.Length dummy_call(x = iris) #> 13: Petal.Width dummy_call(x = iris) #> 14: Species dummy_call(x = iris)