Function factory for archived targets
Usage
tar_archive(
f,
package,
pipeline,
envir = parent.frame(),
script = targets::tar_config_get("script"),
store = targets::tar_config_get("store")
)Arguments
- f
A function of targets package.
- package
A scalar character of the package name.
- pipeline
A scalar character of the pipeline name.
- envir
An environment, where to run the target R script (default:
_targets.R) ifcallr_functionisNULL. Ignored ifcallr_functionis anything other thanNULL.callr_functionshould only beNULLfor debugging and testing purposes, not for serious runs of a pipeline, etc.The
envirargument oftar_make()and related functions always overrides the current value oftar_option_get("envir")in the current R session just before running the target script file, so whenever you need to set an alternativeenvir, you should always set it withtar_option_set()from within the target script file. In other words, if you calltar_option_set(envir = envir1)in an interactive session and thentar_make(envir = envir2, callr_function = NULL), thenenvir2will be used.- script
Character of length 1, path to the target script file. Defaults to
tar_config_get("script"), which in turn defaults to_targets.R. When you set this argument, the value oftar_config_get("script")is temporarily changed for the current function call. Seetar_script(),tar_config_get(), andtar_config_set()for details about the target script file and how to set it persistently for a project.- store
Character of length 1, path to the
targetsdata store. Defaults totar_config_get("store"), which in turn defaults to_targets/. When you set this argument, the value oftar_config_get("store")is temporarily changed for the current function call. Seetar_config_get()andtar_config_set()for details about how to set the data store path persistently for a project.
Examples
tar_outdated_archive <- tar_archive(
targets::tar_outdated,
package = "tarchives",
pipeline = "example-model"
)
# \donttest{
withr::with_envvar(
c(R_USER_CACHE_DIR = tempfile()),
tar_outdated_archive()
)
#> [1] "data" "model"
# }