title: R ggplot histogram bars in descending order
body: <p>I don't get how to make the bars of an histogram to appears in descending order with ggplot.</p>
  
  <p>Heres my code with a dataframe that everyone can use :</p>
  
  <pre><code>library(ggplot2)
  library(scales)
  
  
  chol &lt;- read.table(url("http://assets.datacamp.com/blog_assets/chol.txt"), 
  header = TRUE)
  ggplot(chol) +
  geom_histogram(aes(x = AGE, y = ..ncount.., fill = ..ncount..),
                 breaks=seq(20, 50, by = 2),
                 col="red",
                 alpha = .2) +
  scale_fill_gradient("Percentage", low = "green", high = "red") +
  scale_y_continuous(labels = percent_format()) +
  labs(title="Histogram for Age") +
  labs(x="Age", y="Percentage")
  </code></pre>
  
  <p>The resulting histogram that i want in descending order :</p>
  
  <p><a href="https://i.stack.imgur.com/kipG3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kipG3.png" alt="enter image description here"></a></p>
  
  <p>I tried to order the column AGE before plotting :</p>
  
  <pre><code>## set the levels in order we want
  Chol &lt;- within(Chol, 
                 AGE &lt;- factor(AGE, 
                                    levels=names(sort(table(AGE), 
                                                      decreasing=TRUE)
  </code></pre>
  
  <p>I get an error when i plot the order AGE with ggplot and geom_histogram.</p>