dm (version 0.0.3.9003)

check_if_subset: Test if values of one column are a subset of values of another column

Description

check_if_subset() tests, if the values of the chosen column c1 of data frame t1 are a subset of the values of column c2 of data frame t2.

Usage

check_if_subset(t1, c1, t2, c2)

Arguments

t1

Data frame containing the column c1.

c1

Column of t1 that should only contain values that are also in c2 of data frame t2.

t2

Data frame containing the column c2.

c2

Column of second data frame which has to contain all values of c1 to avoid an error.

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 passing:
check_if_subset(data_1, a, data_2, a)

# this is failing:
try(check_if_subset(data_2, a, data_1, a))
# }

Run the code above in your browser using DataCamp Workspace