title: How to not overwrite file in R
body: <p>I am trying to copy and paste tables from R into Excel. Consider the following code from a previous <a href="https://stackoverflow.com/questions/14942917/array-of-tables">question</a>:</p>
  
  <pre><code>    data &lt;- list.files(path=getwd())
      n &lt;- length(list)
      for (i in 1:n) 
       {
        data1 &lt;- read.csv(data[i])
        outline &lt;- data1[,2]
        outline &lt;- as.data.frame(table(outline))
        print(outline)   # this prints all n tables
        name &lt;- paste0(i,"X.csv")
        write.csv(outline, name)
        }
  </code></pre>
  
  <p>This code writes each table into separate Excel files (i.e. "1X.csv", "2X.csv", etc..). Is there any way of "shifting" each table down some rows instead of rewriting the previous table each time? I have also tried this code:</p>
  
  <pre><code> output &lt;- as.data.frame(output)
   wb = loadWorkbook("X.xlsx", create=TRUE)
   createSheet(wb, name = "output")
   writeWorksheet(wb,output,sheet="output",startRow=1,startCol=1)
   writeNamedRegion(wb,output,name="output")
   saveWorkbook(wb)
  </code></pre>
  
  <p>But this does not copy the dataframes exactly into Excel.</p>