I am trying to make a graph with ordered bars according to frequency and also using a variable two separate two variables using facets. Words have to be ordered by value
Given the info provided by @GordonShumway and following the answer given by @CPak, bellow I provide the entire and "tricky" and no-elegant way to fix this issue. The almost entire answer (by @CPak) and one more line finally fix the problem:
d %>%
mutate(temp = paste(word, u_c, sep = "_")) %>%
ggplot(aes(x = fct_reorder(temp, n), y = n, fill = u_c)) +
geom_col(show.legend = F) +
scale_x_discrete(labels = function(x) str_replace(x,"_candidate|_user", "")) +
facet_wrap(~u_c, scales = "free_y") +
coord_flip()
Thanks for the answers!