Skip to contents

Resolve all Placeholders in a Dictionary

Usage

resolveAll(dictionary, ...)

Arguments

dictionary

list with named elements where the element name represents the key and the element value represents the value assigned to the key.

...

additional assignments of the form <key> = <value> that are temporarily added to the dictionary before doing the resolving

Examples

# Define a dictionary in the form of a list
dictionary <- list(
  basedir = "C:/myNicefolder",
  projectdir = "<basedir>/projects/<project_name>",
  inputdir = "<projectdir>/input",
  outputdir = "<projectdir>/output"
)

# Resolve all entries in the dictionary, with different values for the
# placeholder "<project_name> which is undefined in the original dictionary
dictionary.1 <- resolveAll(dictionary, project_name = "project_1")
dictionary.2 <- resolveAll(dictionary, project_name = "project_2")

# Define entries of the dictionary to resolve
keys <- c("inputdir", "outputdir")

# Resolve the entries using the two different dictionaries
resolve(keys, dictionary.1)
#> [1] "C:/myNicefolder/projects/project_1/input" 
#> [2] "C:/myNicefolder/projects/project_1/output"
resolve(keys, dictionary.2)
#> [1] "C:/myNicefolder/projects/project_2/input" 
#> [2] "C:/myNicefolder/projects/project_2/output"