title: Assign unique ID to each data.frame element in a list
body: <p>I have a list of many (spatial) data.frames. I want to add a column to each data.frame that has an ID equivalent to the list index ID (i.e., every row in each individual data.frame's new column will have the same ID). </p>
  
  <p>I think I have to use some apply function along with cbind, but I do not know how to format it for each element in a list (especially of Spatial data.frames elements). Please help!</p>
  
  <p>Here is some example code to work with: </p>
  
  <pre><code>d1 &lt;- data.frame(y1 = c(1, 2, 3), y2 = c(4, 5, 6))
  d2 &lt;- data.frame(y1 = c(3, 2, 1), y2 = c(6, 5, 4))
  my.list &lt;- list(d1, d2)
  </code></pre>
  
  <p>I want to end up with the following:</p>
  
  <pre><code>[[1]]
    y1 y2 unique.id
  1  1  4  1
  2  2  5  1
  3  3  6  1
  
  [[2]]
    y1 y2 unique.id
  1  3  6  2
  2  2  5  2
  3  1  4  2
  </code></pre>