Skip to content

Is it possible to "map" over tar_combine() #82

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

You must be logged in to vote

Thanks, @jdtrat. In your case, I think it would be convenient to put the tar_combine() target inside tar_map(). Sketch:

library(targets)
  
tar_script({
  library(tarchetypes)
  library(tidyselect)
  
  # https://armchairecology.blog/iris-dataset/
  # https://allisonhorst.github.io/palmerpenguins/
  library(palmerpenguins)
  
  subsets <- list(
    tar_target(
      first,
      head(data)
    ),
    tar_target(
      last,
      tail(data)
    )
  )
  
  combined <- tar_combine(
    combined,
    subsets,
    command = dplyr::bind_rows(!!!.x)
  )
  
  tar_map(
    list(subsets, combined),
    values = tibble::tibble(
      data = rlang::syms(c("mtcars", "penguins"))
    ),
    unlist = TRUE

Replies: 1 comment 1 reply

Comment options

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

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