targets::tar_map() example? (R targets static branching)
Asked Answered
H

1

6

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

Hildredhildreth answered 26/2, 2022 at 6:8 Comment(0)
A
6

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

Appurtenance answered 4/5, 2022 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.