% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assert-is-set.R, R/is-set.R
\name{assert_are_disjoint_sets}
\alias{are_disjoint_sets}
\alias{are_intersecting_sets}
\alias{are_set_equal}
\alias{assert_are_disjoint_sets}
\alias{assert_are_intersecting_sets}
\alias{assert_are_set_equal}
\alias{assert_is_set_equal}
\alias{assert_is_subset}
\alias{assert_is_superset}
\alias{is_set_equal}
\alias{is_subset}
\alias{is_superset}
\title{Set comparisons}
\usage{
assert_are_disjoint_sets(x, y, severity = getOption("assertive.severity",
  "stop"))

assert_are_intersecting_sets(x, y, severity = getOption("assertive.severity",
  "stop"))

assert_are_set_equal(x, y, severity = getOption("assertive.severity", "stop"))

assert_is_set_equal(x, y, severity = getOption("assertive.severity", "stop"))

assert_is_subset(x, y, strictly = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_is_superset(x, y, strictly = FALSE,
  severity = getOption("assertive.severity", "stop"))

are_disjoint_sets(x, y, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(y))

are_intersecting_sets(x, y, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(y))

are_set_equal(x, y, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(y))

is_set_equal(x, y, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(y))

is_subset(x, y, strictly = FALSE, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(y))

is_superset(x, y, strictly = FALSE, .xname = get_name_in_parent(x),
  .yname = get_name_in_parent(y))
}
\arguments{
\item{x}{A vector.}

\item{y}{Another vector.}

\item{severity}{How severe should the consequences of the assertion be?
Either \code{"stop"}, \code{"warning"}, \code{"message"}, or \code{"none"}.}

\item{strictly}{Logical.  If \code{TRUE}, \code{x} and \code{y} should not
be set equal.}

\item{.xname}{Not intended to be used directly.}

\item{.yname}{Not intended to be used directly.}
}
\value{
The \code{is_*} functions return \code{TRUE} or \code{FALSE}.
The \code{assert_*} functions throw an error in the event of failure.
}
\description{
Checks on the contents of two vectors (ignoring the order of the elements).
}
\examples{
# Same contents, different order, returns TRUE
are_set_equal(1:5, 5:1)

# Different lengths
are_set_equal(1:5, 1:6)

# First vector contains values not in second vector
are_set_equal(1:5, c(1:4, 4))

# Second vector contains values not in first vector
are_set_equal(c(1:4, 4), 1:5)

# Is x a subset of y?
is_subset(1:4, 1:5)
is_subset(1:5, 1:4)

# Is x a superset of y?
is_superset(1:5, 1:4)
is_superset(1:4, 1:5)

# The strictly argument checks for a strict sub/superset
is_subset(1:5, 1:5, strictly = TRUE)
is_superset(1:5, 1:5, strictly = TRUE)

# Do x and y have common elements?
are_intersecting_sets(1:4, 3:6)
are_disjoint_sets(1:4, 3:6)

# Types are coerced to be the same, as per base::setdiff
are_set_equal(1:4, c("4", "3", "2", "1"))

# Errors are thrown in the event of failure
assert_are_set_equal(1:5, 5:1)
assertive.base::dont_stop(assert_are_set_equal(1:5, 1:6))

assert_is_subset(1:4, 1:5)
assertive.base::dont_stop(assert_is_subset(1:5, 1:4))

assert_is_superset(1:5, 1:4)
assertive.base::dont_stop(assert_is_superset(1:4, 1:5))

# A common use case: checking that data contains required columns
required_cols <- c("Time", "weight", "Diet")
assert_is_superset(colnames(ChickWeight), required_cols)
}
\seealso{
\code{\link[base]{sets}}, \code{\link[sets]{set_is_equal}}
}

