billdenney · GitHub

This is partly related to #3243.

When joining by specified column names, if names will duplicate due to the first suffix, then duplicated names are generated. If names will duplicated from the second suffix, names are specific. I would expect the latter behavior (the second pair of examples) and not the former (the first pair of examples).

library(dplyr, quietly = TRUE)
#> 
#> 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
d1 <- data.frame(A = 1, A.x = 2)
d2 <- data.frame(B = 3, A.x = 4, A = 5)
full_join(d1, d2, by = "A.x")
#>   A.x A.x  B A.y
#> 1   1   2 NA  NA
#> 2  NA   4  3   5
full_join(d2, d1, by = "A.x")
#>    B A.x A.x.x A.y
#> 1  3   4     5  NA
#> 2 NA   2    NA   1
d1 <- data.frame(A = 1, A.y = 2)
d2 <- data.frame(B = 3, A.y = 4, A = 5)
full_join(d1, d2, by = "A.y")
#>   A.x A.y  B A.y.y
#> 1   1   2 NA    NA
#> 2  NA   4  3     5
full_join(d2, d1, by = "A.y")
#>    B A.y A.x A.y.y
#> 1  3   4   5    NA
#> 2 NA   2  NA     1

Read the original on github.com ↗