I have two very large dataframes containing names of people. The two dataframes report different information on these people (i.e. df1 reports data on health status and df2 on socio-economic status). A subset of people appears in both dataframes. This is the sample I am interested in. I would need to create a new dataframe which includes only those people appearing in both datasets. There are, however, small differences in the names, mostly due to typos.
My data is as follows:
df1
name | smoker | age
"Joe Smith" | Yes | 43
"Michael Fagin" | Yes | 35
"Ellen McFarlan" | No | 55
...
...
df2
name | occupation | location
"Joe Smit" | Postdoc | London
"Joan Evans" | IT consultant | Bristol
"Michael Fegin" | Lawyer | Liverpool
...
...
What I would need is to have a third dataframe df3 with the following information:
df3
name1 | name2 | distance | smoker | age | occupation | location
"Joe Smith" | "Joe Smit" | a measure of their Jaro distance | Yes | 43 | Postdoc | London
"Michael Fagin" | "Michael Fegin" | a measure of their Jaro distance | Yes | 35 | Lawyer | Liverpool
...
...
So far I have worked with the stringdist package to get a vector of possible matches, but I am struggling to use this information to create a new dataframe with the information I need. Many thanks in advance should anyone have an idea for this!