Replies: 1 comment 2 replies
-
If I understand correctly, you want some branches of target You can express this with nested library(targets)
library(tarchetypes)
list(
tar_map(
values = tibble::tibble(x = 1:2),
tar_target(a, x),
tar_map(
values = tibble::tibble(y = 1:2),
tar_target(b, a + y)
)
)
) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Help
Description
Intention: in the second
tar_map
, I want to access the outputs of the firsttar_map
with namea
statically expanded toa_1
anda_2
.However, when
tar_make
triggers the error:a
does not exist.I tried a few walkaround.
Those failed:
get(paste0("a_", y))
:a_1
is not in the envirtar_load(paste0("a_", y))
ortar_read(paste0("a_", y))
:tar_load
andtar_read
are not allowedThus, I have to explicitly include these variables so that they can be captured into the enclosure. Like:
Wrapping it up:
with some utils:
My question: Is there any better (tidier) way to collect branching outputs within
command
oftar_target
? For example, explicitly declare (withtidy_select
) names by an parameter oftar_target
.PS: the required feature may also affect construction of dependency DAG. But currently I only care about the former.
Beta Was this translation helpful? Give feedback.
All reactions