title: Convert R list to dataframe with missing/NULL elements
body: <p>Given a list:</p>
  
  <pre><code>alist = list(
    list(name="Foo",age=22),
    list(name="Bar"),
    list(name="Baz",age=NULL)
   )
  </code></pre>
  
  <p>what's the best way to convert this into a dataframe with name and age columns, with missing values (I'll accept NA or "" in that order of preference)?</p>
  
  <p>Simple methods using <code>ldply</code> fail because it tries to convert each list element into a data frame, but the one with the NULL barfs because the lengths don't match. Best I have at the moment is:</p>
  
  <pre><code>&gt; ldply(alist,function(s){t(data.frame(unlist(s)))})
    name  age
  1  Foo   22
  2  Bar &lt;NA&gt;
  3  Baz &lt;NA&gt;
  </code></pre>
  
  <p>but that's pretty icky and the numeric variable becomes a factor...</p>