ggplot2/ggraph visualization from
drake_graph_info() output.This function requires packages ggplot2 and ggraph.
Install them with install.packages(c("ggplot2", "ggraph")).
render_drake_ggraph(graph_info, main = graph_info$default_title,
label_nodes = FALSE)List of data frames generated by
drake_graph_info().
There should be 3 data frames: nodes, edges,
and legend_nodes.
Character string, title of the graph.
Logical, whether to label the nodes.
If FALSE, the graph will not have any text next to the nodes,
which is recommended for large graphs with lots of targets.
A ggplot2 object, which you can modify with more layers,
show with plot(), or save as a file with ggsave().
# NOT RUN {
test_with_dir("Quarantine side effects.", {
load_mtcars_example() # Get the code with drake_example("mtcars").
if (requireNamespace("ggraph", quietly = TRUE)) {
# 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
drake_ggraph(config) # Jump straight to the static graph.
# Get the node and edge info that vis_drake_graph() just plotted:
graph <- drake_graph_info(config)
render_drake_ggraph(graph)
}
})
# }
Run the code above in your browser using DataLab