title: Efficient way to convert CSV to Sparse Matrix in R
body: <p>I have a very large csv file (about 91 million rows so a for loop takes too long in R) of similarities between keywords that when I read into a data.frame looks like:</p>
  
  <pre><code>&gt; df   
  kwd1 kwd2 similarity  
  a  b  1  
  b  a  1  
  c  a  2  
  a  c  2 
  </code></pre>
  
  <p>It is a sparse list and I would like to convert it into a sparse matrix:</p>
  
  <pre><code>&gt; myMatrix 
    a b c  
  a . 1 2
  b 1 . .
  c 2 . .
  </code></pre>
  
  <p>I tried using sparseMatrix(), but converting the keyword names to integer indexes takes too much time.</p>
  
  <p>Thanks for any help!</p>