tests/testthat/test-n_distinct.R

test_that("works on a single vector", {
  x <- c("a", "a", "b")
  expect_equal(n_distinct(x), 2)
})

test_that("works on multiple inputs", {
  x <- c(1, 1, 2)
  y <- c(1, 2, 1)
  expect_equal(n_distinct(x, y), 3)
})

test_that("na.rm works", {
  x <- c("a", "a", "b", NA)
  expect_equal(n_distinct(x, na.rm = TRUE), 2)
})

test_that("n_distinct. works", {
  x <- c("a", "a", "b")
  expect_equal(suppressWarnings(n_distinct.(x)), 2)
})

Try the tidytable package in your browser

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

tidytable documentation built on Oct. 5, 2023, 5:07 p.m.