drake (version 6.2.1)

gather_plan: Write commands to combine several targets into one or more overarching targets.

Description

Creates a new workflow plan to aggregate existing targets in the supplied plan.

Usage

gather_plan(plan = NULL, target = "target", gather = "list",
  append = FALSE)

Arguments

plan

workflow plan data frame of prespecified targets

target

name of the new aggregated target

gather

function used to gather the targets. Should be one of list(...), c(...), rbind(...), or similar.

append

logical. If TRUE, the output will include the original rows in the plan argument. If FALSE, the output will only include the new targets and commands.

Value

A workflow plan data frame that aggregates multiple prespecified targets into one additional target downstream.

See Also

[drake_plan(), map_plan(), reduce_by(), gather_by(), reduce_plan(), evaluate_plan(), expand_plan()

Examples

Run this code
# NOT RUN {
# Workflow plan for datasets:
datasets <- drake_plan(
  small = simulate(5),
  large = simulate(50)
)
# Create a new target that brings the datasets together.
gather_plan(datasets, target = "my_datasets", append = FALSE)
# This time, the new target just appends the rows of 'small' and 'large'
# into a single matrix or data frame.
gathered <- gather_plan(
  datasets,
  target = "aggregated_data",
  gather = "rbind",
  append = FALSE
)
gathered
# For the complete workflow plan, row bind the pieces together.
bind_plans(datasets, gathered)
# Alternatively, you can set `append = TRUE` to incorporate
# the new targets automatically.
gather_plan(
  datasets,
  target = "aggregated_data",
  gather = "rbind",
  append = TRUE
)
# }

Run the code above in your browser using DataCamp Workspace