title: Process all the files in a folder with a loop in R
body: <p>I need to process all the files in a folder, and the files are named sequentially, so I think it is a good time for a loop.  The code to process a single file is simple:</p>
  
  <pre><code>df&lt;-read.table("CLIM0101.WTG", skip = 3, header = TRUE)
  
  df&lt;-df[,-1]
  df$year&lt;-2014
  df$day&lt;-c(1:365)
  
  write.table(df, "clim201401.txt", rownames = "FALSE")
  </code></pre>
  
  <p>The 99 files to be read are "CLIM0101.WTG" through "CLIM9901.WTG" and they should be written to "clim201401.txt" through "clim201499.txt".  Here's a link to the folder with the files: </p>
  
  <p><a href="https://www.dropbox.com/sh/y255e07wq5yj1nd/4dukOLxKgm" rel="nofollow">https://www.dropbox.com/sh/y255e07wq5yj1nd/4dukOLxKgm</a></p>
  
  <p>So what is the problem here?  I don't understand how to write a loop, and haven't found a great description of how to do so.  Previous loop questions have had non-loop answers, but it seems like this time it is really what I need. </p>