title: How to select all elements of a list at a particular nested Level?
body: <p>Or put it differently: How can I use the <code>[[</code> operator in a nested list?</p>
  
  <p>You can consider this as a follow-up question on this <a href="https://stackoverflow.com/questions/13432863/determine-level-of-nesting-in-r">one</a>, when I asked how to determine the depth level of a list. I got some decent answers from @Spacedman and @flodel who both suggested recursive functions. Both solutions where quite similar and worked for me. </p>
  
  <p>However I haven't figured out yet what to do with the information I get from these functions. Let's say I have a list nested at level <code>i</code> and I want to get back a list that contains all <code>i-th</code> level elements, like this:</p>
  
  <pre><code>myList$firstLevel$secondLevel$thirdLevel$fourthLevel
  # fourthLevel contains 5 data.frames and thirdLevel has
  # three elements
  </code></pre>
  
  <p>How can I get back all 15 data.frames from <code>mylist</code>?
  I am trying to use e.g.</p>
  
  <pre><code>lapply(mylist,"[[",2)
  </code></pre>
  
  <p>but obviously I just get the second element of all list elements at the first level.</p>
  
  <p>EDIT: I found the following in the help of <code>extract</code> respectivel <code>?"[["</code> but can't really wrap my head around it so far:
  <code>"[[ can be applied recursively to lists, so that if the single index i is a vector of length p, alist[[i]] is equivalent to alist[[i1]]...[[ip]] providing all but the final indexing results in a list."</code></p>
  
  <p>EDIT:
  Don't want to end up nesting loops like this.</p>
  
  <pre><code>o &lt;- list()
  i=1
  for (i in 1:2){
  o[[i]] &lt;- mylist[[c(i,1,1,1)]]
  } 
  </code></pre>