tests/testthat/test-sd.R

test_that("xtr_sd", {
  expect_identical(xtr_sd(NA_integer_), NA_real_)
  expect_identical(xtr_sd(integer(0)), NA_real_)
  expect_equal(xtr_sd(1), NA_real_)
  expect_equal(xtr_sd(c(1, 1)), 0)
  expect_equal(xtr_sd(c(1, 2)), 0.707106781186548)
  expect_equal(xtr_sd(c(1, 2, NA_real_)), NA_real_)
  expect_equal(xtr_sd(c(1, 2, NA_real_), na_rm = TRUE), 0.707106781186548)
})

Try the extras package in your browser

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

extras documentation built on May 31, 2023, 6:22 p.m.