tests/testthat/test-rollingmerge.R

test_that("rollingmerge joins using a rolling key", {
  x <- data.frame(id = c(1, 1, 1), time = c(5, 10, 15))
  y <- data.frame(id = c(1, 1, 1), time = c(3, 8, 14), value = c("a", "b", "c"))

  out <- rollingmerge(x, y, by = c("id", "time"), direction = "backward")

  expect_s3_class(out, "basetable")
  expect_true("value" %in% names(out))
  expect_equal(out$value, c("a", "b", "c"))
})

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.