Learn R Programming

drake (version 4.2.0)

evaluate: Function evaluate

Description

The commands in workflow plan data frames can have wildcard symbols that can stand for datasets, parameters, function arguments, etc. These wildcards can be evaluated over a set of possible values using evaluate.

Usage

evaluate(plan, rules = NULL, wildcard = NULL, values = NULL,
  expand = TRUE)

Arguments

plan

workflow plan data frame, similar to one produced by link{plan}

rules

Named list with wildcards as names and vectors of replacements as values. This is a way to evaluate multiple wildcards at once. When not NULL, rules overrules wildcard and values if not NULL.

wildcard

character scalar denoting a wildcard placeholder

values

vector of values to replace the wildcard in the drake instructions. Will be treated as a character vector. Must be the same length as plan$command if expand is TRUE.

expand

If TRUE, create a new rows in the workflow plan data frame if multiple values are assigned to a single wildcard. If FALSE, each occurence of the wildcard is replaced with the next entry in the values vector, and the values are recycled.

Value

a workflow plan data frame with the wildcards evaluated

Details

Specify a single wildcard with the wildcard and values arguments. In each command, the text in wildcard will be replaced by each value in values in turn. Specify multiple wildcards with the rules argument, which overrules wildcard and values if not NULL. Here, rules should be a list with wildcards as names and vectors of possible values as list elements.

Examples

Run this code
# NOT RUN {
datasets <- plan(
  small = simulate(5),
  large = simulate(50))
methods <- plan(
  regression1 = reg1(..dataset..),
  regression2 = reg2(..dataset..))
evaluate(methods, wildcard = "..dataset..",
  values = datasets$target)
evaluate(methods, wildcard = "..dataset..",
  values = datasets$target, expand = FALSE)
x = plan(draws = rnorm(mean = Mean, sd = Sd))
evaluate(x, rules = list(Mean = 1:3, Sd = c(1, 10)))
# }

Run the code above in your browser using DataLab