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

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



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 yogevmh