title: Merge dataframes using reduce- how to add the merge by option
body: <p>My code:</p>
  
  <pre><code>df1 &lt;- data.frame("X1"=c("John","Sam","Dave"),"X2"=c(21,22,25))
  df2 &lt;- data.frame("X1"=c("John","Sam"),"X2"=c(22,25))
  df3 &lt;- data.frame("X1"=c("John","Sam","Dave"),"X2"=c("US","SA","NZ"))
  mylist &lt;- list(df1,df2,df3)
  merged= Reduce(function (...) merge(..., all= T), mylist)
  </code></pre>
  
  <p>My output is:</p>
  
  <pre><code>    X1 X2
  1 Dave 25
  2 Dave NZ
  3 John 21
  4 John 22
  5 John US
  6  Sam 22
  7  Sam 25
  8  Sam SA
  </code></pre>
  
  <p>However, the output that I want is</p>
  
  <pre><code>  names X1    X2.x    X2.y
  1  Dave  25    NA      NZ
  2  John  21    22      US
  3   Sam  22    25      SA 
  </code></pre>
  
  <p>I understand that I can get the desired output if I name the columns differently, but that is not an option here. Specifically, I want to know how to add the "by= "X1" argument with the Reduce function as used in merge function alone. </p>