This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For detailed explaination of this function, check this blog post: https://asterhu.com/post/2023-05-11-coalesce-join-in-r/ | |
# Reference: https://alistaire.rbind.io/blog/coalescing-joins/ | |
require(dplyr) | |
require(stringr) | |
coalesce_join <- function(x, y, | |
by = NULL, | |
keep = c("left", "right"), # "left" means keep value from left table if there's any duplicate value in both tables. | |
suffix = c(".x", ".y"), | |
join = c("full_join","left_join", "right_join", "inner_join")) { |