Learn R Programming

drake (version 5.2.1)

vis_drake_graph: Show an interactive visual network representation of your drake project.

Description

To save time for repeated plotting, this function is divided into dataframes_graph() and render_drake_graph().

Usage

vis_drake_graph(config = drake::read_drake_config(), file = character(0),
  selfcontained = FALSE, build_times = "build", digits = 3,
  targets_only = FALSE, split_columns = NULL, font_size = 20,
  layout = "layout_with_sugiyama", main = NULL, direction = "LR",
  hover = TRUE, navigationButtons = TRUE, from = NULL, mode = c("out",
  "in", "all"), order = NULL, subset = NULL, ncol_legend = 1,
  full_legend = TRUE, make_imports = TRUE, from_scratch = FALSE, ...)

Arguments

config

a drake_config() configuration list. You can get one as a return value from make() as well.

file

Name of HTML file to save the graph. If NULL or character(0), no file is saved and the graph is rendered and displayed within R.

selfcontained

logical, whether to save the file as a self-contained HTML file (with external resources base64 encoded) or a file with external resources placed in an adjacent directory. If TRUE, pandoc is required.

build_times

character string or logical. If character, the choices are 1. "build": runtime of the command plus the time it take to store the target or import. 2. "command": just the runtime of the command. 3. "none": no build times. If logical, build_times selects whether to show the times from `build_times(..., type = "build")`` or use no build times at all. See build_times() for details.

digits

number of digits for rounding the build times

targets_only

logical, whether to skip the imports and only include the targets in the workflow plan.

split_columns

logical, deprecated.

font_size

numeric, font size of the node labels in the graph

layout

name of an igraph layout to use, such as 'layout_with_sugiyama' or 'layout_as_tree'. Be careful with 'layout_as_tree': the graph is a directed acyclic graph, but not necessarily a tree.

main

character string, title of the graph

direction

an argument to visNetwork::visHierarchicalLayout() indicating the direction of the graph. Options include 'LR', 'RL', 'DU', and 'UD'. At the time of writing this, the letters must be capitalized, but this may not always be the case ;) in the future.

hover

logical, whether to show the command that generated the target when you hover over a node with the mouse. For imports, the label does not change with hovering.

navigationButtons

logical, whether to add navigation buttons with visNetwork::visInteraction(navigationButtons = TRUE)

from

Optional collection of target/import names. If from is nonempty, the graph will restrict itself to a neighborhood of from. Control the neighborhood with mode and order.

mode

Which direction to branch out in the graph to create a neighborhood around from. Use "in" to go upstream, "out" to go downstream, and "all" to go both ways and disregard edge direction altogether.

order

How far to branch out to create a neighborhood around from (measured in the number of nodes). Defaults to as far as possible.

subset

Optional character vector of of target/import names. Subset of nodes to display in the graph. Applied after from, mode, and order. Be advised: edges are only kept for adjacent nodes in subset. If you do not select all the intermediate nodes, edges will drop from the graph.

ncol_legend

number of columns in the legend nodes. To remove the legend entirely, set ncol_legend to NULL or 0.

full_legend

logical. If TRUE, all the node types are printed in the legend. If FALSE, only the node types used are printed in the legend.

make_imports

logical, whether to make the imports first. Set to FALSE to increase speed and risk using obsolete information.

from_scratch

logical, whether to assume all the targets will be made from scratch on the next make(). Makes all targets outdated, but keeps information about build progress in previous make()s.

...

arguments passed to visNetwork().

Value

A visNetwork graph.

See Also

build_drake_graph()

Examples

Run this code
# NOT RUN {
test_with_dir("Quarantine side effects.", {
config <- load_mtcars_example() # Get the code with drake_example("mtcars").
# Plot the network graph representation of the workflow.
vis_drake_graph(config, width = '100%') # The width is passed to visNetwork
config <- make(my_plan) # Run the project, build the targets.
vis_drake_graph(config) # The red nodes from before are now green.
# Plot a subgraph of the workflow.
vis_drake_graph(
  config,
  from = c("small", "reg2"),
  to = "summ_regression2_small"
)
})
# }

Run the code above in your browser using DataLab