tests/testthat/test-filldown.R

test_that("filldown carries values forward within groups", {
  data <- data.frame(
    id = c(1, 1, 1, 2, 2),
    visit = c(1, 2, 3, 1, 2),
    treatment = c("A", NA, NA, NA, "B")
  )

  out <- filldown(data, cols = "treatment", by = "id")

  expect_s3_class(out, "basetable")
  expect_equal(out$treatment, c("A", "A", "A", NA, "B"))
})

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.