tests/testthat/test-most-common.R

library(testthat)
library(campfin)

test_that("most common values of a vector can be found", {
  x <- c("A", "A", "A", "B", "B", "C")
  expect_equal(most_common(x, 2), c("A", "B"))
  expect_length(most_common(x, 2), 2)
  expect_type(most_common(x, 2), "character")
})

Try the campfin package in your browser

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

campfin documentation built on Oct. 20, 2023, 5:06 p.m.