Some time ago, I posted about how to plot frequencies using ggplot2. One point that remained untouched was how to sort the order of the bars. Let’s look at that issue here. First, let’s load some data. data(tips, package = "reshape2") And the usual culprits. library(tidyverse) library(scales) # for percentage scales First, let’s plot a standard plot, with bars unsorted. tips %>% count(day) %>% mutate(perc = n / nrow(tips)) -> tips2 ggplot(tips2, aes(x = day, y = perc)) + geom_bar(stat = "identity") Hang on, what could ‘unsorted’ possibly …