title: Plot ggplot polygons with holes with geom_polygon
body: <p>There are <a href="https://stackoverflow.com/questions/21748852/choropleth-map-in-ggplot-with-polygons-that-have-holes">questions</a> out there about the fact that <code>ggplot2</code> can't plot polygon shapes that have <strong>holes</strong>.</p>
  
  <p>That is because, if the order of points is not OK, the end graph looks bad, usually with clipping/trimming lines inside the donut shape.</p>
  
  <p>I have read a lot about how order matters, but I am not able to step forward.
  I have a <code>SpatialPolygonsDataFrame</code> with 26 features (comes from <code>raster::rasterToPolygons(dissolve=T)</code>) and I want to plot it with <code>ggplot</code>.</p>
  
  <p>Here's what happens -</p>
  
  <pre><code>r3.pol &lt;- rasterToPolygons(r3, dissolve=T)
  r3.df &lt;- fortify(r3.pol)
  names(r3.df) &lt;- c('x','y','order','hole','piece','ID','group')
  p &lt;- ggplot(r3.df)
  p &lt;- p + geom_polygon(mapping=aes(x=x,y=y,group=ID), fill='red')
  p &lt;- p + coord_equal()
  </code></pre>
  
  <p>I see this output:</p>
  
  <p><a href="https://i.stack.imgur.com/NETDE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NETDE.png" alt="enter image description here"></a></p>
  
  <p>While it should be like so, with <code>plot(r3.pol)</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/zhSNK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zhSNK.png" alt="enter image description here"></a></p>
  
  <p>How can I make this work?
  I tried for hours but I am not able to reorder <code>r3.df</code>.
  Also, can the information in <code>r3.df$hole</code> be helpful? It is returned by the function <code>fortify</code> for points that are holes (I think).</p>
  
  <p><strike><em>Side question: how can I give you my r3.pol SpatialPolygonsDataFrame, so that you can try yourself? I remember seeing long, reproducible "dumps" of objects here, but I don't know how to do it.</em></strike></p>
  
  <p>I <code>save</code>d the polygons data frame <a href="https://drive.google.com/file/d/0B8KkBDlTQxNsMm0tQktHUHhqZnc/view?usp=sharing" rel="nofollow noreferrer"><strong>here</strong></a>. Was not able to save it using <code>dput</code>, sorry. You can fetch it using <code>load</code>.</p>