title: How do I sort bar chart by value with R ggplot?
body: <p>Here is my simple assets dataset:</p>
  
  <pre><code>ID  Type    Currency    Value
  a   Bond    GBP         10
  b   Bond    EUR         20
  c   Stock   GBP         3
  d   Stock   GBP         60
  e   Bond    GBP         8
  f   Bond    USD         39
  g   Stock   USD         1
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code> assets &lt;- read_excel("C:/R/SampleData.xlsx")
   g &lt;- ggplot(assets, aes(Currency, Value))
   g + geom_col()
  </code></pre>
  
  <p>And this is the plot that I get:</p>
  
  <p><img src="https://i.stack.imgur.com/swjzy.png" alt="bar plot"></p>
  
  <p>I am trying to create the same plot, but with bars sorted  by value (in descending order)
  How do I achieve this?
  I have tried the following code: </p>
  
  <pre><code>assets$Currency &lt;- factor(assets$Currency, levels = assets$Currency[order(assets$Value)])
  </code></pre>
  
  <p>But I get the following warning message and the chart is still not sorted correctly:</p>
  
  <pre><code>Warning message:
  In `levels&lt;-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels,  :
  duplicated levels in factors are deprecated
  </code></pre>
  
  <p>Thanks!</p>