title: How to export multiple data frames to CSV?
body: <p><strong>Situation</strong>: I have several data frames that I like to export as CSV files into the working directory for further processing.</p>
  
  <p><strong>Goal</strong>: Export a collection of data frames from the workspace as csv files to the working directory by using a single function (batch export).</p>
  
  <p><strong>Details</strong>:</p>
  
  <p><em>My question is not about changing the content of the data frames, so you can just use any example data provided by R for reproduction</em>.</p>
  
  <p>The function I use for exporting a single data frame is</p>
  
  <pre><code>csvExport &lt;- function(data, enc = 'utf8'){
      name &lt;- paste(deparse(substitute(data)), "csv", sep=".")
      con &lt;- file(name, encoding = enc)
      write.csv(data, file = con, row.names=FALSE, quote = TRUE, sep = ";")
      text&lt;-"exported!"
      print(paste(name, text, sep=" "))
  }
  </code></pre>
  
  <p>Since I do not like to call the function for each data frame to export explicitly I am looking for a way to export the data frames by indicating which ones from the workspace I like to export with:</p>
  
  <pre><code>export &lt;- ls()[1:20]
  </code></pre>
  
  <p>I then tried using this function (with some variation of the for loop) with the above list:</p>
  
  <pre><code>multipleCSVExport &lt;- function(export){
    for (i in export){
      csvExport(i)
    }
  }
  </code></pre>
  
  <p>However, I am not able to create the expected result. </p>