check_subset {dm} R Documentation

Check column values for subset

Description

check_subset() tests if the values of the chosen columns c1 of data frame t1 are a subset of the values of columns c2 of data frame t2.

Usage

check_subset(t1, c1, t2, c2)


Arguments

 t1 The data frame that contains the columns c1. c1 The columns of t1 that should only contain values that are also present in columns c2 of data frame t2. Multiple columns can be chosen using c(col1, col2). t2 The data frame that contains the columns c2. c2 The columns of the second data frame which have to contain all values of c1 to avoid an error. Multiple columns can be chosen using c(col1, col2).

Value

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

Examples

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_subset(data_1, a, data_2, a)

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


[Package dm version 0.2.8 Index]