drake (version 7.3.0)

reduce_plan: Deprecated: write commands to reduce several targets down to one.

Description

Deprecated on 2019-05-16. Use drake_plan() transformations instead. See https://ropenscilabs.github.io/drake-manual/plans.html#large-plans for the details.

Usage

reduce_plan(plan = NULL, target = "target", begin = "", op = " + ",
  end = "", pairwise = TRUE, append = FALSE, sep = "_")

Arguments

plan

Workflow plan data frame of prespecified targets.

target

Name of the new reduced target.

begin

Character, code to place at the beginning of each step in the reduction.

op

Binary operator to apply in the reduction

end

Character, code to place at the end of each step in the reduction.

pairwise

Logical, whether to create multiple new targets, one for each pair/step in the reduction (TRUE), or to do the reduction all in one command.

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.

sep

Character scalar, delimiter for creating new target names.

Value

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

Details

Creates a new workflow plan data frame with the commands to do a reduction (i.e. to repeatedly apply a binary operator to pairs of targets to produce one target).

See Also

drake_plan()

Examples

Run this code
# NOT RUN {
suppressWarnings({
# Workflow plan for datasets:
x_plan <- evaluate_plan(
  drake_plan(x = VALUE),
  wildcard = "VALUE",
  values = 1:8
)
x_plan
# Create a new target from the sum of the others.
reduce_plan(x_plan, target = "x_sum", pairwise = FALSE, append = FALSE)
# Optionally include the original rows with `append = TRUE`.
reduce_plan(x_plan, target = "x_sum", pairwise = FALSE, append = TRUE)
# For memory efficiency and parallel computing,
# reduce pairwise:
reduce_plan(x_plan, target = "x_sum", pairwise = TRUE, append = FALSE)
# Optionally define your own function and use it as the
# binary operator in the reduction.
x_plan <- evaluate_plan(
  drake_plan(x = VALUE),
  wildcard = "VALUE",
  values = 1:9
)
x_plan
reduce_plan(
  x_plan, target = "x_sum", pairwise = TRUE,
  begin = "fun(", op = ", ", end = ")"
)
})
# }

Run the code above in your browser using DataLab