Learn R Programming

dm (version 0.0.6.9000)

check_set_equality: Test if the value sets of two different columns in two different tables are the same

Description

check_set_equality() is a wrapper of check_subset(). It tests if one value set is a subset of another and vice versa, i.e., if both sets are the same. If not, it throws an error.

Usage

check_set_equality(t1, c1, t2, c2)

Arguments

t1

The data frame that contains column c1.

c1

The column of t1 that should only contain values that are also present in column c2 of data frame t2.

t2

The data frame that contains column c2.

c2

The column of t2 that should only contain values that are also present in column c1 of data frame t1.

Value

Returns t1, invisibly, if the check is passed. Otherwise an error is thrown and the reason for it is explained.

Examples

Run this code
# NOT RUN {
data_1 <- tibble::tibble(a = c(1, 2, 1), b = c(1, 4, 1), c = c(5, 6, 7))
data_2 <- tibble::tibble(a = c(1, 2, 3), b = c(4, 5, 6), c = c(7, 8, 9))
# this is failing:
try(check_set_equality(data_1, a, data_2, a))

data_3 <- tibble::tibble(a = c(2, 1, 2), b = c(4, 5, 6), c = c(7, 8, 9))
# this is passing:
check_set_equality(data_1, a, data_3, a)
# }

Run the code above in your browser using DataLab