title: Repeating certain columns when merging two data frames of different length (pasting?)
body: <p>I have two data frames for an event study and struggle a bit with preparing the data for the analysis. df1 has two rows with company ID and event date. Some companies have more than one event date, so the company ID is listed for every event date (which means there's more columns than unique company ID's). The other (df2) has share price of every company: row 1 is the company ID and every row below is share price for that specific firm at different dates which are specified in column 1.</p>
  
  <p>I want to merge (or paste?) the two data frames so that for every company ID in df1, it will copy the information below the matching company ID (share price) of df2 to itself.</p>
  
  <p>I've searched around for a solution, however it looks like I'm bad at searching at the moment because my searches yield no significant results. I've tried different merge commands and expand.grid, but I'm rusty in r.</p>
  
  <pre><code>df1 &lt;- data.frame(X1 = c("Event date","Company ID"),
                 X2 = c("2018-01-01","AA"),
                 X3 = c("2017-05-03","BB"),
                 X4 = c("2016-04-08","CC"),
                 X5 = c("2015-02-02","BB"))
  df2 &lt;- data.frame(X1 = c("Date","2018-12-31","2018-01-01","2017-05-03","2016-12-31","2016-04-08","2015-02-02"),
                 X2 = c("AA",100,102,101,98,99,99),
                 X3 = c("BB",85,78,80,77,75,74),
                 X4 = c("CC",55,53,54,55,54,54))
  
  
  df-desired &lt;- data.frame(X1 = c("Event date","Company ID","2018-12-31","2018-01-01","2017-05-03","2016-12-31","2016-04-08","2015-02-02"),
               X2 = c("2018-01-01","AA",100,102,101,98,99,99),
               X3 = c("2017-05-03","BB",85,78,80,77,75,74),
               X4 = c("2016-04-08","CC",55,53,54,55,54,54),
               X5 = c("2015-02-02","BB",85,78,80,77,75,74))
  </code></pre>
  
  <p>My current data is like df1 and df2 and my desired result is df-desired. I would appreciate if anyone could help me out with what command I should look into. I can't think of what command I should spend my efforts on, so I'm hoping someone can point me in the right direction!</p>