title: How to save the for loop output as data.frame in R?
body: <p>I'd like to know how I can save the output of a <code>for loop</code> as <code>data.frame</code>? 
  let's say using the <code>mtcars</code> dataset I have  the following <code>for loop</code> script:</p>
  
  <pre><code>for (i in seq_len(nrow(mtcars))) { 
    if (i  &lt;= 30) {
  
      next
    }
  
    print(mtcars[i,])  
  }
  
                mpg cyl disp  hp drat   wt qsec vs am gear carb
  Maserati Bora  15   8  301 335 3.54 3.57 14.6  0  1    5    8
              mpg cyl disp  hp drat   wt qsec vs am gear carb
  Volvo 142E 21.4   4  121 109 4.11 2.78 18.6  1  1    4    2
  </code></pre>
  
  <p>but if I am going to <code>save</code> it in <code>output</code> file as <code>dataframe</code>  I will get the following:</p>
  
  <pre><code>   output &lt;- as.data.frame(c())
      for (i in seq_len(nrow(mtcars))) { 
        if (i  &lt;= 30) {
  
          next
        }
  
        output&lt;- c(output,mtcars[i,])  
      }
  
  
     ### then the output is 
  
     &gt; output
      $mpg
      [1] 15
  
      $cyl
      [1] 8
  
      $disp
      [1] 301
  
      $hp
      [1] 335
  
      $drat
      [1] 3.54
  
      $wt
      [1] 3.57
  
      $qsec
      [1] 14.6
  
      $vs
      [1] 0
  
      $am
      [1] 1
  
      $gear
      [1] 5
  
      $carb
      [1] 8
  
      $mpg
      [1] 21.4
  
      $cyl
      [1] 4
  
      $disp
      [1] 121
  
      $hp
      [1] 109
  
      $drat
      [1] 4.11
  
      $wt
      [1] 2.78
  
      $qsec
      [1] 18.6
  
      $vs
      [1] 1
  
      $am
      [1] 1
  
      $gear
      [1] 4
  
      $carb
      [1] 2
  </code></pre>
  
  <p>I know the simple indexing <code>output &lt;- mtcars[-(1:30), ]</code>, but this is not a solution for my real life situation (which is more complex). I really need the loop to do what I want.</p>