tidyverse/forcats

Feature Request: Add handling of ordered factors to fct()

sambtalcott opened this issue · 0 comments

I would like to see the fct() function from forcats be extended to cover creating ordered factors. This could look like including ordered as an optional argument (as in base::factor()) and/or by creating an analogue function ord() that has the same default level-checking as fct().

In practice this would look like:

x <- c("A", "B", "A", "C", "A", "B", "D")
lvls <- c("F", "D", "C", "B", "A")

x <- fct(x, lvls, ordered = TRUE)

# and/or
x <- ord(x, lvls)

Thanks!