title: Write .csv in a for loop
body: <p>I want to write csv files in a for loop. Say I have a data frame <code>data</code> with 3 rows, to make it simple, of a variable <code>x</code>. In the end, I want my output to be 200 .csv files, each one containing a row of the data. The first column of the data is the identification ("ID") of my variables. </p>
  
  <p>Furthermore, my data is described as the following:</p>
  
  <pre><code>  data:
  
       ID x
   [1] a  1
   [2] b  2
   [3] c  3 
  
   for (i in nrow(data)){
     write.csv(data[i,2], file = paste0("Directory/", "data[i,1], ".csv"))
   }
  </code></pre>
  
  <p>I run this code and a csv file is created. However, only the last row is  created, meaning that I'm found with only one file <code>c.csv</code>. </p>
  
  <p>Do you know what I am doing wrong? I thought that it would automatically create all the archives. Should I save first the results in a list and then export them?</p>