Remove target script helper files (default: _targets_r/
)
that were created by Target Markdown.
Usage
tar_unscript(script = targets::tar_config_get("script"))
Arguments
- 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.
Details
Target Markdown code chunks create R scripts in a folder
called _targets_r/
in order to aid the automatically supplied
_targets.R
file. Over time, the number of script files
starts to build up, and targets
has no way of automatically
removing helper script files that are no longer necessary.
To keep your pipeline up to date
with the code chunks in the Target Markdown document(s),
it is good practice to call tar_unscript()
at the beginning
of your first Target Markdown document. That way,
extraneous/discarded targets are automatically
removed from the pipeline when the document starts render.
If the target script is at some alternative path,
e.g. custom/script.R
, the helper scripts are in custom/script_r/
.
tar_unscript()
works on the helper scripts as long as your
project configuration settings correctly identify the correct
target script.
Examples
tar_dir({ # tar_dir() runs code from a temp dir for CRAN.
tar_unscript()
})