The data frame to compare against.
tidy-select> A set of columns to
A character vector of columns to join by. See
Reverse the results of the check?
data-masking> A filter specifying
a subset of the data frame to test.
A data frame to test. The global test data is used by default.
expect_*() functions are mainly called for their side effects. The
expectation signals its result (e.g. "success", "failure"), which is logged
by the current test reporter. In a non-testing
context the expectation will raise an error with class
expectation_failure if it fails.
expect_valmatch() compares the observations appearing in one data frame
data) to the same observations, as picked out by a key (
by), in another
data frame (
data2). It fails if the selected columns (
vars) aren't the
same for those observations in both data frames.
expect_subset() compares one data frame (
data) to another (
fails if all of the observations in the first, as picked out by a key (
do not appear in the second.
df1 <- data.frame( id = 0:99, binomial = sample(0:1, 100, TRUE), even = abs(0:99%%2 - 1) * 0:99 ) df2 <- data.frame( id = 0:99, binomial = sample(0:1, 100, TRUE), odd = 0:99%%2 *0:99 ) # Check that same records 'succeeded' across data frames try(expect_valmatch(df2, binomial, by = "id", data = df1)) #> Error : The join of `df1` and `df2` by `"id"` has 54 records with a mismatch on variables `binomial`. #> Filter: None #> Comparison: `%==%` # Check that all records in `df1`, as picked out by `id`, exist in `df2` expect_subset(df2, by = "id", data = df1)