safe_join.data.frame: Join Data Frames Safely

View source: R/safejoin.R

safe_join.data.frameR Documentation

Join Data Frames Safely

Description

Joins data frames safely. I.e., a left join that cannot alter row order or number. Supports the case where you only intend to augment existing rows with additional columns and are expecting singular matches. Gives an error if row order or number would have been altered by a left join.

Usage

## S3 method for class 'data.frame'
safe_join(x, y, ...)

Arguments

x

data.frame

y

data.frame

...

passed to dplyr::left_join

See Also

Other safe_join: safe_join()

Examples

library(magrittr)
x <- data.frame(code = c('a','b','c'), value = c(1:3))
y <- data.frame(code = c('a','b','c'), roman = c('I','II','III'))
x %>% safe_join(y)
try(
x %>% safe_join(rbind(y,y))
)

bergsmat/wrangle documentation built on Aug. 29, 2023, 11:28 a.m.