R/use_dictionary.R
use_dictionary.Rd
Substitute Values that are in a Dictionary with their Keys
use_dictionary(x, dict, method = "full")
x | vector of character |
---|---|
dict | list of key = value pairs. Values of this list that are found in
|
method | method to be applied, must be one of "full" or "part".
If "full", the full values must match, otherwise the values in |
x
in which values or parts of the values are replaced with
their short forms as they are defined in the dictionary dict
# Define a vector of long values x <- c("What a nice day", "Have a nice day", "Good morning") # Define short forms for full or partial values dict_full <- list(wand = "What a nice day", gm = "Good morning") dict_part <- list(w = "What", nd = "nice day", g = "Good") # Replace long form values with their short forms kwb.pathdict:::use_dictionary(x, dict_full, method = "full")#> [1] "<wand>" "Have a nice day" "<gm>"#> [1] "<w> a <nd>" "Have a <nd>" "<g> morning"