title: pie chart in ggplot text labelling horror
body: <p>I can't resolve that strange situation. Somewhere I have error, or bug, but sitting over three halfs of an hour could not deal with it.</p>
  
  <p>I have: <code>sta_df</code></p>
  
  <pre><code>             sta value
  1 IN_LIQUIDATION    29
  2     LIQUIDATED    47
  3      OPERATING   435
  4    TRANSFORMED     8
  
  sp &lt;- ggplot(sta_df, aes(x="", y=value, fill=sta)) +
    geom_bar(width = 1, stat = "identity", color = "black") +
    coord_polar("y") + scale_fill_brewer(palette="Pastel2") +
    geom_text(aes(x = seq(1.2,1.4,,4), label = percent(value/sum(value))), 
                  position = position_stack(vjust = 0.5), size=5)
  </code></pre>
  
  <p>and the plot have wrong direction of labelling. </p>
  
  <p><a href="https://i.stack.imgur.com/pbBOC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pbBOC.png" alt="enter image description here"></a></p>
  
  <p>Nevermind this strange font of a picture. I've tried to use many different functions instead of <code>position_stack</code>. For example: </p>
  
  <p><code>geom_text(aes(x = rep(seq(0.9,1.4,,6),1), y = value/2 + c(0, cumsum(value)[-length(value)])</code></p>
  
  <p>but it didn't help. This thread neither: <a href="https://stackoverflow.com/questions/41661654/wrong-labeling-in-ggplot-pie-chart">wrong labeling in ggplot pie chart</a></p>
  
  <p>When I wanted to reverse <code>y=rev(value)</code> the legend didn't correspond with data. Putting direction <code>1</code> or <code>-1</code> doesn't do more than reversing all. Reversing values in <code>geom_text</code> gives Pac-Man-like chart. I've updated <code>ggplot2</code>.</p>
  
  <p>Honestly, the problem is because chart starts to draw anti-clockwise although direction is set to clockwise and text numbers are in right direction. And reversing data in data.frame doesn't change anything in the whole plot. Sorry, I stuck, but feel the solution is right there.</p>