Consider the following example:
dd <- tibble(group = c('a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'),
type = c('auto', 'bike', 'walk','auto', 'bike', 'walk','auto', 'bike', 'walk'),
value = c(12,32,13,60,46,34,24,3,55))
I am trying to get control over the way the bars are shown in a stacked bar chart. The simple ggplot call is
dd %>%
ggplot(aes(y = group, fill = type, x = value)) + geom_col()
However, this default rendering does not work. I would like to sort the bar chart according to the total size of the bar, in descending order. That is, group b should be on top, then a, then c. I was unable to do so using forcats. Any ideas?
Thanks!
