drake_graph_info()
.This function is called inside
vis_drake_graph()
, which typical users
call more often.
render_drake_graph(graph_info, file = character(0),
layout = "layout_with_sugiyama", direction = "LR", hover = TRUE,
main = graph_info$default_title, selfcontained = FALSE,
navigationButtons = TRUE, ncol_legend = 1, collapse = TRUE, ...)
list of data frames generated by
drake_graph_info()
.
There should be 3 data frames: nodes
, edges
,
and legend_nodes
.
Name of a file to save the graph.
If NULL
or character(0)
, no file is saved and
the graph is rendered and displayed within R.
If the file ends in a .png
, .jpg
, .jpeg
, or .pdf
extension,
then a static image will be saved. In this case,
the webshot package and PhantomJS are required:
install.packages("webshot"); webshot::install_phantomjs()
.
If the file does not end in a .png
, .jpg
, .jpeg
, or .pdf
extension, an HTML file will be saved, and you can open the
interactive graph using a web browser.
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.
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.
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.
character string, title of the graph
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. The selfcontained
argument only applies
to HTML files. In other words, if file
is a
PNG, PDF, or JPEG file, for instance,
the point is moot.
logical, whether to add navigation buttons with
visNetwork::visInteraction(navigationButtons = TRUE)
number of columns in the legend nodes.
To remove the legend entirely, set ncol_legend
to NULL
or 0
.
logical, whether to allow nodes to collapse
if you double click on them.
Analogous to visNetwork::visOptions(collapse = TRUE)
or
visNetwork::visOptions(collapse = TRUE)
.
arguments passed to visNetwork()
.
A visNetwork
graph.
# NOT RUN {
test_with_dir("Quarantine side effects.", {
load_mtcars_example() # Get the code with drake_example("mtcars").
# Instead of jumpting right to vis_drake_graph(), get the data frames
# of nodes, edges, and legend nodes.
config <- drake_config(my_plan) # Internal configuration list
vis_drake_graph(config) # Jump straight to the interactive graph.
# Get the node and edge info that vis_drake_graph() just plotted:
graph <- drake_graph_info(config)
# You can pass the data frames right to render_drake_graph()
# (as in vis_drake_graph()) or you can create
# your own custom visNewtork graph.
render_drake_graph(graph, width = '100%') # Width is passed to visNetwork.
# Optionally visualize clusters.
config$plan$large_data <- grepl("large", config$plan$target)
graph <- drake_graph_info(
config, group = "large_data", clusters = c(TRUE, FALSE))
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")
render_drake_graph(graph)
})
# }
Run the code above in your browser using DataLab