StrDist
computes distances between strings following to Levenshtein or Hamming method.StrDist(x, y, method = "levenshtein", mismatch = 1, gap = 1)
"levenshtein"
or "hamming"
. Default is the classical
Levenshtein distance.StrDist
returns an object of class "dist"
; cf. dist
."ScoringMatrix"
and "TraceBackMatrix"
.
The numbers in the trace-back matrix reflect insertion of a gap in string y
(1),
match/missmatch (2), and insertion of a gap in string x
(3).adist
, dist
x <- "GACGGATTATG"
y <- "GATCGGAATAG"
## Levenshtein distance
d <- StrDist(x, y)
d
attr(d, "ScoringMatrix")
attr(d, "TraceBackMatrix")
## Hamming distance
StrDist(x, y, method="hamming")
Run the code above in your browser using DataLab