tests/testthat/test-cran-final-example-hardening.R

test_that("major user-facing functions remain exported", {
  ex <- getNamespaceExports("R4VN")
  expect_true(all(c("tabsurv", "tabscore", "tabmachine") %in% ex))
})

test_that("minimal tabscore example remains executable", {
  set.seed(2026)
  n <- 80
  d <- data.frame(
    age = round(rnorm(n, 52, 12)),
    hypertension = factor(rbinom(n, 1, .30), 0:1, c("No", "Yes")),
    smoking = factor(rbinom(n, 1, .25), 0:1, c("No", "Yes"))
  )
  d$event <- rbinom(n, 1, plogis(-3.5 + .04*d$age +
    .8*(d$hypertension == "Yes") + .6*(d$smoking == "Yes")))
  expect_no_error({
    s <- tabscore(
      event, c(age, hypertension, smoking), data = d,
      cuts = list(age = c(40, 55, 70)),
      validate = "none", show = FALSE
    )
  })
  expect_s3_class(s, "r4vn_tabscore")
})

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.