title: List of lists to matrix
body: <p>I have a list of lists and I want to convert it into a matrix such that each column = one sublist.</p>
  
  <p><strong>Mock example</strong></p>
  
  <pre><code>list1 &lt;- list(1, 2)
  list2 &lt;- list(1, 2, 3)
  list3 &lt;- list(1, 2, 3, 4)
  
  list_lists &lt;- list (list1, list2, list3)
  </code></pre>
  
  <p>I'm first egalizing the lengths of all the sublists (padding with NULLs if needed) so that all sublists have the length of the longest one. That is to avoid having R repeating data to fill in the rows in the final matrix (feel free if I can skip this step somehow).</p>
  
  <pre><code>max_length &lt;- max(unlist(lapply (list_lists, FUN = length)))
  list_lists &lt;- lapply (list_lists, function (x) {length (x) &lt;- max_length; return (x)})
  </code></pre>
  
  <p><strong>My best attempt so far</strong></p>
  
  <pre><code>mat &lt;- lapply (list_lists, cbind)
  </code></pre>
  
  <p><code>mat</code> does look superficially like what I want but it is actually not. It is not a matrix (and attempts to convert it into one using <code>as.matrix</code> are unsuccessful) and I cannot refer to columns/rows like I would do with a matrix.</p>
  
  <p><strong>I am expecting</strong></p>
  
  <pre><code>     [,1] [,2] [,3]
  [1,] 1    1    1   
  [2,] 2    2    2   
  [3,] NULL 3    3   
  [4,] NULL NULL 4   
  </code></pre>
  
  <p>What is weird to me is that</p>
  
  <pre><code>mat &lt;- cbind (list_lists[[1]], list_lists[[2]], list_lists[[3]])
  </code></pre>
  
  <p>seems to work. I would bet these two lines are the same, how can they be different?</p>