forcats icon indicating copy to clipboard operation
forcats copied to clipboard

incorrect "Unknown levels" error message in fct_other

Open xelax opened this issue 5 years ago • 0 comments

when no values in f triggers the generation of "Other" then a warning message is emitted. This is particularly troublesome on very large grouped datasets because you get a warning for each group and it takes forever to process it.

library(forcats)
fct_other(c("A"), keep="A")
#> Warning: Unknown levels in `f`: Other
#> [1] A
#> Levels: A
fct_other(c("A", "B"), keep="A")
#> [1] A     Other
#> Levels: A Other

Created on 2020-07-02 by the reprex package (v0.3.0)

xelax avatar Jul 02 '20 18:07 xelax