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

  name = NULL,
  default = NA_character_,
  create_dir = FALSE,
  store = targets::tar_config_get("store")



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


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.


Logical of length 1, whether to create dirname(tar_path()) in tar_path() itself. This is useful if you are writing to tar_path() from inside a storage = "none" target and need the parent directory of the file to exist.


Character of length 1, path to the targets data store. Defaults to tar_config_get("store"), which in turn defaults to _targets/. When you set this argument, the value of tar_config_get("store") is temporarily changed for the current function call. See tar_config_get() and tar_config_set() for details about how to set the data store path persistently for a project.


Character, file path of the return value of the target. If not called from inside a running target, 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.

For non-cloud storage formats, if you call tar_path() with no arguments while target x is running, the name argument defaults to the name of the running target, so tar_path() returns _targets/objects/x.

For cloud-backed formats, tar_path() returns the path to the staging file in _targets/scratch/. That way, even if you select a cloud format (e.g. tar_target(..., format = "aws_parquet", storage = "none")) then you can still manually write to tar_path(create_dir = TRUE) and the targets package will automatically hash it and upload it to the AWS S3 bucket. This does not apply to formats "file" or "aws_file", where you would never need storage = "none" anyway.

See also

Other utilities: tar_cancel(), tar_definition(), tar_envir(), tar_group(), tar_name(), tar_seed()


#> [1] NA
#> [1] "_targets/objects/your_target"
if (identical(Sys.getenv("TAR_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) }) }