0

I am trying to combine 2 dataframes, such that only the rows that are in both sets will show in the final.

I first need to care for dates being in the same format. For one of my sets I just have the week beginning date, and the day of the week, and I need to get the actual date from that.

Then, if the date columns match, it needs to merge the observations. We are supposed to use case_when, but I just can't understand how to use it. I think it is something along the lines of, if the dates match, show the observation.

Any help would be appreciated.

from df1:

showing columns in the first dataframe

from df2:

showing columns in the second dataframe

scarhand
  • 9
  • 2
  • 1
    That’s called an *inner join* — are you using the ‘dplyr’ package? If so: `inner_join`; otherwise: `merge`. – Konrad Rudolph May 11 '21 at 15:03
  • (1) See https://stackoverflow.com/q/1299871/3358272, https://stackoverflow.com/a/6188334/3358272, good examples of joins, the first is R-code. (2) Please don't post pictures of data, we can't use it to clearly demonstrate code in action, please just post usable data (preferably programmatically with `data.frame(..)` or from `dput(.)`). Please read https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info for discussions on reproducible data. Thanks! – r2evans May 11 '21 at 15:06
  • If you made a data.frame combining both df1 and df2, then using the ```duplicate``` function to check for rows that appear twice, would that work? – David May 11 '21 at 15:06

0 Answers0