coalesceJoin: Coalesce Duplicate Fields from a Join

View source: R/coalesceJoin.R

coalesceJoinR Documentation

Coalesce Duplicate Fields from a Join

Description

[Stable]

Coalesces columns by suffix created by joins. Useful after a full join.

Usage

coalesceJoin(df, suffix = c(".x", ".y"), showMessage = TRUE)

Arguments

df

the joined data.frame

suffix

suffix used to diferentiate the columns needing coalesced. Defaults to c(".x", ".y")

showMessage

TRUE/FALSE on whether to print message. Default TRUE.

Value

df with the join suffixed columns coalesced

Examples

## Not run: 
#Download Case, Death, Test Data
cdtData <- MARCDataAPI_read('https://gis2.marc2.org/MARCDataAPI/api/covidcasedeathtest') %>%
  dplyr::mutate(Date = as.Date(Date),
                LastUpdated = lubridate::as_datetime(LastUpdated),
                LastUpdated = lubridate::with_tz(LastUpdated, "America/Chicago"))

#Download the Hospital Data
hospData <- marcR::MARCDataAPI_read('https://gis2.marc2.org/MARCDataAPI/api/covidhospital') %>%
    dplyr::mutate(Date = as.Date(Date))

cdtHospSumData <- dplyr::full_join(cdtData, hospData, by = c("GeoID", "Date")) %>% coalesceJoin()

## End(Not run)

MARC-KC/marcR documentation built on June 2, 2022, 9:31 p.m.