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
When using fct_inorder() or fct_infreq() to create a factor ordered by appearance or frequency, the functions create a factor with levels in the correct order, but the factor is not an official ordered factor, so the ordering does not carry over to ggplot plots, ordered logistic regression models, or any other situations where ordered factors matter.
Right now, these two functions have to be wrapped in ordered() to make them actual ordered factors. It would be nice if there were an ordered=TRUE/FALSE argument in fct_inorder() and fct_infreq() to avoid this extra step.
f<-factor(c("b", "b", "a", "c", "c", "c"))
f#> [1] b b a c c c#> Levels: a b c# Unordered
fct_inorder(f)
#> [1] b b a c c c#> Levels: b a c
fct_infreq(f)
#> [1] b b a c c c#> Levels: c b a# Ordered
ordered(fct_inorder(f))
#> [1] b b a c c c#> Levels: b < a < c
ordered(fct_infreq(f))
#> [1] b b a c c c#> Levels: c < b < a# Would be nice
fct_inorder(f, ordered=TRUE)
#> Error in fct_inorder(f, ordered = TRUE): unused argument (ordered = TRUE)
fct_infreq(f, ordered=TRUE)
#> Error in fct_infreq(f, ordered = TRUE): unused argument (ordered = TRUE)
The text was updated successfully, but these errors were encountered:
When using
fct_inorder()
orfct_infreq()
to create a factor ordered by appearance or frequency, the functions create a factor with levels in the correct order, but the factor is not an official ordered factor, so the ordering does not carry over to ggplot plots, ordered logistic regression models, or any other situations where ordered factors matter.Right now, these two functions have to be wrapped in
ordered()
to make them actual ordered factors. It would be nice if there were anordered=TRUE/FALSE
argument infct_inorder()
andfct_infreq()
to avoid this extra step.The text was updated successfully, but these errors were encountered: