Set comparisons

isSubset(x, y, .xname = getNameInParent(x),
  .yname = getNameInParent(y))

isSuperset(x, y, .xname = getNameInParent(x),
  .yname = getNameInParent(y))

areDisjointSets(x, y, .xname = getNameInParent(x),
  .yname = getNameInParent(y))

areIntersectingSets(x, y, .xname = getNameInParent(x),
  .yname = getNameInParent(y))

areSetEqual(x, y, .xname = getNameInParent(x),
  .yname = getNameInParent(y))

Arguments

x

Object.

y

Secondary object.

.xname

Not intended to be used directly.

.yname

Not intended to be used directly.

Value

TRUE on success; FALSE on failure, with cause attribute set.

See also

Examples

## TRUE ==== isSubset(x = "a", y = c("a", "b"))
#> [1] TRUE
## This assert is particularly useful for checking required columns. isSuperset( x = colnames(datasets::ChickWeight), y = c("Time", "weight", "Diet") )
#> [1] TRUE
areDisjointSets(x = c("a", "b"), y = c("c", "d"))
#> [1] TRUE
areIntersectingSets(x = c("a", "b"), y = c("b", "c"))
#> [1] TRUE
areSetEqual(x = c("a", "b"), y = c("b", "a"))
#> [1] TRUE
## FALSE ==== isSubset(x = "c", y = c("a", "b"))
#> [1] FALSE #> Cause of failure: #> "c" has elements not in c("a", "b"): c
isSuperset( x = c("Time", "weight", "Diet"), y = colnames(datasets::ChickWeight) )
#> [1] FALSE #> Cause of failure: #> colnames(datasets::ChickWeight) has elements not in c("Time", "weight", "Diet"): Chick
areDisjointSets(x = c("a", "b"), y = c("b", "a"))
#> [1] FALSE #> Cause of failure: #> c("a", "b") and c("b", "a") have common elements: a, b
areIntersectingSets(x = c("a", "b"), y = c("c", "d"))
#> [1] FALSE #> Cause of failure: #> c("a", "b") and c("c", "d") have no common elements.
areSetEqual(x = c("a", "b"), y = c("b", "c"))
#> [1] FALSE #> Cause of failure: #> x has elements not in y: a