Skip to content

[help] How to static branch over a hierarchical object? #162

Closed Answered by wlandau
stulacy asked this question in Help
Discussion options

You must be logged in to vote

The helpers in tarchetypes are designed for functional programming over a flattened list of inputs. For a hierarchical structure, it is probably clearer to write out each target manually, even if you have upwards of 10 or 20 of them. If you have hundreds, then it could get cumbersome, but you could reduce the volume of code if each inner list is a tar_map().

library(targets)
library(tarchetypes)
list(
  tar_target(data_a, get_data(id = "a")),
  tar_target(data_b, get_data(id = "b")),
  tar_map(
    values = list(species_name = c("CO2", "CO")),
    tar_target(species_a, f(data_a, species_name))
  ),
  tar_map(
    values = list(species_name = c("NH3", "NO2", "CH3")),
    tar_target(species_b

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stulacy
Comment options

Answer selected by stulacy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants