title: Read and rbind multiple csv files
body: <p>I have a series of csv files (one per anum) with the same column headers and different number of rows. Originally I was reading them in and merging them like so; </p>
  
  <pre><code>setwd &lt;- ("N:/Ring data by cruise/Shetland")
  LengthHeight2013 &lt;- read.csv("N:/Ring data by      cruise/Shetland/R_0113A_S2013_WD.csv",sep=",",header=TRUE)
  LengthHeight2012 &lt;- read.csv("N:/Ring data by cruise/Shetland/R_0212A_S2012_WD.csv",sep=",",header=TRUE)
  LengthHeight2011 &lt;- read.csv("N:/Ring data by cruise/Shetland/R_0211A_S2011_WOD.csv",sep=",",header=TRUE)
  LengthHeight2010 &lt;- read.csv("N:/Ring data by cruise/Shetland/R_0310A_S2010_WOD.csv",sep=",",header=TRUE)
  LengthHeight2009 &lt;- read.csv("N:/Ring data by cruise/Shetland/R_0309A_S2009_WOD.csv",sep=",",header=TRUE)
  
  LengthHeight &lt;- merge(LengthHeight2013,LengthHeight2012,all=TRUE)
  LengthHeight &lt;- merge(LengthHeight,LengthHeight2011,all=TRUE)
  LengthHeight &lt;- merge(LengthHeight,LengthHeight2010,all=TRUE)
  LengthHeight &lt;- merge(LengthHeight,LengthHeight2009,all=TRUE)
  </code></pre>
  
  <p>I would like to know if there is a shorter/tidier way to do this, also considering that each time I run the script I might want to look at a different range of years.</p>
  
  <p>I also found this bit of code by Tony Cookson which looks like it would do what I want, however the data frame it produces for me has only the correct headers but no data rows. </p>
  
  <pre><code>multmerge = function(mypath){
  filenames=list.files(path=mypath, full.names=TRUE)
  datalist = lapply(filenames, function(x){read.csv(file=x,header=T)})
  Reduce(function(x,y) {merge(x,y)}, datalist)
  
  mymergeddata = multmerge("C://R//mergeme")
  </code></pre>