title: Phantom NA's in dataframe when regression in R
body: <p>I have pretty large dataframe -- about 235K rows and I want to do multivariate regression:</p>
  <pre><code>model &lt;- lm(var~., data=data)
  </code></pre>
  <p>but I get an error:</p>
  <pre><code>Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
    NA/NaN/Inf в 'y'
  In addition: Warning message:
  In storage.mode(v) &lt;- &quot;double&quot; : NAs introduced by coercion
  </code></pre>
  <p>Neither <code>na.omit</code>, nor other methods of getting rid of NA's didn't help.</p>
  <p>So I've tried to find NA by myself. I've split dataframe into two parts:</p>
  <p><strong>Second UPD</strong></p>
  <pre><code>data1 &lt;- data[1:(dim(data)[1]/2), ]
  data2 &lt;- data[(dim(data)[1]/2):(dim(data)[1]), ]
  </code></pre>
  <p>and I again get result for both <code>lm</code> and no errors from previous UPD section! NB: I've restarted RStudio.</p>
  <p><strong>First UPD</strong></p>
  <pre><code>data1 &lt;- data[1:(dim(data)[1]/2),]
  </code></pre>
  <p>and when I call <code>lm</code> instead of previous error I get next:</p>
  <pre><code>Error in `contrasts&lt;-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
    contrasts can be applied only to factors with 2 or more levels
  </code></pre>
  <p>To reach this error I reduced data from 235K to 14.5K. So, what is the problem now? Some of offcasted slices don't throw any errors.</p>
  <p><strong>Origin version</strong></p>
  <pre><code>data1 &lt;- data[1:(dim(data)[1]/2)]
  data2 &lt;- data[(dim(data)[1]/2):(dim(data)[1])]
  </code></pre>
  <p>and call <code>lm</code> for each of them:</p>
  <pre><code>model1 &lt;- lm(var~., data=data1)
  model2 &lt;- lm(var~., data=data2)
  </code></pre>
  <p>and I reciece no errors! So, I suppose problem is in big size of dataframe. Is there any way to fix it?</p>