Assign Id to fuzzy match name in new table - R

41 Views Asked by At

I have two tables. Table one has an id column and a full_name column. Table two has only a full name column but the names are near-matches and not full matches. I would like to apply the id column to the second table so that the ids apply to the correct near-match names. My tables look like this:

df1 <- read.table(text="
id  full_name
1   'Tom Jones'
2   'Jim James'", header = TRUE)

df2 <- read.table(text="
full_name
'Tom Jones Jr.'
'Jim James Ii'", header = TRUE)

I would like Table 2 to end up like this:

id full_name
1 Tom Jones Jr.
2 Jim James Ii

I have tried stringdist_join and would like to ideally do in in dplyr but I'm not sure thats possible. Any help would be appreciated. Thanks.

0

There are 0 best solutions below