title: outputting multiple data frames to multiple excel files using loop in R
body: <p>I am using the <code>xlsx</code> package in R and have a loop set up where many data frames are created and am having trouble writing the code to output each data frame from an iteration of the loop to a separately named excel file ..below is what I am trying to do..</p>
  
  <pre><code>data1 &lt;- function(58) # Cannot disclose the function
  write.xlsx(data.frame(data1),"data1.xlsx", sheetName="Sheet1")
  
  data2 &lt;- function(59) 
  write.xlsx(data.frame(data2),"data2.xlsx", sheetName="Sheet1")
  
  data1 &lt;- function(60)
  write.xlsx(data.frame(data3),"data3.xlsx", sheetName="Sheet1") 
  </code></pre>