Skip to content

[help] Dynamically branch over pairs of file paths #1179

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

You must be logged in to vote

The approach you sketched should work. What error are you seeing? The example below works for me.

# _targets.R file:
library(targets)

writeLines("first_2000", "first_2000.txt")
writeLines("first_2020", "first_2020.txt")
writeLines("second_2000", "second_2000.txt")
writeLines("second_2020", "second_2020.txt")

list(
  tar_target(year, c(2000, 2020)),
  tar_target(
    first_files, 
    glue::glue("first_{year}.txt"),
    pattern = map(year),
    format = "file"
  ),
  tar_target(
    second_files,
    glue::glue("second_{year}.txt"),
    pattern = map(year),
    format = "file"
  ),
  tar_target(
    bind_files,
    paste(readLines(first_files), readLines(second_files)),
    pattern = map(f…

Replies: 1 comment 1 reply

Comment options

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

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