You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Put them at the end makes the most sense to me, as you may want them for zero counts in tables etc. You also have more flexibility keeping them, as you can simply run fct_drop if you don't want them, but if the default is to drop the levels then it is harder to add them back should you want them.
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.
Created on 2020-04-29 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: