I have 2 data frames. The first data frame has 2 columns (Ticker, Date), the second data frame has 3 columns (Ticker, Date, Price). The first data frame only has 1 row per Ticker while the 2nd data frame has many rows per Ticker. For example.
df1
Ticker Date
GS 2019-01-01
AAPL 2019-02-19
GE 2019-02-14
df2
Ticker Date Price
GS 2019-01-01 100
GS 2019-10-10 105
AAPL 2019-02-19 210
AAPL 2019-05-05 225
GE 2019-02-14 28
GE 2019-02-21 27
I would like to group by ticker and extract only the row that has the same Date and ticker.
For example something like this.
df2 %>% group_by(Ticker, Date) %>% slice(#match df1 Ticker and Date)%>% un_group()
Ticker Date Price
GS 2019-01-01 100
AAPL 2019-02-19 210
GE 2019-02-14 28
Lastly, if you could show a way to do this in purrr that would be awesome. Thank you very much.