tests/testthat/test-lenuniq.R

context("length unique")

test_that("lenuniq works", {

    x <- c(1, 2, 1, 3, 1, 1, 2, 2, 3, NA, NA, 1)
    expect_equal(lenuniq(x), 3)
    expect_equal(lenuniq(x, na.rm=FALSE), 4)

    expect_equal(lenuniq(NULL), 0)
    expect_equal(lenuniq(character(0)), 0)

})

Try the broman package in your browser

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

broman documentation built on July 8, 2022, 5:07 p.m.