title: flatten nested list by averaging vectors
body: <p>Say I have a nested list of vectors.</p>
  
  <pre><code>lst1 &lt;- list(`A`=c(a=1,b=1), `B`=c(a=1), `C`=c(b=1), `D`=c(a=1,b=1,c=1))
  lst2 &lt;- list(`A`=c(b=1), `B`=c(a=1,b=1), `C`=c(a=1,c=1), `D`=c(a=1,c=1))
  lstX &lt;- list(lst1, lst2)
  </code></pre>
  
  <p>As seen, each vector <code>A,B,C,D</code> occur twice with <code>a,b,c</code> present in different frequencies.</p>
  
  <p>How would be the most efficient way of flatten the lists so that <code>a,b,c</code> is summed, or averaged over <code>A,B,C,D</code> across the nested lists, as seen below. The real list has several hundreds of thousands of nested lists.</p>
  
  <pre><code>#summed
    a b  c
  A 1 2 NA
  B 2 1 NA
  C 1 1  1
  D 2 1  2
  
  #averaged
    a   b   c
  A 0.5 1   NA
  B 1   0.5 NA
  C 0.5 0.5 0.5
  D 1   0.5 1
  </code></pre>