Since NA is not unique (i.e. one NA does not necessarily equal another NA) it seems to follow that when performing a join the rows should not match when both keys are NA. However when merging with dplyr
NA will match NA when merging. What is the reasoning behind this behavior?
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
df1 <- tibble(key = c("A", "A", NA), value = 1:3)
df2 <- tibble(key = c("B", "B", NA), value = 4:6)
inner_join(df1, df2, by = "key")
#> # A tibble: 1 x 3
#> key value.x value.y
#> <chr> <int> <int>
#> 1 <NA> 3 6
Created on 2019-04-16 by the reprex package (v0.2.1)