Skip to content

[help] feeding information from helper table to select targets to purr::reduce #148

Closed Answered by wlandau
nicki-dese asked this question in Help
Discussion options

You must be logged in to vote

From ?purrr::reduce, it looks like informal ... arguments are constant arguments to .f rather than part of the vector being reduced, and ... is discouraged anyway. We really want those data frames to be part of .x.

tar_manifest() shows that command of the combined target looks like this:

cat(tar_manifest()$command[[3]])
#> reduce(split_sepal = split_sepal, split_species = split_species, 
#>      merge, by = "row_id", all.x = T, all.y = T)

What we really want is something like this:

reduce(
  .x = list(split_sepal = split_sepal, split_species = split_species),
  .f = \(x, y) merge(x = x, y = y, by = "row_id", all.x = TRUE, all.y = TRUE)
)

The following _targets.R file seems to work:

# _tar…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nicki-dese
Comment options

Answer selected by nicki-dese
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