I have two different data frames. Lets say "Cases" and "test".
"Cases" Data Frame Looks like:
Date Death Cured
15-04-2020 5 2
16-04-2020 4 3
17-04-2020 2 5
18-04-2020 5 10
19-04-2020 7 13
20-04-2020 4 12
21-04-2020 6 13
22-04-2020 4 13
"test" Data Frame Looks like:
Date Samples Positive
18/04/2020 50 15
19/04/2020 60 20
20/04/2020 70 16
21/04/2020 80 19
22/04/2020 90 17
I want to conditionally join these data frames. This means if Cases$Date == test$Date then join "Samples" and "Positive" column to data frame "Cases". So, my final output should be :
"Cases" Data Frame should have following:
Date Death Cured Samples Positive
15-04-2020 5 2 NA NA
16-04-2020 4 3 NA NA
17-04-2020 2 5 NA NA
18-04-2020 5 10 50 15
19-04-2020 7 13 60 20
20-04-2020 4 12 70 16
21-04-2020 6 13 80 19
22-04-2020 4 13 90 17
I have looked multiple answers on stack overflow but couldn't able to do the specific operation. How can we do it using dplyr package or normal if-else.