tests/testthat/test-zscore.R

test_that("zscore", {
  expect_identical(zscore(NA_integer_), NA_real_)
  expect_identical(zscore(integer(0)), NA_real_)
  expect_equal(zscore(1), NA_real_)
  expect_equal(zscore(c(1, 1)), Inf)
  expect_equal(zscore(c(0, 0)), NaN)
  expect_equal(zscore(0), NA_real_)
  set.seed(101)
  expect_equal(zscore(rnorm(1000, 2)), 2.04891535423035)
  expect_equal(zscore(1:3), 2)
  expect_equal(zscore(c(1:3, NA)), NA_real_)
  expect_equal(zscore(c(1:3, NA), na_rm = TRUE), 2)
})

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.