prefix_match | R Documentation |
prefix_match
accepts a trie and a character vector
and returns the values associated with any key that has a particular
character vector entry as a prefix (see the examples).
prefix_match(trie, to_match, include_keys = FALSE)
trie |
a trie object, created with |
to_match |
a character vector containing the strings to check against the trie's keys. |
include_keys |
a logical value indicating whether to include the keys in the returned results or not. If TRUE (not the default) the returned object will be a list of data.frames, rather than of vector. |
a list, the length of to_match
, with each entry containing any trie values
where the to_match
element was a prefix of the associated key. In the case that
nothing was found, the entry will contain NA
.
longest_match
and greedy_match
for longest and greedy matching, respectively.
trie <- trie(keys = c("afford", "affair", "available", "binary", "bind", "blind"), values = c("afford", "affair", "available", "binary", "bind", "blind")) prefix_match(trie, "aff")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.