tests/testthat/test-set-rows.R

test_that("intersectrows keeps x rows whose key is present in y", {
  x <- data.frame(id = c(1, 2, 3), value = c("a", "b", "c"))
  y <- data.frame(id = c(2, 3, 4))

  out <- intersectrows(x, y, by = "id")
  expect_setequal(out$id, c(2, 3))
})

test_that("diffrows keeps x rows whose key is absent from y", {
  x <- data.frame(id = c(1, 2, 3), value = c("a", "b", "c"))
  y <- data.frame(id = c(2, 3, 4))

  out <- diffrows(x, y, by = "id")
  expect_equal(out$id, 1)
})

Try the basetable package in your browser

Any scripts or data that you put into this service are public.

basetable documentation built on Sept. 18, 2026, 9:13 a.m.