tar_map {tarchetypes} | R Documentation |
Static branching.
Description
Define multiple new targets based on existing target objects.
Usage
tar_map(
values,
...,
names = tidyselect::everything(),
descriptions = tidyselect::everything(),
unlist = FALSE
)
Arguments
values |
Named list or data frame with values to iterate over.
The names are the names of symbols in the commands and pattern
statements, and the elements are values that get substituted
in place of those symbols. |
... |
One or more target objects or list of target objects.
Lists can be arbitrarily nested, as in |
names |
Subset of |
descriptions |
Names of a column in |
unlist |
Logical, whether to flatten the returned list of targets.
If |
Details
tar_map()
creates collections of new
targets by iterating over a list of arguments
and substituting symbols into commands and pattern statements.
Value
A list of new target objects. If unlist
is FALSE
,
the list is nested and sub-lists are named and grouped by the original
input targets. If unlist = TRUE
, the return value is a flat list of
targets named by the new target names.
See the "Target objects" section for background.
Target objects
Most tarchetypes
functions are target factories,
which means they return target objects
or lists of target objects.
Target objects represent skippable steps of the analysis pipeline
as described at https://books.ropensci.org/targets/.
Please read the walkthrough at
https://books.ropensci.org/targets/walkthrough.html
to understand the role of target objects in analysis pipelines.
For developers, https://wlandau.github.io/targetopia/contributing.html#target-factories explains target factories (functions like this one which generate targets) and the design specification at https://books.ropensci.org/targets-design/ details the structure and composition of target objects.
See Also
Other branching:
tar_combine()
,
tar_combine_raw()
,
tar_map2()
,
tar_map2_count()
,
tar_map2_count_raw()
,
tar_map2_raw()
,
tar_map2_size()
,
tar_map2_size_raw()
,
tar_map_rep()
,
tar_map_rep_raw()
,
tar_rep()
,
tar_rep2()
,
tar_rep2_raw()
,
tar_rep_map()
,
tar_rep_map_raw()
,
tar_rep_raw()
Examples
if (identical(Sys.getenv("TAR_LONG_EXAMPLES"), "true")) {
targets::tar_dir({ # tar_dir() runs code from a temporary directory.
targets::tar_script({
list(
tarchetypes::tar_map(
list(a = c(12, 34), b = c(45, 78)),
targets::tar_target(x, a + b),
targets::tar_target(y, x + a, pattern = map(x))
)
)
})
targets::tar_manifest()
})
}