findSimilarName: Looks for approximate matches to 'x' (the first argument)...

Description Usage Arguments See Also Examples

Description

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

Usage

1
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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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)

DYM documentation built on May 2, 2019, 3:37 p.m.

Related to findSimilarName in DYM...