same_content {midfieldr} | R Documentation |
Test for equal content between two data tables
Description
Test of data equality between data.table objects. Convenience function used in 'midfieldr' articles.
Usage
same_content(x, y)
Arguments
x |
Data frame to be compared. Same as |
y |
Data frame to be compared. Same as |
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)
Value
Either TRUE or a description of the differences between x
and y
.
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)
# Different number of rows
x <- toy_student[1:10]
y <- toy_student[1:11]
same_content(x, y)
# Different column names
x <- toy_student[, .(mcid)]
y <- toy_student[, .(institution)]
same_content(x, y)
# Different number of columns and column names
x <- toy_student[, .(mcid)]
y <- toy_student[, .(mcid, institution)]
same_content(x, y)
# Different number of rows, number of columns, and column names
x <- toy_student
y <- toy_term
same_content(x, y)
# Different row content
x <- toy_student[1:10]
y <- toy_student[2:11]
same_content(x, y)
[Package midfieldr version 1.0.2 Index]