tests/testthat/test-length_omit_na.R

test_that("length_omit_na() counts only non-missing elements of a vector", {
  expect_equal(length_omit_na(c("Nigeria", "South Africa", "Kenya", NA, "Rwanda")), 4)
  expect_equal(length(c("Nigeria", "South Africa", "Kenya", NA, "Rwanda")), 5)
})

Try the forstringr package in your browser

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

forstringr documentation built on Aug. 7, 2023, 5:08 p.m.