Test of data equality between data.table objects. Convenience function used in package articles.
Arguments
- x
Data frame to be compared. Same as
target
argument inall.equal()
- y
Data frame to be compared. Same as
current
argument inall.equal()
Details
Wrapper around all.equal()
for class data.table that ignores row order,
column order, and data.table keys. Both inputs must be date frames.
Equivalent to:
all.equal(target, current, ignore.row.order = TRUE, ignore.col.order =
TRUE)
Examples
# Same information and ignore row order, column order
x <- toy_student[order(mcid), .(mcid, institution)]
y <- toy_student[order(institution), .(institution, mcid)]
same_content(x, y)
#> [1] TRUE
# Different number of rows
x <- toy_student[1:10]
y <- toy_student[1:11]
same_content(x, y)
#> [1] "Different number of rows"
# Different column names
x <- toy_student[, .(mcid)]
y <- toy_student[, .(institution)]
same_content(x, y)
#> [1] "Different column names"
# Different number of columns and column names
x <- toy_student[, .(mcid)]
y <- toy_student[, .(mcid, institution)]
same_content(x, y)
#> [1] "Different number of columns" "Different column names"
# Different number of rows, number of columns, and column names
x <- toy_student
y <- toy_term
same_content(x, y)
#> [1] "Different number of rows" "Different number of columns"
#> [3] "Different column names"
# Different row content
x <- toy_student[1:10]
y <- toy_student[2:11]
same_content(x, y)
#> [1] "Dataset 'current' has rows not present in 'target'"