Skip to content

[help] tar_eval() cannot track targets nested in list #153

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

You must be logged in to vote

substitute(list(x), env = list(x = rlang::syms(list("y", "z")))) and substitute(list(x), env = list(x = quote(list(y, z)))) may look the same when you print them, but the returned objects are actually very different. The former has a non-language list object in place of x, whereas the latter is a better language object with true language objects at every level of the abstract syntax tree. tar_eval() is built on substitute(), so it works the same way. The following _targets.R file does what you want.

# _targets.R
library(targets)
list(
  tar_target(x, 1),
  tar_target(y, 2),
  tarchetypes::tar_eval(
    tar_target(name, list(val)),
    values = tibble::tribble(
      ~name, ~val,
      quote(

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@psychelzh
Comment options

@psychelzh
Comment options

@psychelzh
Comment options

@psychelzh
Comment options

Answer selected by psychelzh
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