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

Object.

.xname

Name of object defined in x. Not intended to be used directly.

.yname

Name of object defined in y. Not intended to be used directly.

Value

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

Note

Updated 2019-08-10.

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: '"c"' has elements not in 'c("a", "b")': c
isSuperset( x = c("Time", "weight", "Diet"), y = colnames(datasets::ChickWeight) )
#> [1] FALSE #> Cause: 'colnames(datasets::ChickWeight)' has elements not in 'c("Time", "weight", "Diet")': Chick
areDisjointSets(x = c("a", "b"), y = c("b", "a"))
#> [1] FALSE #> Cause: 'c("a", "b")' and 'c("b", "a")' have common elements: a, b
areIntersectingSets(x = c("a", "b"), y = c("c", "d"))
#> [1] FALSE #> Cause: 'c("a", "b")' and 'c("c", "d")' have 0 common elements.
areSetEqual(x = c("a", "b"), y = c("b", "c"))
#> [1] FALSE #> Cause: 'x' has elements not in 'y': a