title: R - SpatialPolygonsDataFrame LIST from a list of SpatialPolygons
body: <p>I have a list of SpatialPolygons I created using lapply and the <code>raster::buffer</code> function. I would like to convert the files in the list back to a list of SpatialPolygonsDataFrame objects. I tried the answer provided here (although note my issue is slightly different because I would like to end up with a LIST of SpatialPolygonsDataFrame objects): <a href="https://stackoverflow.com/questions/46890221/r-spatialpolygonsdataframe-from-a-list-of-spatialpolygons">R - SpatialPolygonsDataFrame from a list of SpatialPolygons</a>, but i don't know how to get unique IDs for each object in the list. When I apply that code, I get the following error msg:</p>
  
  <pre><code>#Getting polygon IDs
  IDs &lt;- sapply(list_of_SPols, function(x)
   slot(slot(x, "polygons")[[1]], "ID"))
  
  #Checking
  length(unique(IDs)) == length(list_of_SPols) #output = [1] FALSE
  
  #Making SpatialPolygons from list of polygons
  Spol &lt;- SpatialPolygons(lapply(list_of_SPols,
                              function(x) slot(x, "polygons")[[1]]))
  
  #output = Error in validObject(res) : 
    #invalid class “SpatialPolygons” object: non-unique Polygons ID slot 
    #values
  </code></pre>
  
  <p>My SpatialPolygons list elements have unique index values, but when I check the output of the IDs object created above, a subset of it looks like this:</p>
  
  <pre><code>#[1] "1" "1" "1" "1" "1" "1" "1"....
  </code></pre>
  
  <p>So all list elements have the same IDs. So I think what I need to do is create unique IDs equal to the index numbers? </p>
  
  <p>How do I do this, then how do I go on to create a list of SpatialPolygonsDataFrame objects?</p>