title: Merge data frames by exact match of column
body: <p>I would like to merge two data frames where one has more variables (columns) whereas the other has more observations (rows). A simplified example of how they are set up are below:</p>
  
  <p>Dataframe 1:</p>
  
  <pre><code>ID      Date         Indicator
  12345   01/01/2008   1
  54321   12/01/2008   1
  </code></pre>
  
  <p>Dataframe 2:</p>
  
  <pre><code>ID      Date         
  12345   01/01/2008   
  12345   01/31/2008
  12345   02/28/2009
  24681   01/01/2008
  54321   12/01/2008
  54321   12/20/2008
  </code></pre>
  
  <p>What I would like to do is only keep the rows in which the ID's are an exact match. For example, I would like the following output:</p>
  
  <p>New dataframe:</p>
  
  <pre><code>ID      Date         Indicator     
  12345   01/01/2008   1
  12345   01/31/2008   NA
  12345   02/28/2009   NA
  54321   12/01/2008   1
  54321   12/20/2008   NA
  </code></pre>
  
  <p>I have tried </p>
  
  <pre><code>new &lt;- merge(df1, df2, all=TRUE)
  </code></pre>
  
  <p>but this results in the merging of ALL rows, whereas I only want the rows from df2 with ID that are seen in df1.</p>
  
  <p>Any help is appreciated!</p>