drake (version 7.3.0)

r_make: Reproducible R session management for drake functions

Description

drake searches your environment to detect dependencies, so functions like make(), outdated(), etc. are designed to run in fresh clean R sessions. Wrappers r_make(), r_outdated(), etc. run reproducibly even if your current R session is old and stale.

Usage

r_make(source = NULL, r_fn = NULL, r_args = list())

r_drake_build(..., source = NULL, r_fn = NULL, r_args = list())

r_outdated(..., source = NULL, r_fn = NULL, r_args = list())

r_missed(..., source = NULL, r_fn = NULL, r_args = list())

r_drake_graph_info(..., source = NULL, r_fn = NULL, r_args = list())

r_vis_drake_graph(..., source = NULL, r_fn = NULL, r_args = list())

r_sankey_drake_graph(..., source = NULL, r_fn = NULL, r_args = list())

r_drake_ggraph(..., source = NULL, r_fn = NULL, r_args = list())

r_text_drake_graph(..., source = NULL, r_fn = NULL, r_args = list())

r_predict_runtime(..., source = NULL, r_fn = NULL, r_args = list())

r_predict_workers(..., source = NULL, r_fn = NULL, r_args = list())

Arguments

source

Path to an R script file that loads packages, functions, etc. and returns a drake_config() object. There are 3 ways to set this path.

  1. Pass an explicit file path.

  2. Call options(drake_source = "path_to_your_script.R").

  3. Just create a file called "_drake.R" in your working directory and supply nothing to source.

r_fn

A callr function such as callr::r or callr::r_bg. Example: r_make(r_fn = callr::r).

r_args

List of arguments to r_fn, not including func or args. Example: r_make(r_fn = callr::r_bg, r_args = list(stdout = "stdout.log")).

...

Arguments to the inner function. For example, if you want to call r_vis_drake_graph(), the inner function is vis_drake_graph(), and selfcontained is an example argument you could supply to the ellipsis.

Details

r_outdated() runs the four steps below. r_make() etc. are similar.

  1. Launch a new callr::r() session.

  2. In that fresh session, run the R script from the source argument. This script loads packages, functions, global options, etc. and returns a drake_config() object.

  3. In that same session, run outdated() with the config argument from step 2.

  4. Return the result back to master process (e.g. your interactive R session).

See Also

make()

Examples

Run this code
# NOT RUN {
isolate_example("quarantine side effects", {
writeLines(
  c(
    "library(drake)",
    "load_mtcars_example()",
    "drake_config(my_plan)"
  ),
  "_drake.R" # default value of the `source` argument
)
cat(readLines("_drake.R"), sep = "\n")
r_outdated()
r_make()
r_outdated()
})
# }

Run the code above in your browser using DataLab