target {drake}R Documentation

Customize a target in drake_plan(). [Stable]


The target() function is a way to configure individual targets in a drake plan. Its most common use is to invoke static branching and dynamic branching, and it can also set the values of custom columns such as format, elapsed, retries, and max_expand. Details are at ⁠⁠. Note: drake_plan(my_target = my_command()) is equivalent to ⁠drake_plan(my_target = target(my_command())⁠.


target(command = NULL, transform = NULL, dynamic = NULL, ...)



The command to build the target.


A call to map(), split(), cross(), or combine() to apply a static transformation. Details: ⁠⁠


A call to map(), cross(), or group() to apply a dynamic transformation. Details: ⁠⁠


Optional columns of the plan for a given target. See the Columns section of this help file for a selection of special columns that drake understands.


target() must be called inside drake_plan(). It is invalid otherwise.


A one-row workflow plan data frame with the named arguments as columns.


drake_plan() creates a special data frame. At minimum, that data frame must have columns target and command with the target names and the R code chunks to build them, respectively.

You can add custom columns yourself, either with target() (e.g. drake_plan(y = target(f(x), transform = map(c(1, 2)), format = "fst"))) or by appending columns post-hoc (e.g. plan$col <- vals).

Some of these custom columns are special. They are optional, but drake looks for them at various points in the workflow.


drake_plan() understands special keyword functions for your commands. With the exception of target(), each one is a proper function with its own help file.


Specialized target formats increase efficiency and flexibility. Some allow you to save specialized objects like keras models, while others increase the speed while conserving storage and memory. You can declare target-specific formats in the plan (e.g. drake_plan(x = target(big_data_frame, format = "fst"))) or supply a global default format for all targets in make(). Either way, most formats have specialized installation requirements (e.g. R packages) that are not installed with drake by default. You will need to install them separately yourself. Available formats:

See Also

drake_plan(), make()


# Use target() to create your own custom columns in a drake plan.
# See ?triggers for more on triggers.
  website_data = target(
    trigger = "always",
    custom_column = 5
  analysis = analyze(website_data)
models <- c("glm", "hierarchical")
plan <- drake_plan(
  data = target(
    transform = map(x = c("simulated", "survey"))
  analysis = target(
    analyze_data(data, model),
    transform = cross(data, model = !!models, .id = c(x, model))
  summary = target(
    transform = map(analysis, .id = c(x, model))
  results = target(
    transform = combine(summary, .by = data)
if (requireNamespace("styler", quietly = TRUE)) {

[Package drake version 7.13.9 Index]