Learn R Programming

drake (version 5.2.1)

triggers: List the available drake triggers.

Description

Triggers are target-level rules that tell make() how to know if a target is outdated or up to date.

Usage

triggers()

Arguments

Value

A character vector with the names of the available triggers.

Details

By default, make() builds targets that need updating and skips over the ones that are already up to date. In other words, a change in a dependency, workflow plan command, or file, or the lack of the target itself, triggers the build process for the target. You can relax this behavior by choosing a trigger for each target. Set the trigger for each target with a "trigger" column in your workflow plan data frame. The triggers() function lists the available triggers:

  • 'any': Build the target if any of the other triggers activate (default).

  • 'command': Build if the workflow plan command has changed since last time the target was built. Also built if missing is triggered.

  • 'depends': Build if any of the target's dependencies has changed since the last make(). Also build if missing is triggered.

  • 'file': Build if the target is a file and that output file is either missing or corrupted. Also build if missing is triggered.

  • 'missing': Build if the target itself is missing. Always applies.

See Also

drake_plan(), make()

Examples

Run this code
# NOT RUN {
triggers()
# }
# NOT RUN {
test_with_dir("Quarantine side effects.", {
load_mtcars_example() # Load drake's canonical example.
my_plan[["trigger"]] <- "command"
# You can have different triggers for different targets.
my_plan[["trigger"]][1] <- "file"
make(my_plan) # Run the project, build the targets.
# Change an imported dependency function.
reg2 <- function(d) {
  d$x3 <- d$x ^ 3
  lm(y ~ x3, data = d)
}
# Nothing changes! To react to `reg2`, you would need the
# "any" or "depends" trigger.
make(my_plan)
# You can use a global trigger if your workflow plan
# does not have a 'trigger' column.
my_plan[["trigger"]] <- NULL # Would override the global trigger.
make(my_plan, trigger = "missing") # Just build missing targets.
})
# }

Run the code above in your browser using DataLab