title: Swapping between ascending and descending x axis in ggplot and barplot
body: <p>I know this should be simple, and it is probably asked before, but I can't find it. I have this code for a bar plot in ggplot:</p>
  
  <pre><code>ggplot(agg.table.year,aes(x=YR,y=prc)) +
    scale_y_continuous(limits=c(0,100),expand=c(0,0)) +
    geom_bar(stat='identity',width=0.7) + 
    theme_bw(base_size = 12) + xlab('') + ylab('Percent') +
    theme(axis.text.x=element_text(angle=45,hjust=1,size=13)) +
    theme(axis.text.y=element_text(size=13)) +
    ggtitle("Fraction of government-funded studies
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/HOIDI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HOIDI.png" alt="enter image description here"></a></p>
  
  <p>With the same data, x-axis (year) being a factor, the following barplot code:</p>
  
  <pre><code>barplot((agg.table.year$prc),axes=T,ylim=c(0,100),
          names.arg = agg.table.year$YR,
          cex.names=0.8,las=2,space=0.5,col="black",density=19,
          main=paste("Fraction of government-funded studies"))
  </code></pre>
  
  <p>gives this plot:</p>
  
  <p><a href="https://i.stack.imgur.com/QIECR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QIECR.png" alt="enter image description here"></a></p>
  
  <p>I am not mastering how to switch between ascending and descending x-axis in either way, but I am desperate learn. I have googled it and read the R Cookbook, but I don't get it. </p>