findSimilarName

0th

Percentile

Looks for approximate matches to x (the first argument) within name (the second) argument.

Looks for approximate matches to x (the first argument) within name (the second) argument.

Usage
findSimilarName(x, names, threshold = 2, max_n = 10, ignoreCase = FALSE)
Arguments
x
A string giving the (misspelt) name to search for.
names
A character vector of correct names to match against.
threshold
The maximum distance between the misspell (x) and the correct answer (in name).
max_n
An integer limiting the number of results. Passed to head.
ignoreCase
A logical value indicating whether differences in case should be ignored when matching. Passed to adist.
See Also

adist calculates the distance between strings. agrep and stringdist-package provide alternate metrics for these distances.

Aliases
  • findSimilarName
Examples

x <- "logg"
names <- DYM:::getNames(x)
# Increasing threshold increases the number of hits, upto max_n = 10
lapply(
  stats::setNames(0:4, 0:4), 
  function(i) DYM:::findSimilarName(x, names, threshold = i)
)

# Use max_n = Inf to return all hits
DYM:::findSimilarName(x, names, threshold = 3, max_n = Inf)

# Negative max_n returns all hits except the last max_n
DYM:::findSimilarName(x, names, threshold = 3, max_n = -40)

# Set ignoreCase = TRUE to get more matches that differ by letter case
DYM:::findSimilarName(x, names, ignoreCase = TRUE)

Documentation reproduced from package DYM, version 0.2, License: BSD_3_clause + file LICENSE

Community examples

Looks like there are no examples yet.