title: Removing empty rows of a data file in R
body: <p>I have a dataset with empty rows. I would like to remove them:</p>
  
  <pre><code>myData&lt;-myData[-which(apply(myData,1,function(x)all(is.na(x)))),]
  </code></pre>
  
  <p>It works OK. But now I would like to add a column in my data and initialize the first value:</p>
  
  <pre><code>myData$newCol[1] &lt;- -999
  
  Error in `$&lt;-.data.frame`(`*tmp*`, "newCol", value = -999) : 
    replacement has 1 rows, data has 0
  </code></pre>
  
  <p>Unfortunately it doesn't work and I don't really understand why and I can't solve this.
  It worked when I removed one line at a time using:</p>
  
  <pre><code>TgData = TgData[2:nrow(TgData),]
  </code></pre>
  
  <p>Or anything similar.</p>
  
  <p>It also works when I used only the first 13.000 rows.</p>
  
  <p>But it doesn't work with my actual data, with 32.000 rows.</p>
  
  <p>What did I do wrong? It seems to make no sense to me.</p>