Examples for 'utils::adist'


Approximate String Distances

Aliases: adist

Keywords: character

### ** Examples

## Cf. https://en.wikipedia.org/wiki/Levenshtein_distance
adist("kitten", "sitting")
     [,1]
[1,]    3
## To see the transformation counts for the Levenshtein distance:
drop(attr(adist("kitten", "sitting", counts = TRUE), "counts"))
ins del sub 
  1   0   2 
## To see the transformation sequences:
attr(adist(c("kitten", "sitting"), counts = TRUE), "trafos")
     [,1]      [,2]     
[1,] "MMMMMM"  "SMMMSMI"
[2,] "SMMMSMD" "MMMMMMM"
## Cf. the examples for agrep:
adist("lasy", "1 lazy 2")
     [,1]
[1,]    5
## For a "partial approximate match" (as used for agrep):
adist("lasy", "1 lazy 2", partial = TRUE)
     [,1]
[1,]    1

[Package utils version 4.2.3 Index]