tests/testthat/test-tablong-example-data.R

test_that("tablong documented repeated example data are self-contained", {
  set.seed(12)
  n_subject <- 12
  d <- expand.grid(
    id = seq_len(n_subject),
    visit = factor(c("Baseline", "Month 6"),
                   levels = c("Baseline", "Month 6"))
  )
  d <- d[order(d$id, d$visit), ]
  d$treatment <- factor(
    rep(sample(c("Control", "Intervention"), n_subject, TRUE), each = 2)
  )
  d$score <- rnorm(nrow(d))
  expect_true(all(c("id", "visit", "treatment", "score") %in% names(d)))
})

Try the R4VN package in your browser

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

R4VN documentation built on Sept. 30, 2026, 5:13 p.m.