I'm having a hard time understanding how to do the equivalent of a look-up table in R. I've seen people suggest you should use "merges" in lieu of look-up tables, but I'm not sure what the right approach is:
Let's say I have the following:
set.seed(42)
person_ids <- data.frame(person_1_id = stringi::stri_rand_strings(100, 10, '[A-Z]'),
person_2_id = stringi::stri_rand_strings(100, 10, '[A-Z]'))
team_id_lookup <- data.frame(person_id = stringi::stri_rand_strings(100, 10, '[A-Z]'),
team_ids = floor(runif(100, min=0, max=500)))
I want to create two new columns in person_ids
-- team_id_1
and team_id_2
, which use the look up dataframe to find the corresponding team_ids for a given person_id and taking that value.
What is the right approach here?