tests/testthat/test-s3-factor.R

test_that("factor", {
  expect_snapshot({
    # simple factor with implict levels
    construct(factor(month.abb))
    construct(factor(month.abb), opts_factor("next"))
    construct(factor(month.abb), opts_factor("integer"))
    construct(factor(month.abb, month.abb))
    construct(factor(month.abb), opts_factor("as_factor"))
    construct(factor(month.abb, month.abb), opts_factor("as_factor"))
    construct(factor(month.abb), opts_factor("new_factor"))
    construct(factor(month.abb, month.abb), opts_factor("new_factor"))
    construct(factor(month.abb, levels = c(month.abb, NA), exclude = NULL))
    construct(factor(c(a="foo")))
  })
})

Try the constructive package in your browser

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

constructive documentation built on April 3, 2025, 9:39 p.m.