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.
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))
)