tests/testthat/test-getcohort.R

test_that("get.cohort adds cohort columns and handles options", {
  skip_on_cran()
  suppressWarnings(try(data("simdata", package = "fect"), silent = TRUE))
  expect_true(exists("simdata"))
  df <- simdata

  out <- get.cohort(
    data = df,
    D = "D",
    index = c("id", "time"),
    start0 = TRUE,
    drop.always.treat = TRUE
  )

  expect_true(all(c("Cohort", "Time_to_Treatment") %in% names(out)))
  expect_true(all(out$Cohort %in% c("Control", unique(out$Cohort))))
})

Try the fect package in your browser

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

fect documentation built on April 30, 2026, 9:06 a.m.