The Damerau-Levenshtein distance between the two strings "abc" and "acb" would be 1, because it involves one transposition between "b" and "c".
> stringdist("abc", "acb", method = "dl")
[1] 1
Now suppose that I have the following two character vectors:
A = c("apple", "banana", "citrus")
B = c("apple", "citrus", "banana")
How can I calculate the Damerau-Levenshtein distance between A and B so that the result is identical to the distance between "abc" and "acb", since there is one transposition between "citrus" and "banana"? In other words, how can I calculate the Damerau-Levenshtein distance between A and B so that each item is counted as one character within a string?
What about
The basic idea here is:
x
vsy
and visa-versa. Each of these are 1 permutationduplicated(abs(...))
. Egabcd
,badc
is 2 permutations whileabcd
,bdca
is 3.That is very similar to how
stringdist
works for single strings.