Learn R Programming

drake (version 5.2.1)

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

Description

Creates a new workflow plan data frame with a single new target. This new target is a list, vector, or other aggregate of a collection of existing targets in another workflow plan data frame.

Usage

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

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.

Value

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

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")
# 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"
)
gathered
# For the complete workflow plan, row bind the pieces together.
my_plan <- rbind(datasets, gathered)
my_plan
# }

Run the code above in your browser using DataLab