title: R list to sparse matrix
body: <p>I tried to load data from mongodb with R, but I find the query results was unstructured-data, it's a messy list, the results looks like this:</p>
  
  <pre><code> df
  [[1]]
  list()
  [[2]]
  [[2]][[1]]
  [1] "vector1"
  [[2]][[2]]
  [1] "vector2"
  [[3]]
  list()
  [[4]]
  list()
  [[5]]
  list()
  [[6]]
  [[6]][[1]]
  [1] "vector1"
  [[6]][[2]]
  [1] "vector2"
  [[6]][[3]]
  [1] "vector3"
  </code></pre>
  
  <p>I tried to convert the list to matrix, just like this:</p>
  
  <pre><code>vector1 vector2 vector3
     0       0       0
     1       1       0
     0       0       0
     0       0       0
     0       0       0
     1       1       1 
  </code></pre>
  
  <p>I try to use <code>SparseMatrix()</code> and <code>sapply()</code>, but all failed. And I had to manually create the dataframe above to make the question clear.</p>