Builds a causal network plot
make_causal_plot.RdTakes node and edges dfs, along with arguments to specify attributes
(particularly color), and how to return the output. Internally, this finds
the network relevant to a given set of nodes (by default all of them), using
find_related_nodes, attributes according to the attribute arguments using
causal_colors_general and node_plot_atts and then uses DiagrammeR to
make the plot.
Usage
make_causal_plot(
nodes,
edges,
focalnodes = unique(nodes$Name),
drop_unused_nodes = TRUE,
edge_pal = list(fromtype = "nationalparkcolors::GeneralGrant"),
edge_colorgroups = NULL,
edge_colorset = "fromtype",
edge_pal_direction = rep(1, length(edge_pal)),
node_pal = list(fromtype = "nationalparkcolors::GeneralGrant"),
node_colorgroups = NULL,
node_colorset = "NodeType",
node_pal_direction = rep(1, length(node_pal)),
setLimits = NULL,
wrap_names = TRUE,
render = TRUE,
returnnetwork = TRUE,
save = FALSE,
savedir,
savename = NULL
)Arguments
- nodes
a tibble or dataframe defining nodes
- edges
a tibble or dataframe defining all edge relationships
- focalnodes
a character vector of nodes to use to find the related network (default is all values in the
Namecolumn of thenodesdf). Usesfind_related_nodesto build a network with these nodes along with all their upstream and downstream nodes.- drop_unused_nodes
logical, default
TRUE, drops nodes with no connections.FALSEcould be useful to keep unconnected nodes if we want to see if there are any that are not causally related to the others.- edge_pal
a named list of color palettes or color values for the edges. Currently only supports paletteer palettes, vectors of colors, or single colors. See
causal_colors_general- edge_colorgroups
NULL (the default) or a column name (character) specifying a grouping column for different color palettes for the edges. See
causal_colors_general- edge_colorset
a column name (character) giving the column to define edge color. See
causal_colors_general- edge_pal_direction
either 1 (default) or -1 (reversed) direction of the palettes
- node_pal
a named list of color palettes or color values for the nodes. Currently only supports paletteer palettes, vectors of colors, or single colors. See
causal_colors_general- node_colorgroups
NULL (the default) or a column name (character) specifying a grouping column for different color palettes for the nodes. See
causal_colors_general- node_colorset
a column name (character) giving the column to define node color. See
causal_colors_general- node_pal_direction
either 1 (default) or -1 (reversed) direction of the palettes
- setLimits
NULL (default) or length-2 numeric vector to force limits of the color scale.
- wrap_names
logical, default
TRUE, should long node names be wrapped to multiple lines- render
logical, default
TRUE, should the network be rendered to the graphics device?- returnnetwork
logical, default
TRUE, should the graph object produced byDiagrammeRbe returned?- save
logical, default
FALSE, should the graph be saved as a .png and .pdf- savedir
path to directory for saving outputs. Only needed if
save = TRUE- savename
character, filename for the output plots. .pdf and .png are automatically appended.