title: R error: Error in match.names(clabs, names(xi)) : names do not match previous names
body: <p>I'm trying to combine multiple CSV files in R and have come across an issue I can't solve even though I've searched this website.</p>
  <p>I'm using a function to read multiple CSV files and merge them using the reduce command.</p>
  <p>This isn't working as I get the following error:</p>
  <blockquote>
  <p>Error in match.names(clabs, names(xi)) :</p>
  <p>names do not match previous names</p>
  </blockquote>
  <p>So I took 4 CSVs manually out of the bunch I want to run to see if I could solve this issue and here is the code for these 4:</p>
  <pre><code>dataframeA=read.csv(&quot;1.csv&quot;)
  dataframeA &lt;- subset(dataframeA, select = c(Name,Position))
  dataframeB=read.csv(&quot;2.csv&quot;)
  dataframeB &lt;- subset(dataframeB, select = c(Name,Position))
  dataframeC=read.csv(&quot;3.csv&quot;)
  dataframeC &lt;- subset(dataframeC, select = c(Name,Position))
  dataframeD=read.csv(&quot;4.csv&quot;)
  dataframeD &lt;- subset(dataframeD, select = c(Name,Position))
  
  prac=Reduce(function(x,y) merge(x,y,by=&quot;Name&quot;,all=TRUE), list(dataframeA, dataframeB, dataframeC, dataframeD))
  </code></pre>
  <p>Where I have taken out two particular columns of each of my CSV files (there are 3 in total but the 3rd column is to be used later on), there was also a need to perform an outer join.</p>
  <p>When running this code I get the same error as before so I looked up the cause of this and found as the error suggests the column names aren't the same. I produced queries between these 4 data frames to see:</p>
  <pre><code>&gt; identical(colnames(dataframeA),colnames(dataframeB))
  [1] TRUE
  &gt; identical(colnames(dataframeA),colnames(dataframeC))
  [1] TRUE
  &gt; identical(colnames(dataframeA),colnames(dataframeD))
  [1] TRUE
  </code></pre>
  <p>As you can see this doesn't bring back any issues for my column names being different so I am at a loss about how to fix this.</p>
  <p>Also what is interesting is running the same command with only three data frames (yes it can be any of the three data frames) I get no error whatsoever for example running the following gives no error at all, I can also run this for dataframeD instead of any of the other data frames and also get it to run.</p>
  <pre><code>prac=Reduce(function(x,y) merge(x,y,by=&quot;Name&quot;,all=TRUE), list(dataframeA, dataframeB, dataframeC))
  </code></pre>
  <p>I may have just overlooked something very simple but I cannot find the error at all.</p>
  <p>Thanks for any help in advance</p>
  <p>Nathan</p>