title: converting a matrix to a list
body: <p>Suppose I have a matrix <code>foo</code> as follows:</p>
  
  <pre><code>foo &lt;- cbind(c(1,2,3), c(15,16,17))
  
  &gt; foo
       [,1] [,2]
  [1,]    1   15
  [2,]    2   16
  [3,]    3   17
  </code></pre>
  
  <p>I'd like to turn it into a list that looks like</p>
  
  <pre><code>[[1]]
  [1]  1 15
  
  [[2]]
  [1]  2 16
  
  [[3]]
  [1]  3 17
  </code></pre>
  
  <p>You can do it as follows:</p>
  
  <p><code>lapply(apply(foo, 1, function(x) list(c(x[1], x[2]))), function(y) unlist(y))</code></p>
  
  <p>I'm interested in an alternative method that isn't as complicated.  Note, if you just do <code>apply(foo, 1, function(x) list(c(x[1], x[2])))</code>, it returns a list within a list, which I'm hoping to avoid.</p>