I want to create a sorted bar chart (similar to the one presented here: http://flowingdata.com/2008/08/19/3-worthwhile-alternatives-to-the-pie-chart/). When I run the code below, I get something very similar, but the bars aren't sorted. How can I sort the bars so that the one with the highest frequency is at the top of the chart?
cat = c("CatA", "CatB", "CatC", "CatB", "CatB", "CatB", "CatB", "CatB", "CatB", "CatB")
dat = data.frame(Category = cat)
qplot(factor(Category), data=dat, geom="bar") +
geom_bar() +
coord_flip()