tidyverse/forcats

`fct_reorder()` treatment of missing values in .x depends on whether .f is a factor or a character vector

dominikbach opened this issue · 1 comments

When .x contains missing values, this throws an error if .f is a character vector but not if .f is a factor (with no missing values in either case).

This behaviour is not documented (and I suspect is not intended). It occurs in v0.5.0 and v1.0.0.

Example:

.f <- c("a", "b", "c")
.x <- c(1, 2, NA)
forcats::fct_reorder(.f, .x)
forcats::fct_reorder(forcats::as_factor(.f), .x)