all.equal.data.table: Equality Test Between Two Data Tables

Description Usage Arguments Details Value See Also Examples

Description

Performs some factor level “stripping” and other operations to allow for a convenient test of data equality between data.table objects.

Usage

1
2
  ## S3 method for class 'data.table'
all.equal(target, current, trim.levels = TRUE, ...)

Arguments

target, current

data.tables to compare

trim.levels

A logical indicating whether or not to remove all unused levels in columns that are factors before running equality check.

...

Passed down to internal call of all.equal.list

Details

This function is used primarily to make life easy with a testing harness built around test_that. A call to test_that::(expect_equal|equal) will ultimately dispatch to this method when making an "equality" check.

Value

Either TRUE or a vector of mode "character" describing the differences between target and current.

See Also

all.equal.list

Examples

1
2
3
4
  dt1 <- data.table(A = letters[1:10], X = 1:10, key = "A")
  dt2 <- data.table(A = letters[5:14], Y = 1:10, key = "A")
  identical(all.equal(dt1, dt1), TRUE)
  is.character(all.equal(dt1, dt2))

Example output

[1] TRUE
[1] TRUE

data.table documentation built on May 2, 2019, 4:57 p.m.