title: extracting a dataframe from a list over many objects
body: <p>I have over a 1000 objects (<code>z</code>) in R, each containing three dataframes (<code>df1</code>, <code>df2</code>, <code>df3</code>) with different structures.</p>
  
  <blockquote>
    <p><code>z1$df1</code> … <code>z1000$df1</code></p>
    
    <p><code>z1$df2</code> … <code>z1000$df2</code></p>
    
    <p><code>z1$df3</code> … <code>z1000$df3</code></p>
  </blockquote>
  
  <p>I created a list of these objects (list1 thus contains z1 thru z1000) and tried to use <code>lapply</code> to extract one type of dataframe (<code>df2</code>) for all objects, and then merge them to one single dataframe.</p>
  
  <h3>Extraction:</h3>
  
  <p>For a single object it would look like this:</p>
  
  <pre><code>df15&lt;- z15$df2 # I transferred the index of z to the extracted df
  </code></pre>
  
  <p>I tried some code with <code>lapply</code>, ignoring the transfer of the index (I can create another list for that). However I don’t know what function I should use.</p>
  
  <pre><code>List2 &lt;- lapply(list1, function(x))
  </code></pre>
  
  <p>I try to avoid using a loop because there's so many and vectorization is so much quicker. I have the idea I'm looking at it from the wrong angle.</p>
  
  <p>Subsequent merging can be done as follows:</p>
  
  <pre><code>merged &lt;- do.call(rbind, list2)
  </code></pre>
  
  <p>Thanks for any suggestions.</p>