Learn R Programming

targets (version 0.4.1)

tar_path: Identify the file path where a target will be stored.

Description

Identify the file path where a target will be stored after the target finishes running in the pipeline.

Usage

tar_path(name = NULL, default = NA_character_)

Arguments

name

Symbol, name of a target. If NULL, tar_path() returns the path of the target currently running in a pipeline.

default

Character, value to return if tar_path() is called on its own outside a targets pipeline. Having a default lets users run things without tar_make(), which helps peel back layers of code and troubleshoot bugs.

Value

Character, file path to a hypothetical target.

Details

tar_path(name = your_target) just returns _targets/objects/your_target, the file path where your_target will be saved unless format is equal to "file" or any of the supported cloud-based storage formats. If you call tar_path() with no arguments while target x is running, the name argument defaults to the name of the target, so tar_path() returns _targets/objects/x.

See Also

Other utilities: tar_cancel(), tar_envir(), tar_group(), tar_name(), tar_seed(), tar_timestamp_raw(), tar_timestamp()

Examples

Run this code
# NOT RUN {
tar_path()
tar_path(your_target)
if (identical(Sys.getenv("TAR_LONG_EXAMPLES"), "true")) {
tar_dir({ # tar_dir() runs code from a temporary directory.
tar_script(tar_target(returns_path, tar_path()), ask = FALSE)
tar_make()
tar_read(returns_path)
})
}
# }

Run the code above in your browser using DataLab