qd_dag | R Documentation |
Provide simple syntax specifying paths between nodes to generate a graph object.
qd_dag( edgelist, node.labs = NULL, node.aes.opts = list(), edge.aes.opts = list(), verbose = TRUE, check.dag = TRUE, theme = "base", ... )
edgelist |
A vector of edge relationships. Must be strictly organized (see example for format). |
node.labs |
A named character vector containing label names. Defaults to |
node.aes.opts |
A list feeding aesthetic options for nodes to |
edge.aes.opts |
A list feeding aesthetic options for edges to |
verbose |
Indicate whether to print node and edge dataframes to the console. See NOTE below. Defaults to |
check.dag |
Logical. Check whether the graph conforms to the rules of DAGs. Defaults to |
theme |
Choose theme for plot output. Defaults to "base". Setting theme to NULL will use DiagrammeR's NULL attribute theme. |
... |
Pass optional |
Suggestions and bug reports welcome at https://github.com/jrgant/quickDAG/issues.
Packages used: DiagrammeR, stringr, purrr
Leaving the checks
option selected may be advisable to ensure labels and IDs have not been mismatched. By default, qd_dag()
alphabetizes nodes included in edgelist
and does the same for node.labs
under a first assumption that labels will begin with the same letter as their corresponding alpha.id
, which may not always be the case.
# Provide a list of edges, with nodes specified as letters. # Do not list a node as a parent more than once. # Each line should contain a single edge character '->'. edges <- c("A -> { B C }", "B -> C") # make a DAG object and render the graph using the default theme g.obj <- qd_dag(edges) render_graph(g.obj) # Pass labels and aesthetic options for nodes or edges g.obj2 <- qd_dag(edges, node.labs = c("A" = "Alcohol", "B" = "BP", "C" = "CVD"), node.aes.opts = list(shape = "plaintext", fillcolor = "none", color = "black"), edge.aes.opts = list(arrowsize = 0.5, color = "gray"), theme = NULL) render_graph(g.obj2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.