0

I have two data frames:

> cDates
# A tibble: 4 x 2
    week ClosedPR
  <date>    <int>
1 2017-01-09        1
2 2017-02-06        1
3 2017-05-22        1
4         NA       72
> oDates
# A tibble: 22 x 2
     week OpenPR
   <date>  <int>
1 2016-09-05      1
2 2016-09-12      1
3 2016-10-10      2
4 2016-12-19      1
5 2017-01-02      1
6 2017-01-09      1
7 2017-01-16      1
8 2017-01-23      2
9 2017-02-20      3
10 2017-03-06      2
# ... with 12 more rows

When I perform a "merge", I get the intersection of the data:

        week OpenPR ClosedPR
1 2017-01-09      1        1
2 2017-05-22      3        1
3       <NA>     27       72

What I'd like is the union of all the data not just the entries with common dates in "week". How can I do this?

samcantrell
  • 1
  • 1
  • 1

1 Answers1

1

Instead of using merge, perhaps use full_join from dplyr.

library(dplyr)
full_join(cDates, oDates, by = "week")
Dan
  • 11,370
  • 4
  • 43
  • 68