nearest_arg | R Documentation |
It determines the nearest candidate value for each value in arg
. As a replacement for base::match.arg
since it is more (typo) error tolerant, but if a wrong choice will be done it is difficult to detect.
nearest_arg(arg, choices, method = "cosine", ...)
arg |
character: vector or NULL |
choices |
character: vector of candidate values |
method |
character: method for distance calculation (default: |
... |
further parameters for stringdist::stringdistmatrix |
for each value in arg
the (first) nearest element of choices
# match.arg("tow.sided", c("two.sided", "less", "greater")) # will fail
nearest_arg("tow.sided", c("two.sided", "less", "greater"))
nearest_arg(c("two.sided", "less", "greater"), c("two.sided", "less", "greater"))
nearest_arg(c("two", "two", "ded", "ss", "ea"), c("two.sided", "less", "greater"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.