Skip to content

tar_map() losing names if values is a data frame with a list column #105

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

You must be logged in to vote

tar_map() substitutes simple objects, symbois, and expressions. Try wrapping your lists in quote() to treat them as expression objects.

targets::tar_script({
  MODELS <- tibble::tribble(
    ~NAME, ~PARAMS,
    1, quote(list(a = 3, b = 5, c = 25)), # quote()
    2, quote(list(a = 0, b = 1, c = 42))  # quote()
  )
  
  list(
    tarchetypes::tar_map(
      values = MODELS,
      names = NAME,
      targets::tar_target(params, PARAMS)
    )
  )
})

targets::tar_manifest()
#> # A tibble: 2 × 2
#>   name     command                   
#>   <chr>    <chr>                     
#> 1 params_1 list(a = 3, b = 5, c = 25)
#> 2 params_2 list(a = 0, b = 1, c = 42)

Created on 2022-09-05 with reprex v2.0.2

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by MarekGierlinski
Comment options

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

Comment options

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

@wlandau
Comment options

Comment options

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

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