title: Merging datasets in loop in R
body: <p>I have 1 base file that looks as follows:</p>
  
  <pre><code>ID  x1
  1   5
  2   20
  3   14
  4   8
  5   20
  </code></pre>
  
  <p>I have 1.000 seperate files, that each contain extra variables. 2 examples are:</p>
  
  <pre><code>ID  x2
  1   45
  2   85
  3   42
  7   52
  8   41
  
  
  ID  x2
  10  54
  12  4
  4   7
  5   21
  </code></pre>
  
  <p>What I would like to get it:</p>
  
  <pre><code>ID  x1  x2
  1   5   45
  2   20  85
  3   14  42
  4   8   7
  5   20  21
  </code></pre>
  
  <p>I only want to add matching IDs in "mydata". I initially tried to merge all separate files into 1 single file and then merge, but the size is too large. I also tried merging in loop, but this keeps adding new variables. Any suggestions on how to merge this?</p>