Running forcats::fct_inorder on factors with empty levels produces an (informative) error.
Is this behaviour expected/desired, or should empty levels be automatically dropped (with a warning)? If expected, would be good to flag on the help file.
library(forcats)
f <- factor(rev(letters[1:5]), levels = letters[1:6])
fct_inorder(f)
#> Error: `idx` must contain one integer for each level of `f`
fct_infreq(f)
#> [1] e d c b a
#> Levels: a b c d e f
fct_inorder(fct_drop(f))
#> [1] e d c b a
#> Levels: e d c b a
Created on 2020-04-29 by the reprex package (v0.3.0)
Running
forcats::fct_inorderon factors with empty levels produces an (informative) error.Is this behaviour expected/desired, or should empty levels be automatically dropped (with a warning)? If expected, would be good to flag on the help file.
Created on 2020-04-29 by the reprex package (v0.3.0)