Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring case sensitvity in dplyr joins

Is there a way to ignore case sensitvity when doing joins using dplyr? left, inner, and full?

I see it works with select but this often a huge pain for me. I know I can convert the columns toupper or tolower before hand, but this would be a helpful work around.

like image 736
runningbirds Avatar asked May 20 '16 06:05

runningbirds


1 Answers

I don't think there's a straightforward way to get around using tolower or toupper to tidy the data first. That said, an inline mutate (inside the join) would leave the original data untouched if that is preferred.

X %>% left_join(Y %>% mutate(id = tolower(id)), by = "id")

It works, but we might as well have created a tidy Y with ids to match X in the first place (in my opinion).

like image 99
Damian Avatar answered Sep 28 '22 06:09

Damian