tests/testthat/test_getUsedFactorLevels.R

context("getUsedFactorLevels")

test_that("getUsedFactorLevels", {
  used.levels = letters[1:3]
  all.levels = letters
  x = factor(x = used.levels, levels = all.levels)
  expect_equal(sort(getUsedFactorLevels(x)), used.levels)

  x = factor(x = used.levels)
  expect_equal(used.levels, levels(x))
})

Try the BBmisc package in your browser

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

BBmisc documentation built on Sept. 29, 2022, 5:12 p.m.