targets::tar_map() example? (R targets static branching)

Viewed 145

Does anyone have an example of how to use static branching from the targets package (R)? I'm reading targets manual on static branching but I'm having a hard time understanding it (even though I do get dynamic branching).

https://books.ropensci.org/targets/static.html

1 Answers

Here's an example _targets.R very similar to a project I have:

library(targets)
library(tarchetypes)
library(dplyr)

params <- tribble(
  ~name, ~arg1,  ~arg2,  
  "A",  "a",  1,    
  "B",  "b",  2,
  "C",  "c",  3  
) 

mapped_pipeline <- tar_map(
  values = params, 
  names = "name",
  tar_target(first_target,
             f(arg1, arg2)),
  tar_target(second_target,
             g(first_target)
  )
)

tar_pipeline(pipeline)

And the pipeline looks something like this: enter image description here

Related