Skip to content

tar_map() seems to cause dataframes to output as lists #76

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

You must be logged in to vote

tar_map() works by creating the R expressions for target commands. This works well for atomic scalar values like character strings and numerics (also symbols), but not so well with complicated objects with attributes. In your case, tar_map() is trying to turn the cars data frame into an R expression that evaluates to that data frame.

targets::tar_script({
  list(
    tarchetypes::tar_map(
      list(a = list(cars)),
      names = id,
      targets::tar_target(y, a)
    )
  )
})
targets::tar_manifest()$command
#> [1] "list(c(4, 4, 7, 7, 8, 9, 10, 10, 10, 11, 11, 12, 12,  \\n     12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16,  \\n     17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 20,…

Replies: 2 comments 3 replies

Comment options

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

@wlandau
Comment options

Answer selected by shirdekel
Comment options

You must be logged in to vote
1 reply
@wlandau
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
2 participants