Learn R Programming

drake (version 7.5.2)

drake_envir: Get the environment where drake builds targets

Description

Call this function inside the commands in your plan to get the environment where drake builds targets. That way, you can strategically remove targets from memory while make() is running. That way, you can limit the amount of computer memory you use.

Usage

drake_envir()

Arguments

Value

The environment where drake builds targets.

Keywords

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.

  • target(): declare more than just the command, e.g. assign a trigger or transform. Examples: https://ropenscilabs.github.io/drake-manual/plans.html#large-plans. # nolint

  • file_in(): declare an input file dependency.

  • file_out(): declare an output file to be produced when the target is built.

  • knitr_in(): declare a knitr file dependency such as an R Markdown (*.Rmd) or R LaTeX (*.Rnw) file.

  • ignore(): force drake to entirely ignore a piece of code: do not track it for changes and do not analyze it for dependencies.

  • no_deps(): tell drake to not track the dependencies of a piece of code. drake still tracks the code itself for changes.

  • drake_envir(): get the environment where drake builds targets. Intended for advanced custom memory management.

See Also

from_plan()

Examples

Run this code
# NOT RUN {
isolate_example("contain side effects", {
plan <- drake_plan(
  large_data_1 = sample.int(1e4),
  large_data_2 = sample.int(1e4),
  subset = c(large_data_1[seq_len(10)], large_data_2[seq_len(10)]),
  summary = {
    print(ls(envir = drake_envir()))
    # We don't need the large_data_* targets in memory anymore.
    rm(large_data_1, large_data_2, envir = drake_envir())
    print(ls(envir = drake_envir()))
    mean(subset)
  }
)
make(plan, cache = storr::storr_environment(), session_info = FALSE)
})
# }

Run the code above in your browser using DataLab