title: Dynamically Name R Data Frame in a For Loop
body: <p>I'm using a For loop to create 100 datasets according to some specifications.  My end goal is to have 1 dataset containing each iterated dataset (i.e., dataset 1 through 100). </p>
  
  <p>My current solution is inelegant. I export each individual data frame (called Dataset) to a csv then merge them outside R. With each iteration i of the For loop, my data frame is overwritten. </p>
  
  <pre><code>Trackfile=1:100
  for (i in Trackfile){
    d.cor &lt;- .10 # Desired correlation
    Dataset &lt;- as.data.frame(mvrnorm(20, mu = c(0,0), 
                                     Sigma = matrix(c(1,d.cor,d.cor,1), ncol = 2), 
                                     empirical = TRUE))
    write.csv(Dataset, paste0("C:/",d.cor," ",i,".csv"))
  }
  </code></pre>
  
  <p>I believe the solution is to dynamically name the data frame according to the iteration (i) such that the data frames are named dataset1, dataset2...dataset100, then merge them. But I've struggled to find a solution for dynamically naming data frames embedded in a For loop. I'm a novice in R, please help! </p>