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
library(forcats)
x<-letters[c(1:3, 2)]
w<- c(4, 1, 3, 1)
x#> [1] "a" "b" "c" "b"w#> [1] 4 1 3 1
fct_infreq(x)
#> [1] a b c b#> Levels: b a c
fct_infreq(x, w=w)
#> Error in fct_infreq(x, w = w): unused argument (w = w)# Should behave like:
fct_reorder(x, w, sum, .desc=TRUE)
#> [1] a b c b#> Levels: a c b
Thanks @krlmlr. I just hit this with geom_bar(aes(y = fct_infreq(<factor>), weight = <weight>)), which doesn't sort the discrete axis correctly, presumably because ggplot 3.4.0 isn't flowing weight to fct_infreq(). fct_reorder() handles this case correctly.
It seems perhaps also worth noting the reordering FAQ entry for geom_bar() doesn't consider this case. So, depending what happens with this issue, it may be worth revising the FAQ.
similarly to
fct_lump()
.Created on 2020-04-27 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: