-
Help
DescriptionI have two paths with dynamic targets that need to exist independently until a common step is shared. I was hoping to map over each item for both dynamic targets 1 by 1, and then have a new dynamic target made that's a stacked version of the two that were previously separate. I then use this stacked set for further processes until it is collapsed much further along. I dont want to combine into a single target right away due to the size of each member of the dynamic targets. For simplicity, this is the type of relationship up until the desired stacking of two dynamic target collections: However, I cannot seem to find a way to achieve this. Most of the Is what I am trying to do achievable in {targets}?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hello, I suggest using library(targets)
tar_dir({ # tar_dir() runs code from a temp dir for CRAN.
tar_script({
library(targets)
library(tarchetypes)
list(
tar_target(x, seq_len(2)),
tar_target(y, seq_len(2)),
dyn1 <- tar_target(dynamic1, c(x, y), pattern = map(x, y)),
dyn2 <- tar_target(dynamic2, c(x, y), pattern = map(x, y)),
tar_combine(name = newdynam,
dyn1,
dyn2,
command = list(!!!.x))
)
})
tar_make()
#tar_glimpse()
tar_read(newdynam)
})
#> + x dispatched
#> ✔ x completed [0ms, 98 B]
#> + y dispatched
#> ✔ y completed [0ms, 98 B]
#> + dynamic1 declared [2 branches]
#> ✔ dynamic1 completed [1ms, 99 B]
#> + dynamic2 declared [2 branches]
#> ✔ dynamic2 completed [0ms, 99 B]
#> + newdynam dispatched
#> ✔ newdynam completed [0ms, 173 B]
#> ✔ ended pipeline [170ms, 7 completed, 0 skipped]
#> $dynamic1
#> dynamic1_e549c33e20e5d0e3_1 dynamic1_e549c33e20e5d0e3_2
#> 1 1
#> dynamic1_6521f729ca5913cd_1 dynamic1_6521f729ca5913cd_2
#> 2 2
#>
#> $dynamic2
#> dynamic2_e549c33e20e5d0e3_1 dynamic2_e549c33e20e5d0e3_2
#> 1 1
#> dynamic2_6521f729ca5913cd_1 dynamic2_6521f729ca5913cd_2
#> 2 2 Created on 2025-06-18 with reprex v2.1.1 Depending on what exact object are to be combined, you can adapt the |
Beta Was this translation helpful? Give feedback.
Apologies if my use case is a bit confusing or attempting to use {targets} in a less common pattern. Normally, I would have all the necessary branches defined when the dynamic target was first created (via
tar_files_input()
), but in this situation the seconddynamic2
target depends on the final member fromdynamic1
and it would be great ifdynamic2
branches could just be appended todynamic1
once the branches fromdynamic2
are known. Since they are large objects, the branching structure needs to be preserved.In summary then, there is currently no way to "append" all branches from multiple dynamic targets to a new dynamic target? One cannot create a new dynamic target (like
dynamic3
in th…