title: Write list of data.frames to separate CSV files with lapply
body: <p>The question says it all - I want to take a list object full of data.frames and write each data.frame to a separate .csv file where the name of the .csv file corresponds to the name of the list object.</p>
  
  <p>Here's a reproducible example and the code I've written thus far.</p>
  
  <pre><code>df &lt;- data.frame(
      var1 = sample(1:10, 6, replace = TRUE)
      , var2 = sample(LETTERS[1:2], 6, replace = TRUE)
      , theday = c(1,1,2,2,3,3)
  )
  
  df.daily &lt;- split(df, df$theday) #Split into separate days
  
  lapply(df.daily, function(x){write.table(x, file = paste(names(x), ".csv", sep = ""), row.names = FALSE, sep = ",")})
  </code></pre>
  
  <p>And here is the top of the error message that R spits out</p>
  
  <pre><code>Error: Results must have one or more dimensions.
  In addition: Warning messages:
  1: In if (file == "") file &lt;- stdout() else if (is.character(file)) { :
    the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>What am I missing here?</p>