Learn R Programming

drake (version 5.2.1)

loadd: Load one or more targets or imports from the drake cache.

Description

Loads the object(s) into the current workspace (or environment envir if given). Defaults to loading the entire cache if you do not supply anything to arguments ... or list.

Usage

loadd(..., list = character(0), imported_only = FALSE, path = getwd(),
  search = TRUE, cache = drake::get_cache(path = path, search = search,
  verbose = verbose), namespace = NULL, envir = parent.frame(), jobs = 1,
  verbose = drake::default_verbose(), deps = FALSE, lazy = "eager",
  graph = NULL, replace = TRUE, show_source = FALSE)

Arguments

...

targets to load from the cache: as names (symbols), character strings, or dplyr-style tidyselect commands such as starts_with().

list

character vector naming targets to be loaded from the cache. Similar to the list argument of remove().

imported_only

logical, whether only imported objects should be loaded.

path

Root directory of the drake project, or if search is TRUE, either the project root or a subdirectory of the project. Ignored if a cache is supplied.

search

logical. If TRUE, search parent directories to find the nearest drake cache. Otherwise, look in the current working directory only. Ignored if a cache is supplied.

cache

drake cache. See new_cache(). If supplied, path and search are ignored.

namespace

character scalar, name of an optional storr namespace to load from.

envir

environment to load objects into. Defaults to the calling environment (current workspace).

jobs

number of parallel jobs for loading objects. On non-Windows systems, the loading process for multiple objects can be lightly parallelized via parallel::mclapply(). just set jobs to be an integer greater than 1. On Windows, jobs is automatically demoted to 1.

verbose

logical or numeric, control printing to the console. Use pkgconfig to set the default value of verbose for your R session: for example, pkgconfig::set_config("drake::verbose" = 2).

0 or FALSE:

print nothing.

1 or TRUE:

print only targets to build.

2:

in addition, print checks and cache info.

3:

in addition, print any potentially missing items.

4:

in addition, print imports. Full verbosity.

deps

logical, whether to load any cached dependencies of the targets instead of the targets themselves. This is useful if you know your target failed and you want to debug the command in an interactive session with the dependencies in your workspace. One caveat: to find the dependencies, loadd() uses information that was stored in a drake_config() list and cached during the last make(). That means you need to have already called make() if you set deps to TRUE.

lazy

either a string or a logical. Choices:

  • "eager": no lazy loading. The target is loaded right away with assign().

  • "promise": lazy loading with delayedAssign()

  • "bind": lazy loading with active bindings: bindr::populate_env().

  • TRUE: same as "promise".

  • FALSE: same as "eager".

graph

optional igraph object, representation of the workflow network for getting dependencies if deps is TRUE. If none is supplied, it will be read from the cache.

replace

logical. If FALSE, items already in your environment will not be replaced.

show_source

logical, option to show the command that produced the target or indicate that the object was imported (using show_source()).

Value

NULL

Details

loadd() excludes foreign imports: R objects not originally defined in envir when make() last imported them. To get these objects, use readd().

See Also

readd(), cached(), built(), imported(), drake_plan(), make(),

Examples

Run this code
# NOT RUN {
test_with_dir("Quarantine side effects.", {
load_mtcars_example() # Get the code with drake_example("mtcars").
make(my_plan) # Run the projects, build the targets.
loadd(small) # Load target 'small' into your workspace.
small
# For many targets, you can parallelize loadd()
# using the 'jobs' argument.
loadd(list = c("small", "large"), jobs = 2)
ls()
# How about tidyselect?
loadd(starts_with("summ"))
ls()
# Load the dependencies of the target, coef_regression2_small
loadd(coef_regression2_small, deps = TRUE)
ls()
# Load all the imported objects/functions.
# Note: loadd() excludes foreign imports
# (R objects not originally defined in `envir`
# when `make()` last imported them).
loadd(imported_only = TRUE)
ls()
# Load all the targets listed in the workflow plan
# of the previous `make()`.
# Be sure your computer has enough memory.
loadd()
ls()
# With files, you just get the fingerprint.
loadd(list = file_store("report.md"))
ls() # Should include "\"report.md\"".
get(file_store("report.md"))
})
# }

Run the code above in your browser using DataLab