title: Transpose a List of Lists
body: <p>I have a list which contains list entries, and I need to transpose the structure.
  The original structure is rectangular, but the names in the sub-lists do not match.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>ax &lt;- data.frame(a=1,x=2)
  ay &lt;- data.frame(a=3,y=4)
  bw &lt;- data.frame(b=5,w=6)
  bz &lt;- data.frame(b=7,z=8)
  before &lt;- list(  a=list(x=ax, y=ay),   b=list(w=bw, z=bz))
  </code></pre>
  
  <p>What I want:</p>
  
  <pre><code>after  &lt;- list(w.x=list(a=ax, b=bw), y.z=list(a=ay, b=bz))
  </code></pre>
  
  <p>I do not care about the names of the resultant list (at any level).</p>
  
  <p>Clearly this can be done explicitly:</p>
  
  <pre><code>after &lt;- list(x.w=list(a=before$a$x, b=before$b$w), y.z=list(a=before$a$y, b=before$b$z))
  </code></pre>
  
  <p>but this is ugly and only works for a 2x2 structure.  What's the idiomatic way of doing this?</p>