title: r - Using geom_segment with coord_polar
body: <p>I want to do something similar to the answer in this <a href="https://stackoverflow.com/questions/24590154/r-ggplot2-connecting-points-in-polar-coordinates-with-a-straight-line">post</a>, but with <code>geom_segment()</code> instead of <code>geom_path()</code> because now I want to add arrows to my lines.</p>
  
  <p>Setup:</p>
  
  <pre><code>example &lt;- data.frame(r=c(5,4,3),theta=c(0.9,1.1,0.6))
  
  is.linear.polar2 &lt;- function(x) TRUE
  coord_polar2 &lt;- coord_polar(theta="y", start = 3/2*pi, direction=-1) 
  class(coord_polar2) &lt;- c("polar2", class(coord_polar2))
  
  myplot &lt;- ggplot(example, aes(r, theta)) + geom_point(size=3.5) +
    scale_x_continuous(breaks=seq(0,max(example$r)), lim=c(0, max(example$r))) + 
    scale_y_continuous(breaks=round(seq(0, 2*pi, by=pi/4),2), expand=c(0,0), lim=c(0,2*pi)) +
    geom_text(aes(label=rownames(example)), size=4.4, hjust=0.5, vjust=-1)
  
  myplot + coord_polar2 + geom_path()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/xmqDL.jpg" alt="enter image description here"></p>
  
  <p>I want a plot that looks like this, but with arrows in the direction of the next point in the sequence.</p>
  
  <p>These are my attempts:</p>
  
  <pre><code>myplot + coord_polar2 + 
  geom_segment(data=example,aes(x=r, y=theta, xend=c(tail(r, n=-1), NA), 
                                yend=c(tail(theta, n=-1), NA)),
               arrow=arrow(length=unit(0.3,"cm"), type="closed"))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/DVpwr.jpg" alt="enter image description here"></p>
  
  <pre><code>myplot + coord_polar(theta="y", start = 3/2*pi, direction=-1) + 
  geom_segment(data=example,aes(x=r, y=theta, xend=c(tail(r, n=-1), NA), 
                                yend=c(tail(theta, n=-1), NA)),
               arrow=arrow(length=unit(0.3,"cm"), type="closed"))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/04rF1.jpg" alt="enter image description here"></p>