title: large-scale regression in R with a sparse feature matrix
body: <p>I'd like to do large-scale regression (linear/logistic) in R with many (e.g. 100k) features, where each example is relatively sparse in the feature space---e.g., ~1k non-zero features per example.</p>
  
  <p>It seems like the <a href="http://cran.r-project.org/web/packages/SparseM/" rel="nofollow noreferrer" title="SparseM">SparseM</a> package <code>slm</code> should do this, but I'm having difficulty converting from the <code>sparseMatrix</code> format to a <code>slm</code>-friendly format.</p>
  
  <p>I have a numeric vector of labels <code>y</code> and a <code>sparseMatrix</code> of features <code>X</code> \in {0,1}. When I try</p>
  
  <pre><code>model &lt;- slm(y ~ X)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Error in model.frame.default(formula = y ~ X) : 
  invalid type (S4) for variable 'X'
  </code></pre>
  
  <p>presumably because <code>slm</code> wants a <code>SparseM</code> object instead of a <code>sparseMatrix</code>.</p>
  
  <p>Is there an easy way to either a) populate a <code>SparseM</code> object directly or b) convert a <code>sparseMatrix</code> to a <code>SparseM</code> object? Or perhaps there's a better/simpler way to do this?</p>
  
  <p>(I suppose I could explicitly code the solutions for linear regression using <code>X</code> and <code>y</code>, but it would be nice to have <code>slm</code> working.)</p>