title: data.frame behaving differently when using complete.cases in R?
body: <p>I was wondering why the <em>First</em> approach works OK but the <em>Second</em> approach fails? Is there anyway to make the output of Second approach to become like the First approach:</p>
  
  <pre><code>#First:
  
  data &lt;- mtcars["wt"]
  d &lt;- scale(data)
  data[, paste0(names(data), ".bbb") ] &lt;- c(d)
  data
  
  #Secondt:
  
  data &lt;- mtcars["wt"]
  data &lt;- data[complete.cases(data), ]  ## THIS LINE is the only difference with ABOVE ##
  d &lt;- scale(data)
  data[, paste0(names(data), ".bbb") ] &lt;- c(d)
  data
  </code></pre>