library(dplyr, warn.conflicts = FALSE)
tbl1 <- tribble(
~USUBJID, ~AGE, ~SEX,
"1001", 18, "M",
"1002", 19, "F",
"1003", 20, "M",
"1004", 18, "F"
)
tbl2 <- tribble(
~USUBJID, ~AGE, ~SEX,
"1001", 18, "M",
"1002", 18.9, "F",
"1003", 20, NA
)
try(expect_dfs_equal(tbl1, tbl2, keys = "USUBJID"))
tlb3 <- tribble(
~USUBJID, ~AGE, ~SEX,
"1004", 18, "F",
"1003", 20, "M",
"1002", 19, "F",
"1001", 18, "M",
)
# Note the sorting order of the keys is not required
expect_dfs_equal(tbl1, tlb3, keys = "USUBJID")
Run the code above in your browser using DataLab