Learn R Programming

targets (version 0.7.0)

tar_config_set: Write configuration settings to _targets.yaml.

Description

tar_config_set() writes special custom settings to an optional project-level YAML configuration file (default: _targets.yaml). Most of these settings are default arguments shared across multiple functions called outside _targets.R.

Usage

tar_config_set(
  config = "_targets.yaml",
  reporter_make = NULL,
  reporter_outdated = NULL,
  store = NULL,
  shortcut = NULL,
  script = NULL,
  workers = NULL
)

Arguments

config

Character of length 1, path to the YAML file with all the configuration settings (default: _targets.yaml).

reporter_make

Character of length 1, reporter argument to tar_make() and related functions that run the pipeline.

reporter_outdated

Character of length 1, reporter argument to tar_outdated() and related functions that do not run the pipeline.

store

Character of length 1, path to the data store of the pipeline. If NULL, the store setting is left unchanged in the YAML configuration file (default: _targets.yaml). Usually, the data store lives at _targets. Set store to a custom directory to specify a path other than _targets/. The path need not exist before the pipeline begins, and it need not end with "_targets", but it must be writeable. For optimal performance, choose a storage location with fast read/write access.

shortcut

logical of length 1, default shortcut argument to tar_make() and related functions.

script

Character of length 1, path to the target script file that defines the pipeline (_targets.R by default). This path should be either an absolute path or a path relative to the project root where you will call tar_make() and other functions. When tar_make() and friends run the script from the current working directory.

workers

Positive numeric of length 1, workers argument of tar_make_clustermq() and related functions that run the pipeline with parallel computing among targets.

Value

NULL (invisibly)

Details

Each project can have an optional YAML configuration file (default: _targets.yaml at the project root) with settings specific to a given project. You can either write it by hand or modify it with tar_config_set(), but tar_config_set() is recommended because it has guardrails to validate user input. The currently supported configuration settings are documented as the arguments of tar_config_set().

tar_config_set() always writes a YAML file with a full set of configuration settings even when no arguments are supplied. To reset options completely, simply call tar_config_set(config = "_targets.yaml") and remove _targets.yaml if it exists.

See Also

Other configuration: tar_config_get(), tar_envvars(), tar_option_get(), tar_option_reset(), tar_option_set()

Examples

Run this code
# NOT RUN {
if (identical(Sys.getenv("TAR_EXAMPLES"), "true")) {
tar_dir({ # tar_dir() runs code from a temporary directory.
tar_script(list(tar_target(x, 1 + 1)))
tar_config_get("store") # NULL (data store defaults to "_targets/")
store_path <- tempfile()
tar_config_set(store = store_path)
tar_config_get("store") # Shows a temp file.
tar_make() # Writes to the custom data store identified in _targets.yaml.
tar_read(x) # tar_read() knows about _targets.yaml too.
file.exists("_targets") # FALSE
file.exists(store_path) # TRUE
})
}
# }

Run the code above in your browser using DataLab