title: Merging different size data frames and repeating values
body: <p>I need to merge two different size data frames. The larger one (<code>df1</code>) has a column with several repeated values (<code>licto</code>), the shorter one (<code>df2</code>) has the column <code>licto</code>, but its values are not repeated. df2 also has a ID column. I need a new column in <code>df1</code> with the IDs in <code>df2</code>, repeated according the repeated values in <code>licto</code>. The example below probably make it clearer.  </p>
  
  <pre><code>df1&lt;-data.frame(licfrom=c(15470,16307,17121,15350,16982,17182,20319,16727,16946,16262,16605,
                16607,15924,15399,15404,16739,16839,16842,16899,16157,15399),
          licto=c(17121,17121,17121,16982,16982,16982,16982,16946,16946,16262,16607,
              16607,15924,16839,16839,16839,16839,16839,16839,16157,15399))
  </code></pre>
  
  <p>.</p>
  
  <pre><code>df2&lt;-data.frame(licto=c(17121,16982,16946,16607,15924,16839,16157,15399),
          fisherID=c(160,760,770,406,106,2196,17323,2441))
  </code></pre>
  
  <p>My data frames look like this:</p>
  
  <pre><code>df1                 df2 
  licfrom licto       licto   fisherID
  15470   17121       17121   160
  16307   17121       16982   760
  17121   17121       16946   770
  15350   16982       16262   947
  16982   16982       16607   406
  17182   16982       15924   106
  20319   16982       16839   2196
  16727   16946       16157   17323
  16946   16946       15399   2441
  16262   16262           
  16605   16607           
  16607   16607           
  15924   15924           
  15399   16839           
  15404   16839           
  16739   16839           
  16839   16839           
  16842   16839           
  16899   16839           
  16157   16157           
  15399   15399   
  </code></pre>
  
  <p>And my final data frame should be like this:</p>
  
  <pre><code>licfrom licto   fisherID
  15470   17121   160
  16307   17121   160
  17121   17121   160
  15350   16982   760
  16982   16982   760
  17182   16982   760
  20319   16982   760
  16727   16946   770
  16946   16946   770
  16262   16262   947
  16605   16607   406
  16607   16607   406
  15924   15924   106
  15399   16839   2196
  15404   16839   2196
  16739   16839   2196
  16839   16839   2196
  16842   16839   2196
  16899   16839   2196
  16157   16157   17323
  15399   15399   2441
  </code></pre>
  
  <p>Any help will be appreciated, as I have spent several hour trying to merge as I need. I have used <code>merge</code> and  <code>%in%</code> with no success. Thanks!</p>