tar_map | R Documentation |
Define multiple new targets based on existing target objects.
tar_map(
values,
...,
names = tidyselect::everything(),
descriptions = tidyselect::everything(),
unlist = FALSE,
delimiter = "_"
)
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 |
delimiter |
Character of length 1, string to insert between other strings when creating names of targets. |
tar_map()
creates collections of new
targets by iterating over a list of arguments
and substituting symbols into commands and pattern statements.
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.
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.
Other static branching:
tar_combine()
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()
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.