-
Help
DescriptionHello, thanks again for I would like to combine the nested Nested static without combine stepFirst static is for 2 models of distributions (1 and 2) and for each (nested # modified from https://github.com/ropensci/targets/discussions/348#discussioncomment-500050
targets::tar_dir({
library(targets)
tar_script({
library(targets)
library(tarchetypes)
tar_map(
values = list(model = c("mod_1", "mod_2")),
tar_target(
distrib,
tar_name(),
),
# static in static: nested tar_map()
tar_map(
values = list(sim = c("A", "B")),
tar_target(
estim,
paste(distrib, tar_name()),
)
)
)
})
tar_make()
tar_read(estim_B_mod_2)
tar_visnetwork()
})
#> ▶ dispatched target distrib_mod_1
#> ● completed target distrib_mod_1 [0.001 seconds]
#> ▶ dispatched target distrib_mod_2
#> ● completed target distrib_mod_2 [0 seconds]
#> ▶ dispatched target estim_A_mod_1
#> ● completed target estim_A_mod_1 [0 seconds]
#> ▶ dispatched target estim_B_mod_1
#> ● completed target estim_B_mod_1 [0 seconds]
#> ▶ dispatched target estim_A_mod_2
#> ● completed target estim_A_mod_2 [0 seconds]
#> ▶ dispatched target estim_B_mod_2
#> ● completed target estim_B_mod_2 [0 seconds]
#> ▶ ended pipeline [0.281 seconds] Created on 2024-06-05 with reprex v2.1.0 Nested static with a combination for all estimatorsWorks but I would like a combination per distribution, not all 4 together targets::tar_dir({
library(targets)
tar_script({
library(targets)
library(tarchetypes)
mapped <- tar_map(
#unlist = FALSE, # Return a nested list from tar_map()
values = list(model = c("mod_1", "mod_2")),
tar_target(
distrib,
tar_name(),
),
# static in static
tar_map(
values = list(sim = c("A", "B")),
tar_target(
estim,
paste(distrib, tar_name()),
)
)
)
combined <- tar_combine(combi,
# select both _A and _B while we want per model
tar_select_targets(mapped, starts_with("estim")),
command = paste(!!!.x))
list(mapped, combined)
})
tar_make()
tar_read(combi)
tar_visnetwork()
})
#> ▶ dispatched target distrib_mod_1
#> ● completed target distrib_mod_1 [0.001 seconds]
#> ▶ dispatched target distrib_mod_2
#> ● completed target distrib_mod_2 [0 seconds]
#> ▶ dispatched target estim_A_mod_1
#> ● completed target estim_A_mod_1 [0 seconds]
#> ▶ dispatched target estim_B_mod_1
#> ● completed target estim_B_mod_1 [0 seconds]
#> ▶ dispatched target estim_A_mod_2
#> ● completed target estim_A_mod_2 [0 seconds]
#> ▶ dispatched target estim_B_mod_2
#> ● completed target estim_B_mod_2 [0 seconds]
#> ▶ dispatched target combi
#> ● completed target combi [0 seconds]
#> ▶ ended pipeline [0.32 seconds] Created on 2024-06-05 with reprex v2.1.0 Trying the
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You're looking for this graph, right? If so, it may help to generate the library(targets)
library(tarchetypes)
inner <- tar_map(
values = list(sim = c("A", "B")),
tar_target(
estim,
paste(distrib, tar_name()),
)
)
combine <- tar_combine(combi, inner, command = paste(!!!.x))
tar_map(
values = list(model = c("mod_1", "mod_2")),
tar_target(distrib, tar_name()),
inner,
combine
) |
Beta Was this translation helpful? Give feedback.
You're looking for this graph, right?
If so, it may help to generate the
tar_combine()
target separately just using the pre-mappedestim
targets: