vis_drake_graph()
.With the returned data frames,
you can plot your own custom visNetwork
graph.
drake_graph_info(config = drake::read_drake_config(), from = NULL,
mode = c("out", "in", "all"), order = NULL, subset = NULL,
build_times = "build", digits = 3, targets_only = FALSE,
split_columns = NULL, font_size = 20, from_scratch = FALSE,
make_imports = TRUE, full_legend = FALSE, group = NULL,
clusters = NULL)
a drake_config()
configuration list.
You can get one as a return value from make()
as well.
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
.
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.
How far to branch out to create
a neighborhood around from
(measured
in the number of nodes). Defaults to
as far as possible.
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.
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.
number of digits for rounding the build times
logical, whether to skip the imports and only include the targets in the workflow plan.
logical, deprecated.
numeric, font size of the node labels in the graph
logical, whether to make the imports first.
Set to FALSE
to increase speed and risk using obsolete information.
logical. If TRUE
, all the node types
are printed in the legend. If FALSE
, only the
node types used are printed in the legend.
optional character scalar, name of the column used to
group nodes into columns. All the columns names of your config$plan
are choices. The other choices (such as "status"
) are column names
in the nodes
. To group nodes into clusters in the graph,
you must also supply the clusters
argument.
optional character vector of values to cluster on.
These values must be elements of the column of the nodes
data frame
that you specify in the group
argument to drake_graph_info()
.
A list of three data frames: one for nodes, one for edges, and one for the legend nodes. The list also contains the default title of the graph.
# NOT RUN {
test_with_dir("Quarantine side effects.", {
load_mtcars_example() # Get the code with drake_example("mtcars").
config <- drake_config(my_plan) # my_plan loaded with load_mtcars_example()
vis_drake_graph(config) # Jump straight to the interactive graph.
# Get a list of data frames representing the nodes, edges,
# and legend nodes of the visNetwork graph from vis_drake_graph().
raw_graph <- drake_graph_info(config = config)
# Choose a subset of the graph.
smaller_raw_graph <- drake_graph_info(
config = config,
from = c("small", "reg2"),
mode = "in"
)
# Inspect the raw graph.
str(raw_graph)
# Use the data frames to plot your own custom visNetwork graph.
# For example, you can omit the legend nodes
# and change the direction of the graph.
library(magrittr)
library(visNetwork)
visNetwork(nodes = raw_graph$nodes, edges = raw_graph$edges) %>%
visHierarchicalLayout(direction = 'UD')
# Optionally visualize clusters.
config$plan$large_data <- grepl("large", config$plan$target)
graph <- drake_graph_info(
config, group = "large_data", clusters = c(TRUE, FALSE))
tail(graph$nodes)
render_drake_graph(graph)
# You can even use clusters given to you for free in the `graph$nodes`
# data frame.
graph <- drake_graph_info(
config, group = "status", clusters = "imported")
tail(graph$nodes)
render_drake_graph(graph)
})
# }
Run the code above in your browser using DataLab