Title: | Did You Mean? |
---|---|
Description: | Add a "Did You Mean" feature to the R interactive. With this package, error messages for misspelled input of variable names or package names suggest what you really want to do in addition to notification of the mistake. |
Authors: | Kosei Abe [aut, cre], Richard Cotton [ctb] |
Maintainer: | Kosei Abe <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 0.2 |
Built: | 2024-11-19 05:40:35 UTC |
Source: | https://github.com/kos59125/dym |
You might mistype an object name. The package suggests the correct spell of the object you meant.
If the function is called after an error of 'object not found', the function tries to tell you the name of the correct name that you meant.
DYM(threshold = 2, max_n = 10, ignoreCase = FALSE)
DYM(threshold = 2, max_n = 10, ignoreCase = FALSE)
threshold |
The maximum distance between the misspell ( |
max_n |
An integer limiting the number of results. Passed to |
ignoreCase |
A logical value indicating whether differences in case should be ignored when matching. Passed to |
## Not run: options(error = DYM::DYM()) logg(10) # For fewer or more suggestions, change threshold, max_n and ignoreCase options(error = DYM::DYM(threshold = 3, max_n = 25, ignoreCase = TRUE)) logg(10) ## End(Not run)
## Not run: options(error = DYM::DYM()) logg(10) # For fewer or more suggestions, change threshold, max_n and ignoreCase options(error = DYM::DYM(threshold = 3, max_n = 25, ignoreCase = TRUE)) logg(10) ## End(Not run)
x
(the first argument)
within name
(the second) argument.Looks for approximate matches to x
(the first argument)
within name
(the second) argument.
findSimilarName(x, names, threshold = 2, max_n = 10, ignoreCase = FALSE)
findSimilarName(x, names, threshold = 2, max_n = 10, ignoreCase = FALSE)
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 ( |
max_n |
An integer limiting the number of results. Passed to |
ignoreCase |
A logical value indicating whether differences in case should be ignored when matching. Passed to |
adist
calculates the distance between strings.
agrep
and stringdist-package
provide alternate metrics for these distances.
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)
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)
When this function is called after an error, it looks for the error message of missing value and returns the name of the mistype if it is found.
getMissingVariable()
getMissingVariable()
Retrieves available symbols in the specified environment.
getNames(mode, envir = .GlobalEnv)
getNames(mode, envir = .GlobalEnv)
mode |
The mode of misspelled name. |
envir |
The base environment to search variables. |
name
is valid as a variable name for R.Checks if the given name
is valid as a variable name for R.
isVariableName(name)
isVariableName(name)
name |
A character vector to check. |