Assuming you have:
one <- c("toyota","walmart","fox ad company")
two <- c("sales walmart","fox advertisement company","metro toyota")
You could extract the match with the minimum string distance, as calculated by adist
. This is probably open to error, but it will give you a start. See ?adist
for how you might edit this to only look at additions, substitutions or insertions of characters.
max.col(-adist(one,two))
#[1] 3 1 2
Matches up okay:
data.frame(one, two=two[max.col(-adist(one,two))])
# one two
#1 toyota metro toyota
#2 walmart sales walmart
#3 fox ad company fox advertisement company