tests/testthat/test-rev.R

test_that("reverses levels", {
  f1 <- factor(c("a", "b", "a"))
  f2 <- fct_rev(f1)

  expect_equal(levels(f2), c("b", "a"))
})

Try the forcats package in your browser

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

forcats documentation built on Feb. 16, 2023, 8:57 p.m.