Skip to content

[help] map on a list passes list elements to the command. #1216

Closed Answered by eliocamp
eliocamp asked this question in Help
Discussion options

You must be logged in to vote

Ah, sorry, I had misunderstood how the iteration argument worked. I though it determined how the pattern did the iteration, but instead is a property of how will the target be iterated with map.

This now works.

targets::tar_dir({ 
  targets::tar_script({
    
    list(
      targets::tar_target(paths_list, as.list(1:3), iteration = "list"),
      
      targets::tar_target(
        x,
        is.list(paths_list),
        pattern = map(paths_list)
      )
    )
  })
  targets::tar_make()
  
  targets::tar_read(x)
  
})
#> ▶ dispatched target paths_list
#> ● completed target paths_list [0.001 seconds]
#> ▶ dispatched branch x_bed6a16d
#> ● completed branch x_bed6a16d [0.001 seconds]
#> ▶ di…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@eliocamp
Comment options

@wlandau
Comment options

Comment options

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

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