Skip to content

Commit

Permalink
full_join(na_matches = "never") (#5367)
Browse files Browse the repository at this point in the history
* closes #5359

* clarity
  • Loading branch information
romainfrancois committed Jun 29, 2020
1 parent 092f756 commit 4c96c40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/join-rows.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ join_rows <- function(x_key, y_key, type = c("inner", "left", "right", "full"),
if (type == "right" || type == "full") {
miss_x <- !vec_in(y_key, x_key, na_equal = na_equal)

if (!na_equal) {
miss_x[is.na(miss_x)] <- TRUE
}

if (any(miss_x)) {
y_extra <- seq_len(vec_size(y_key))[miss_x]
}
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-join.r
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ test_that("joins don't match NA when na_matches = 'never' (#2033)", {

out <- anti_join(df1, df2, by = "a", na_matches = "never")
expect_equal(out, tibble(a = NA_integer_))

dat1 <- tibble(
name = c("a", "c"),
var1 = c(1, 2)
)
dat3 <- tibble(
name = c("a", NA_character_),
var3 = c(5, 6)
)
expect_equal(
full_join(dat1, dat3, by = "name", na_matches = "never"),
tibble(name = c("a", "c", NA), var1 = c(1, 2, NA), var3 = c(5, NA, 6))
)
})

# nest_join ---------------------------------------------------------------
Expand Down

0 comments on commit 4c96c40

Please sign in to comment.