Render a Sankey diagram from drake_graph_info(). ![[Stable]](figures/lifecycle-stable.svg)
Source: R/sankey_drake_graph.R
render_sankey_drake_graph.RdThis function is called inside
sankey_drake_graph(), which typical users
call more often. A legend is unfortunately unavailable
for the graph itself, but you can see what all the colors mean with
visNetwork::visNetwork(drake::legend_nodes()).
Usage
render_sankey_drake_graph(
graph_info,
file = character(0),
selfcontained = FALSE,
...
)Arguments
- graph_info
List of data frames generated by
drake_graph_info(). There should be 3 data frames:nodes,edges, andlegend_nodes.- file
Name of a file to save the graph. If
NULLorcharacter(0), no file is saved and the graph is rendered and displayed within R. If the file ends in a.png,.jpg,.jpeg, or.pdfextension, 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.pdfextension, an HTML file will be saved, and you can open the interactive graph using a web browser.- selfcontained
Logical, whether to save the
fileas a self-contained HTML file (with external resources base64 encoded) or a file with external resources placed in an adjacent directory. IfTRUE, pandoc is required.- ...
Arguments passed to
networkD3::sankeyNetwork().
Examples
if (FALSE) { # \dontrun{
isolate_example("Quarantine side effects.", {
load_mtcars_example() # Get the code with drake_example("mtcars").
if (suppressWarnings(require("knitr"))) {
if (requireNamespace("networkD3", quietly = TRUE)) {
if (requireNamespace("visNetwork", quietly = TRUE)) {
# Instead of jumpting right to sankey_drake_graph(), get the data frames
# of nodes, edges, and legend nodes.
sankey_drake_graph(my_plan) # Jump straight to the interactive graph.
# Show the legend separately.
visNetwork::visNetwork(nodes = drake::legend_nodes())
# Get the node and edge info that sankey_drake_graph() just plotted:
graph <- drake_graph_info(my_plan)
# You can pass the data frames right to render_sankey_drake_graph()
# (as in sankey_drake_graph()) or you can create
# your own custom visNewtork graph.
render_sankey_drake_graph(graph)
}
}
}
})
} # }