Suggest a conditional rule based on a association rule. This functions derives conditional rules based on the non-existance of combinations of categories in pairs of variables. For each numerical variable a logical variable is derived that tests for positivity. It generates IF THEN rules based on two variables.
data.frame, used to generate the checks
character optionally the subset of variables to be used.
file to which the checks will be written to.
suggest_cond_rule returns validate::validator() object with the suggested rules.
write_cond_rule returns invisibly a named list of ranges for each variable.
data(retailers, package="validate")
# will generate check for all columns in retailers that are
# complete.
suggest_na_check(retailers)
#> Object of class 'validator' with 2 elements:
#> NA1: is.complete(size)
#> NA2: is.complete(incl.prob)
data("car_owner")
rules <- suggest_cond_rule(car_owner)
rules$rules
#> [[1]]
#>
#> Object of class rule.
#> expr : if (driver_license == FALSE) owns_car == FALSE
#> name : CR1
#> label :
#> description: conditional rule
#> origin : validatesuggest 0.3.2
#> created : 2023-10-06 10:29:38
#> meta : language<chr>, severity<chr>
#> [[2]]
#>
#> Object of class rule.
#> expr : if (owns_car == TRUE) income > 0
#> name : CR2
#> label :
#> description: conditional rule
#> origin : validatesuggest 0.3.2
#> created : 2023-10-06 10:29:38
#> meta : language<chr>, severity<chr>