Learn R Programming

targets (version 0.4.1)

tar_envir: For developers only: get the environment of the current target.

Description

For developers only: get the environment where a target runs its command. Inherits from tar_option_get("envir").

Usage

tar_envir(default = parent.frame())

Arguments

default

Environment, value to return if tar_envir() 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

If called from a running target, tar_envir() returns the environment where the target runs its command. If called outside a pipeline, the return value is whatever the user supplies to default (which defaults to parent.frame()).

Details

Users should not call tar_envir() directly because accidental modifications to parent.env(tar_envir()) could break the pipeline. tar_envir() only exists in order to support third-party interface packages such as tarchetypes.

See Also

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

Examples

Run this code
# NOT RUN {
tar_envir()
tar_envir(default = new.env(parent = emptyenv()))
if (identical(Sys.getenv("TAR_LONG_EXAMPLES"), "true")) {
tar_dir({ # tar_dir() runs code from a temporary directory.
tar_script(tar_target(x, tar_envir(default = parent.frame())))
tar_make(x)
tar_read(x)
})
}
# }

Run the code above in your browser using DataLab