tests/testthat/test-median.R

test_that("xtr_median", {
  expect_identical(xtr_median(NA_integer_), NA_real_)
  expect_identical(xtr_median(integer(0)), NA_real_)
  expect_equal(xtr_median(1), 1)
  expect_equal(xtr_median(c(1, 1)), 1)
  expect_equal(xtr_median(c(1, 2)), 1.5)
  expect_equal(xtr_median(c(1, 2, 10)), 2)
  expect_equal(xtr_median(c(1, 2, NA_real_)), NA_real_)
  expect_equal(xtr_median(c(1, 2, NA_real_), na_rm = TRUE), 1.5)
})

Try the extras package in your browser

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

extras documentation built on Aug. 5, 2021, 9:07 a.m.