title: How to take the union of element in a nested list in R
body: <p>I have a nested list in say <code>lst</code>(all the elements are of class <code>int</code>). I don't know the length of <code>lst</code> in advance; however I do know that each element of <code>lst</code> is a list of length say <code>k</code></p>
  
  <pre><code>length(lst[[i]]) # this equals k and is known in advance, 
                   # this is true for i = 1 ... length(lst)
  </code></pre>
  
  <p>How do I take the <code>union</code> of the 1st element, 2nd element, ..., kth element of all the elements of <code>lst</code> </p>
  
  <p>Specifically, if the length of <code>lst</code> is <code>n</code>, I want (not R code):</p>
  
  <pre><code># I know that union can only be taken for 2 elements, 
  # following is for illustration purposes
  listUnion1 &lt;- union(lst[[1, 1]], lst[[2, 1]], ..., lst[[n, 1]])
  listUnion2 &lt;- union(lst[[1, 2]], lst[[2, 2]], ..., lst[[n, 2]])
  .
  .
  .
  listUnionk &lt;- union(lst[[1, k]], lst[[2, k]], ..., lst[[n, k]])
  </code></pre>
  
  <p>Any help or pointers are greatly appreciated.</p>
  
  <p>Here is a dataset that can be used, n = 3 and k = 2</p>
  
  <pre><code>list(structure(list(a = 1:5, b = 6:11), .Names = c("a", "b")), 
      structure(list(a = 6:11, b = 1:5), .Names = c("a", "b")), 
      structure(list(a = 12, b = 12), .Names = c("a", "b")))
  </code></pre>