title: How to merge two data by different column names?
body: <p>I have two different tables:</p>
  
  <p>Table 1:</p>
  
  <pre><code>#     id1   value price sales
  # 1:  c001   100   500    20
  # 2:  c002   200   200    30
  # 3:  c003   300   400    15
  </code></pre>
  
  <p>Table 2:</p>
  
  <pre><code>#     id2   nr 
  # 1: c001   50   
  # 2: c002   23    
  # 3: c003   41   
  </code></pre>
  
  <p>Now I try to join table 1 with table 2 by id1 and id2...</p>
  
  <pre><code>full_join &lt;- merge(table1, table2, by.x="id1", by.y="id2", all = TRUE)
  </code></pre>
  
  <p>I get following result:</p>
  
  <pre><code>#     id1   value price sales  nr
  # 1:  c001   100   500    20   50
  # 2:  c002   200   200    30   23
  # 3:  c003   300   400    15   41
  </code></pre>
  
  <p>But I want to keep all columns. It should look like:</p>
  
  <pre><code> #     id1   id2   value price sales  nr
   # 1:  c001   c001  100   500    20   50
   # 2:  c002   c002  200   200    30   23
   # 3:  c003   c003  300   400    15   41
  </code></pre>
  
  <p>Does anybody know how to solve this problem?</p>
  
  <p>Thanks in advance! </p>