title: How to convert a list with different length element to a dataframe
body: <p>Here I meet so often this kind of problem when I have a loop. The first one is solved. </p>
  
  <p>[1] I have a list like this:</p>
  
  <pre><code>myList &lt;- list(a = c(1, 2, 3), b = c(4, 5, 6, 7), c= c(9,10))
  </code></pre>
  
  <p>now I want to convert the list to a data.frame like this:</p>
  
  <pre><code>    Value
  a   1, 2, 3
  b   4, 5, 6, 7
  c   9, 10
  </code></pre>
  
  <p>Does anyone show me a general function by basic R?</p>
  
  <p>[2]New problem arising:</p>
  
  <pre><code>mynewList &lt;- list(a = c(1, 2, 3, "f"), b = c(4, 5, 6), c= c(9,10), d=list(1,2))
  </code></pre>
  
  <p>I want to convert the mynewlist to a dataframe like this:</p>
  
  <pre><code>    a   b   c   d 
  1   1   4   9  1
  2   2   5  10  2
  3   3   6  na  na
  4   f   na na  na
  </code></pre>
  
  <p>I use the below command before, it works without the d element. but it didnot work for now. </p>
  
  <pre><code>df&lt;-data.frame(lapply(myList, "length&lt;-" , max(lengths(myList))))
  </code></pre>
  
  <p>Does anyone show me a general function by basic R?</p>