Canonical tidyverse method to update some values of a vector from a look-up table
22
3
I frequently need to recode some (not all!) values in a data frame column based off of a look-up table. I'm not satisfied by the ways I know of to solve the problem. I'd like to be able to do it in a clear, stable, and efficient way. Before I write my own function, I'd want to make sure I'm not duplicating something standard that's already out there. ## Toy example data = data.frame( id = 1:7, x = c("A", "A", "B", "C", "D", "AA", ".") ) lookup = data.frame( old = c("A", "D", "."), new = c("a", "d", "!") ) ## desired result # id x # 1 1 a # 2 2 a # 3 3 B # 4 4 C # 5 5 d # 6 6 AA # 7 7 ! I c...