mutate_auto_coalesce: Auto coalesce after a join

View source: R/mutate.R

mutate_auto_coalesceR Documentation

Auto coalesce after a join

Description

When joining data, there are often column conflicts. Coalescing is the most common solution. This function attempts to identify the conflicting column names after a join, coalesces them into the base name, and drops the suffixed versions.

Usage

mutate_auto_coalesce(data, suffix = c(".x", ".y"))

Arguments

data

the data resulting from a join operation

suffix

the suffixes used to disambiguate non-joined duplicate variables during the join

Value

a dataframe with duplicate variables coalesced and the original variants dropped

Examples

x <- data.frame(id = 1:3, v = paste0("x", 1:3))
y <- data.frame(id = 2:4, v = paste0("y", 2:4))
d <- dplyr::left_join(x, y, by = "id")
mutate_auto_coalesce(d)

the-mad-statter/washu documentation built on May 5, 2024, 10:26 a.m.