title: Merging multiple text files in R with a constraint
body: <p>I have 10 text files containing 1000's of rows. </p>
  
  <p>Example:
  First File:</p>
  
  <pre><code>V1  V2
  1   2
  2   3
  10 20
  1   4    
  .....
  </code></pre>
  
  <p>Second file:</p>
  
  <pre><code>V1  V2
  1   2
  8   10
  .....
  </code></pre>
  
  <p>What I want is a final file which will contain 12 columns. The first two columns representing the relationship and the next 10 columns telling about different files ( represented by 1 if that pair is present and 0 if not present )
  For example:</p>
  
  <p>Final File:</p>
  
  <pre><code>V1  V2  V3  V4  V5  V6  V7  V8  V9  V10  V11  V12
  1   2   1   1   0   0   1    0   1   1    0     1
  2   3   1   0   1   1   0    0   0   1    1     0
  </code></pre>
  
  <p>Now, what I did was sort every file so that all the pairs with 1 as their first number appears on top followed by other numbers, i.e.</p>
  
  <p>For a particular file, I did so that,</p>
  
  <pre><code>V1   V2
  
  1     2
  1     3 
  1     10
  1     5
  2     10 
  2     15
  .......
  </code></pre>
  
  <p>Then, I tried using the merge command, however, I know it's not the right one. I am not able to think of other method to do it.</p>