lookup | R Documentation |
Looks up all values as keys of the dictionary and returns the values.
lookup(dict, ..., default = NA, dict_key_is_regex = F, key_is_regex = F) lookup_int(dict, ..., default = NA, dict_key_is_regex = F, key_is_regex = F) lookup_chr(dict, ..., default = NA, dict_key_is_regex = F, key_is_regex = F) lookup_lgl(dict, ..., default = NA, dict_key_is_regex = F, key_is_regex = F) lookup_dbl(dict, ..., default = NA, dict_key_is_regex = F, key_is_regex = F) lookup_num(dict, ..., default = NA, dict_key_is_regex = F, key_is_regex = F)
dict |
A dictionaryish vector (named: key -> value) |
... |
Keys to lookup in the dictionary |
default |
Default value to return if key is not found. Can be a value or function (called with the key).
Note: default is to return NA; another very intuitive case is to return the key itself.
To achieve this, pass |
dict_key_is_regex |
Should the dictionary keys, the names of dict, be regarded as regular expressions? (excludes key_is_regex) |
key_is_regex |
Should the keys to lookup be regarded as regular expressions? (excludes dict_key_is_regex) |
A list of the same size as ..., containing the lookup results. For the type-specific functions, returns a vector typed as requested, requiring all lookup results to have matching type.
a <- list("x", "y", "z") dict <- c(x="xc", y="yv") # returns c("xc", "yv", na_chr) lookup_chr(dict, a)#' # returns c("xc", "yv", "z") lookup_chr(dict, "x", "y", "z", default=identity)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.