title: Saving dataframe after every iteration [r]
body: <p>I'm trying to save a data frame after every iteration of this loop, while appending the data frame with the loop number. So, I'll be left with 5 data frames all with different names.</p>
  
  <p>In my actual code, all the data frames will be different but for simplicity I've just shown one data frame here.</p>
  
  <p>I've supplied some test code below.</p>
  
  <pre><code>testFunction &lt;- function() {
  
  for (i in 1:5)  {
  
  
              x &lt;- data.frame(c(1:10), c(1,2,3,4,5,6,7,8,9,10), c(10:19))
  
              name &lt;- paste("name", i, sep = "_")
              name &lt;- x
  
              }
  }
  </code></pre>
  
  <p>The example data frames created would be named:</p>
  
  <pre><code>testFunction() 
  
  name_1
  name_2
  name_3
  name_4
  name_5
  </code></pre>
  
  <p>However, I'm only getting the final data frame "name_5" to save when the loop completes. My issue is I don't know how to save the ith version of the data frame without escaping from the loop.</p>
  
  <p>Any suggestions on how I can solve this?</p>
  
  <p>***** EDIT ***** </p>
  
  <p>I have my for loop inside a function, which might be why <code>assign()</code> is not working. I've appended my example above to show this.</p>