The r_*()
functions, such as r_make()
,
enhance reproducibility by launching a drake
function in
a separate R process.
Usage
r_make(source = NULL, r_fn = NULL, r_args = list())
r_drake_build(
target,
character_only = FALSE,
...,
source = NULL,
r_fn = NULL,
r_args = list()
)
r_outdated(..., source = NULL, r_fn = NULL, r_args = list())
r_recoverable(..., source = NULL, r_fn = NULL, r_args = list())
r_missed(..., source = NULL, r_fn = NULL, r_args = list())
r_deps_target(
target,
character_only = FALSE,
...,
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.Pass an explicit file path.
Call
options(drake_source = "path_to_your_script.R")
.Just create a file called "_drake.R" in your working directory and supply nothing to
source
.
- r_fn
A
callr
function such ascallr::r
orcallr::r_bg
. Example:r_make(r_fn = callr::r)
.- r_args
List of arguments to
r_fn
, not includingfunc
orargs
. Example:r_make(r_fn = callr::r_bg, r_args = list(stdout = "stdout.log"))
.- target
Name of the target.
- character_only
Logical, whether
name
should be treated as a character or a symbol (just likecharacter.only
inlibrary()
).- ...
Arguments to the inner function. For example, if you want to call
r_vis_drake_graph()
, the inner function isvis_drake_graph()
, andselfcontained
is an example argument you could supply to the ellipsis.
Details
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.
r_outdated()
runs the four steps below.
r_make()
etc. are similar.
Launch a new
callr::r()
session.In that fresh session, run the R script from the
source
argument. This script loads packages, functions, global options, etc. and callsdrake_config()
at the very end.drake_config()
is the preprocessing step ofmake()
, and it accepts all the same arguments asmake()
(e.g.plan
andtargets
).In that same session, run
outdated()
with theconfig
argument from step 2.Return the result back to main process (e.g. your interactive R session).
Recovery
make(recover = TRUE, recoverable = TRUE)
powers automated data recovery.
The default of recover
is FALSE
because
targets recovered from the distant past may have been generated
with earlier versions of R and earlier package environments
that no longer exist.
How it works: if recover
is TRUE
,
drake
tries to salvage old target values from the cache
instead of running commands from the plan.
A target is recoverable if
There is an old value somewhere in the cache that shares the command, dependencies, etc. of the target about to be built.
The old value was generated with
make(recoverable = TRUE)
.
If both conditions are met, drake
will
Assign the most recently-generated admissible data to the target, and
skip the target's command.
Examples
if (FALSE) { # \dontrun{
isolate_example("quarantine side effects", {
if (requireNamespace("knitr", quietly = TRUE)) {
writeLines(
c(
"library(drake)",
"load_mtcars_example()",
"drake_config(my_plan, targets = c(\"small\", \"large\"))"
),
"_drake.R" # default value of the `source` argument
)
cat(readLines("_drake.R"), sep = "\n")
r_outdated()
r_make()
r_outdated()
}
})
} # }