Skip to content

Commit d67c7fe

Browse files
committed
updating stuff
1 parent b8bff29 commit d67c7fe

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
* added a fix when categorical variables where used, without a rule that specified the domain. (issue #15) Thanks to
44
Romina Filippini and Simona Toti for reporting.
55

6+
* added a new function `detect_contradicting_if_rules`. (issue #16)
7+
It detects all rules that are not satisfiable together with the if condition.
8+
Thanks to Romina Filippini and Simona Toti for the suggestion.
9+
10+
* fix for `is_contradicted_by` and `detect_infeasible_rules` when the rules contained
11+
if statements.
12+
613
# validatetools 0.5.2
714

815
* Added fix for change `is.atomic(NULL)==FALSE` in R 4.3.2

README.Rmd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ make_feasible(rules)
6767
is_contradicted_by(rules, "rule1")
6868
```
6969

70+
### Finding contradicting if rules
71+
72+
73+
```{r}
74+
rules <- validator(
75+
if (nace == "a") export == "y",
76+
if (nace == "a") export == "n"
77+
)
78+
79+
conflicts <- detect_contradicting_if_rules(rules, verbose=TRUE)
80+
```
81+
82+
83+
```{r}
84+
print(conflicts)
85+
```
86+
7087
## Simplifying
7188

7289
The function `simplify_rules` combines most simplification methods of `validatetools` to simplify a rule set.

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11

22
<!-- README.md is generated from README.Rmd. Please edit that file -->
3+
34
<!-- badges: start -->
45

56
[![R-CMD-check](https://github.com/data-cleaning/validatetools/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/data-cleaning/validatetools/actions/workflows/R-CMD-check.yaml)
67
[![CRAN
78
status](https://www.r-pkg.org/badges/version/validatetools)](https://CRAN.R-project.org/package=validatetools)
8-
[![codecov](https://codecov.io/github/data-cleaning/validatetools/graph/badge.svg?token=3tIe5HAUWm)](https://codecov.io/github/data-cleaning/validatetools)
9-
[![status](https://tinyverse.netlify.app/badge/validatetools)](https://CRAN.R-project.org/package=validatetools)
109
[![Mentioned in Awesome Official
1110
Statistics](https://awesome.re/mentioned-badge.svg)](http://www.awesomeofficialstatistics.org)
11+
[![Codecov test
12+
coverage](https://codecov.io/gh/data-cleaning/validatetools/graph/badge.svg)](https://app.codecov.io/gh/data-cleaning/validatetools)
1213
<!-- badges: end -->
1314

1415
# validatetools
1516

1617
`validatetools` is a utility package for managing validation rule sets
1718
that are defined with `validate`. In production systems validation rule
18-
sets tend to grow organically and validatetools redundant or (partially)
19+
sets tend to grow organically and accumulate redundant or (partially)
1920
contradictory rules. `validatetools` helps to identify problems with
2021
large rule sets and includes simplification methods for resolving
2122
issues.
@@ -70,6 +71,27 @@ is_contradicted_by(rules, "rule1")
7071
#> [1] "rule2"
7172
```
7273

74+
### Finding contradicting if rules
75+
76+
``` r
77+
rules <- validator(
78+
if (nace == "a") export == "y",
79+
if (nace == "a") export == "n"
80+
)
81+
82+
conflicts <- detect_contradicting_if_rules(rules, verbose=TRUE)
83+
#> 1 contradiction(s) with if clauses found:
84+
#> When nace == "a":
85+
#> V1: if (nace == "a") export == "y"
86+
#> V2: if (nace == "a") export == "n"
87+
```
88+
89+
``` r
90+
print(conflicts)
91+
#> $`nace == "a"`
92+
#> [1] "V1" "V2"
93+
```
94+
7395
## Simplifying
7496

7597
The function `simplify_rules` combines most simplification methods of

examples/detect_contradicting_if_rules.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ rules <- validator(
33
if (nace == "a") export == "n"
44
)
55

6-
detect_contradicting_if_rules(rules)
6+
conflicts <- detect_contradicting_if_rules(rules)
7+
8+
print(conflicts)
9+
10+

0 commit comments

Comments
 (0)