Approximate String Matching (Fuzzy Matching)
Searches for approximate matches to
pattern (the first argument)
within each element of the string
x (the second argument) using
the generalized Levenshtein edit distance (the minimal possibly
weighted number of insertions, deletions and substitutions needed to
transform one string into another).
1 2 3 4 5 6
a non-empty character string or a character string
containing a regular expression (for
character vector where matches are sought.
Maximum distance allowed for a match. Expressed either as integer, or as a fraction of the pattern length times the maximal transformation cost (will be replaced by the smallest integer not less than the corresponding fraction), or a list with possible components
a numeric vector or list with names partially matching
insertions, deletions and substitutions giving
the respective costs for computing the generalized Levenshtein
logical. in a multibyte locale, should the comparison be character-by-character (the default) or byte-by-byte.
The Levenshtein edit distance is used as measure of approximateness: it is the (possibly cost-weighted) total number of insertions, deletions and substitutions required to transform one string into another.
tre by Ville Laurikari
(http://laurikari.net/tre/), which supports MBCS
The main effect of
useBytes is to avoid errors/warnings about
invalid inputs and spurious matches in multibyte locales.
It inhibits the conversion of inputs with marked encodings, and is
forced if any input is found which is marked as
agrep returns a vector giving the indices of the elements that
yielded a match, or, if
TRUE, the matched
elements (after coercion, preserving names but no other attributes).
agrepl returns a logical vector.
Since someone who read the description carelessly even filed a bug
report on it, do note that this matches substrings of each element of
x (just as
grep does) and not whole
elements. See also
adist in package utils, which
optionally returns the offsets of the matched substrings.
Original version in R < 2.10.0 by David Meyer. Current version by Brian Ripley and Kurt Hornik.
1 2 3 4 5
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.