title: removing specific rows from a data frame within a loop in r
body: <p>How can I save the changes occurred in a data frame within a loop, after each iteration? By the following codes, I want to delete some rows from my data frame (df) which have equal value to 'v'. The codes works well, but the problem is finally, only the result of the last i value in the iterations affects the data frame!  </p>
  
  <pre><code>for (i in 1:50){
    v &lt;- i+ 450
        temp&lt;- fn$sqldf("select count(V1) from df where V1='$v' ")
    if (temp[1,] &lt; 1000){ 
      g &lt;- temp[1,]
      c &lt;- v
      print(paste("Topic number: ", c, "is less than 1000, with ", g, "records") )
      new_df&lt;- df[df$V1 != v,]
    }
  
  }
  </code></pre>