title: R: Converting nested list to dataframe and get names of list levels als factors
body: <p>I have a nested list:</p>
  
  <pre><code>list1 &lt;- list("A"=c(1,1,1), "B"=c(2,2,2), "C"=c(3,3,3))
  list2 &lt;- list("F1" = list1, "F2" = list1)
  </code></pre>
  
  <p>and I would like to get the last level of the list (containing the vector) as a dataframe and I would like to get the levels of the list as factors:</p>
  
  <pre><code>  Level1 Level2 V1 V2 V3
  1     F1      A  1  1  1
  2     F1      B  2  2  2
  3     F1      C  3  3  3
  4     F2      A  1  1  1
  5     F2      B  2  2  2
  6     F2      C  3  3  3
  </code></pre>
  
  <p>The first part is nicely given by:</p>
  
  <pre><code>data.frame(matrix(unlist(list2), ncol=3, byrow=T))
  </code></pre>
  
  <p>However, I did not find a nice way to also get the list-level-names as factors in the same dataframe. Any ideas? :)</p>
  
  <p><strong>Edit:</strong> The procedure should work up to p dimensions.</p>