Skip to contents

Set comparisons

Usage

isSubset(x, y)

isSuperset(x, y)

areDisjointSets(x, y)

areIntersectingSets(x, y)

areSetEqual(x, y)

Arguments

x

Object.

y

Object.

Value

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

Note

Updated 2023-10-02.

See also

  • assertive.sets::is_subset().

  • assertive.sets::is_superset().

  • assertive.sets::are_disjoint_sets().

  • assertive.sets::are_intersecting_sets().

  • assertive.sets::are_set_equal().

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
isSuperset(
    x = c("Time", "weight", "Diet"),
    y = colnames(datasets::ChickWeight)
)
#> [1] FALSE

areDisjointSets(x = c("a", "b"), y = c("b", "a"))
#> [1] FALSE
areIntersectingSets(x = c("a", "b"), y = c("c", "d"))
#> [1] FALSE
areSetEqual(x = c("a", "b"), y = c("b", "c"))
#> [1] FALSE