How agrep negotiation works?

The agrep function gives some cryptic results, and I would like to better understand its behavior. For instance:

agrep("abcd",c("abc","abcde","abcef"),value=T,max.distance = 1)

Returns: [1] "abc" "abcde" "abcef"

But the distance between “abcd” and “abcef” is 2. So I'm not sure why the third match appears.

levenshteinDist("abcd","abcef") # gives the answer of 2

In addition, I assume that the function will only return exact matches if the distance limit is set to 0:

agrep("abcd",c("abc","abcde","abcef"),value=T,max.distance = 0)

However, I get [1] "abcde"as a coincidence

It would be very helpful if someone could explain how matching works in agrep.

+4
source share

All Articles