tests/testthat/test-mean.R

test_that("xtr_mean", {
  expect_identical(xtr_mean(NA_integer_), NA_real_)
  expect_identical(xtr_mean(integer(0)), NA_real_)
  expect_equal(xtr_mean(1), 1)
  expect_equal(xtr_mean(c(1, 1)), 1)
  expect_equal(xtr_mean(c(1, 2)), 1.5)
  expect_equal(xtr_mean(c(1, 2, NA_real_)), NA_real_)
  expect_equal(xtr_mean(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.