Skip to content

Instantly share code, notes, and snippets.

@geotheory
Created June 7, 2021 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geotheory/9025ba5a662d832cdc265b761147a9da to your computer and use it in GitHub Desktop.
Save geotheory/9025ba5a662d832cdc265b761147a9da to your computer and use it in GitHub Desktop.
# remotes::install_github("moodymudskipper/safejoin")
require(safejoin)
require(tidyverse)
#> Loading required package: tidyverse
d1 = tibble(id = c(1,2,3), x = c('A','B','C'), y = c(5,7,9))
d2 = tibble(id = c(2,3,4), x = c('B','CC','D'), y = c(7,9,11))
safe_full_join(d1, d2, by = 'id', conflict = ~ coalesce(.y, .x))
#> # A tibble: 4 x 3
#> id x y
#> <dbl> <chr> <dbl>
#> 1 1 A 5
#> 2 2 B 7
#> 3 3 CC 9
#> 4 4 D 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment