tests/testthat/_snaps/fct.md

checks input types

Code
  fct(1:3)
Condition
  Error in `fct()`:
  ! `x` must be a character vector, not an integer vector.
Code
  fct("x", 1:3)
Condition
  Error in `fct()`:
  ! `levels` must be a character vector or `NULL`, not an integer vector.
Code
  fct("x", "y", na = 1)
Condition
  Error in `fct()`:
  ! `na` must be a character vector, not the number 1.

clear error if levels are incomplete

Code
  fct(c("x", "y", "z"), c("x", "y"))
Condition
  Error in `fct()`:
  ! All values of `x` must appear in `levels` or `na`
  i Missing level: "z"


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.