tests/testthat/test-disp_DKL.R

test_that("standardization returns dispersion scores in the unit interval [0,1]", {
  
  expect_true(round(
    disp_DKL(
      c(0,0,0,0,0,0,0,0,0,10), 
      rep(1000, 10),
      standardization = "o2p"), 10) >= 0)

  expect_true(round(
    disp_DKL(
      rep(1, 10), 
      rep(1000, 10),
      standardization = "o2p"), 10) <= 1)
  
  
  expect_true(round(
    disp_DKL(
      c(0,0,0,0,0,0,0,0,0,10), 
      rep(1000, 10),
      standardization = "base_e"), 10) >= 0)

  expect_true(round(
    disp_DKL(
      rep(1, 10), 
      rep(1000, 10),
      standardization = "base_e"), 10) <= 1)
  
  
  expect_true(round(
    disp_DKL(
      c(0,0,0,0,0,0,0,0,0,10), 
      rep(1000, 10),
      standardization = "base_2"), 10) >= 0)

  expect_true(round(
    disp_DKL(
      rep(1, 10), 
      rep(1000, 10),
      standardization = "base_2"), 10) <= 1)
})

Try the tlda package in your browser

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

tlda documentation built on June 8, 2025, 11:41 a.m.