title: R error in glmnet: NA/NaN/Inf in foreign function call
body: <p>I am trying to create a model using glmnet, (currently using cv to find the lambda value) and I am getting an error <code>NA/NaN/Inf in foreign function call (arg 5)</code>. I believe this has something to do with the NA values in my data set, because when I remove all data points with NAs the command runs successfully.</p>
  
  <p>I was under the impression that glmnet <em>can</em> handle NA values. I'm not sure where the error is coming from:</p>
  
  <pre><code>&gt; res &lt;- cv.glmnet(features.mat, as.factor(tmp[,"outcome"]), family="binomial")
  Error in lognet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs,  : 
    NA/NaN/Inf in foreign function call (arg 5)
  </code></pre>
  
  <p>The dataset looks something like this:</p>
  
  <pre><code>&gt; head(features.mat)
  6 x 8 sparse Matrix of class "dgCMatrix"
     a b   c  e  f  g  h i
  1  1 1 138 NA NA 15 NA .
  4  1 3 171 NA NA 17 NA .
  7  1 1 156 NA NA  5 NA .
  8  1 4  97 NA NA  7 NA .
  9  1 1 219 NA NA 11 NA .
  10 1 . 263 NA NA 20 NA .
  &gt; head(as.factor(tmp[,"outcome"]))
  [1] 0 0 0 0 0 0
  Levels: 0 1
  </code></pre>