title: Convert SpatialPointsDataframe to SpatialPolygons in R
body: <p>I have a SpatialPointsDataFrame in R that looks like this:</p>
  
  <pre><code>              coordinates id order  hole piece group box_id
      326  (-94.4, 27.6586) 47     1 FALSE     1  47.1      1
      327 (-93.64, 27.6232) 47     2 FALSE     1  47.1      1
      328 (-92.04, 27.7649) 47     3 FALSE     1  47.1      1
      329 (-90.36, 27.0903) 47     4 FALSE     1  47.1      1
      330 (-91.12, 25.6929) 47     5 FALSE     1  47.1      1
      331 (-92.92, 25.6569) 47     6 FALSE     1  47.1      1
      332 (-93.44, 26.0169) 47     7 FALSE     1  47.1      1
      333  (-94.4, 25.9809) 47     8 FALSE     1  47.1      1
      334  (-94.4, 27.6586) 47     9 FALSE     1  47.1      1
      335 (-92.04, 27.7649) 48     1 FALSE     1  48.1      2
      336 (-93.64, 27.6232) 48     2 FALSE     1  48.1      2
      337  (-94.4, 27.6586) 48     3 FALSE     1  48.1      2
      338  (-94.4, 27.8356) 48     4 FALSE     1  48.1      2
      339 (-93.64, 27.7649) 48     5 FALSE     1  48.1      2
      340 (-90.28, 28.1182) 48     6 FALSE     1  48.1      2
      341 (-90.56, 27.9417) 48     7 FALSE     1  48.1      2
      342 (-92.04, 27.7649) 48     8 FALSE     1  48.1      2
      100  (-94.4, 27.8356) 20     1 FALSE     1  20.1      3
      101  (-94.4, 28.0829) 20     2 FALSE     1  20.1      3
      102 (-90.28, 28.1182) 20     3 FALSE     1  20.1      3
      103 (-93.64, 27.7649) 20     4 FALSE     1  20.1      3
      104  (-94.4, 27.8356) 20     5 FALSE     1  20.1      3
  </code></pre>
  
  <p>(row names/numbers are not in order because I sorted by box_id column)</p>
  
  <p>These points are nodes of polygons (identified by box_id).  I want to write this as a polygon shape file to read into GIS programs, but I'm having trouble converting it into a SpatialPolygonDataFrame (to then use writeOGR) or to directly write it to a shp file.  Any help would be appreciate.  I'm new to GIS with R, so apologies if I'm missing something obvious.</p>