tests/testthat/test-calculate_rr.R

test_that("relative risk is returned in the correct format", {
  rr <- calculate_rr(risk_measures)
  expect_type(rr, "double")
})

test_that("relative risk is calculated correctly from sample data", {
  expect_equal(
    round(calculate_rr(risk_measures), digits = 3),
    c(Intervention_1 = -0.913)
  )
})

test_that("error if Dt is not the same length as the number of time steps", {
  expect_error(
    calculate_rr(risk_measure_int1),
    class = "risk_list_length"
  )
})

Try the DUToolkit package in your browser

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

DUToolkit documentation built on Sept. 14, 2025, 5:09 p.m.