Learn R Programming

drake (version 4.2.0)

plot_graph: Function plot_graph

Description

Plot the dependency structure of your workflow. IMPORTANT: you must be in the root directory of your project. To save time for repeated plotting, this function is divided into dataframes_graph() and render_graph().

Usage

plot_graph(plan, targets = drake::possible_targets(plan),
  envir = parent.frame(), verbose = TRUE, cache = NULL, jobs = 1,
  parallelism = drake::default_parallelism(), packages = (.packages()),
  prework = character(0), file = character(0), selfcontained = FALSE,
  build_times = TRUE, digits = 0, targets_only = FALSE,
  split_columns = FALSE, config = NULL, font_size = 20,
  layout = "layout_with_sugiyama",
  main = drake::default_graph_title(parallelism = parallelism, split_columns =
  split_columns), direction = "LR", hover = TRUE,
  navigationButtons = TRUE, ...)

Arguments

plan

workflow plan data frame, same as for function make().

targets

names of targets to bulid, same as for function make().

envir

environment to import from, same as for function make(). config$envir is ignored in favor of envir.

verbose

logical, whether to output messages to the console.

cache

optional drake cache. See codenew_cache(). If The cache argument is ignored if a non-null config argument is supplied.

jobs

The outdated() function is called internally, and it needs to import objects and examine your input files to see what has been updated. This could take some time, and parallel computing may be needed to speed up the process. The jobs argument is number of parallel jobs to use for faster computation.

parallelism

Choice of parallel backend to speed up the computation. Execution order in make() is slightly different when parallelism equals 'Makefile' because in that case, all the imports are imported before any target is built. Thus, the arrangement in the graph is different for Makefile parallelism. See ?parallelism_choices for details.

packages

same as for make().

prework

same as for make().

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

logical, whether to print the build_times() in the graph.

digits

number of digits for rounding the build times

targets_only

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

split_columns

logical, whether to break up the columns of nodes to make the aspect ratio of the rendered graph closer to 1:1. This improves the viewing experience, but the columns no longer strictly represent parallelizable stages of build items. (Although the targets/imports in each column are still conditionally independent, there may be more conditional independence than the graph indicates.)

config

option internal runtime parameter list of make(...), produced with config(). config$envir is ignored. Otherwise, computing this in advance could save time if you plan multiple calls to outdated().

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

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)

...

other arguments passed to visNetwork::visNetwork() to plot the graph.

See Also

build_graph

Examples

Run this code
# NOT RUN {
load_basic_example()
plot_graph(my_plan, width = '100%') # The width is passed to visNetwork
make(my_plan)
plot_graph(my_plan) # The red nodes from before are now green.
# }

Run the code above in your browser using DataLab