tbl_equal: Check that the rows and columns of two tables are the same

View source: R/tbl_equal.R

tbl_equalR Documentation

Check that the rows and columns of two tables are the same

Description

Test if two tables are equivalent using the same process as tbl_check(). Unlike tbl_check(), which returns either a problem object or NULL, tbl_equal() returns either TRUE or FALSE.

Usage

tbl_equal(
  object = .result,
  expected = .solution,
  cols = NULL,
  check_class = TRUE,
  ignore_class = NULL,
  check_names = TRUE,
  check_column_order = FALSE,
  check_dimensions = TRUE,
  check_groups = TRUE,
  check_columns = TRUE,
  check_column_class = check_columns,
  check_column_levels = check_columns,
  check_column_values = check_columns,
  tolerance = sqrt(.Machine$double.eps),
  check_row_order = check_columns,
  env = parent.frame()
)

Arguments

object

A data frame to be compared to expected.

expected

A data frame containing the expected result.

cols

[tidy-select]
A selection of columns to compare between object and expected. Differences in other columns will be ignored. If NULL, the default, all columns will be checked.

check_class

[logical(1)]
Whether to check that object and expected have the same classes with tbl_check_class().

ignore_class

[character()]
A vector of classes to ignore when finding differences between object and expected.

If an element is named, differences will only be ignored between the pair of the element and its name. For example, ignore_class = c("integer" = "numeric") will ignore class differences only if object has class integer and expected has class numeric, or vice versa.

If all the classes of expected are included in ignore_class, a class problem will never be returned.

check_names

[logical(1)]
Whether to check that object and expected have the same column names with tbl_check_names().

check_column_order

[logical(1)]
Whether to check that the columns of object are in the same order as expected with tbl_check_names(). Defaults to FALSE.

check_dimensions

[logical(1)]
Whether to check that object and expected have the same number of rows and columns with tbl_check_dimensions().

check_groups

[logical(1)]
Whether to check that object and expected have the same groups with dplyr::group_vars().

check_columns

[logical(1)]
Whether to check that all columns have the same contents with tbl_check_column().

check_column_class

[logical(1)]
Whether to check that each column has the same class in object and expected.

check_column_levels

[logical(1)]
Whether to check that each column has the same factor levels in object and expected.

check_column_values

[logical(1)]
Whether to check that each column has the same values in object and expected.

tolerance

[numeric(1) ≥ 0]
values differences smaller than tolerance are ignored. The default value is close to 1.5e-8.

check_row_order

[logical(1)]
Whether to check that the values in each column are in the same order in object and expected.

env

The environment in which to find .result and .solution.

Value

A TRUE or FALSE value.

Examples

tbl_equal(
	data.frame(a = 1:10, b = 11:20),
	data.frame(b = 11:20, a = 1:10)
)

rstudio/tblcheck documentation built on March 11, 2023, 5:42 p.m.