Takes an input graph with bidirected edges and replaces every bidirected edge
x <-> y with a substructure x <- L -> y, where L is a latent variable. See
dagitty::canonicalize()
for details. Undirected edges
are not currently supported in ggdag
.
Usage
node_canonical(.dag, ...)
ggdag_canonical(
.tdy_dag,
...,
edge_type = "link_arc",
node_size = 16,
text_size = 3.88,
label_size = text_size,
text_col = "white",
label_col = text_col,
use_edges = TRUE,
use_nodes = TRUE,
use_stylized = FALSE,
use_text = TRUE,
use_labels = NULL,
label = NULL,
text = NULL,
node = deprecated(),
stylized = deprecated()
)
Arguments
- .dag, .tdy_dag
input graph, an object of class
tidy_dagitty
ordagitty
- ...
additional arguments passed to
tidy_dagitty()
- edge_type
The type of edge, one of "link_arc", "link", "arc", "diagonal".
- node_size
The size of the nodes.
- text_size
The size of the text.
- label_size
The size of the labels.
- text_col
The color of the text.
- label_col
The color of the labels.
- use_edges
A logical value. Include a
geom_dag_edges*()
function? IfTRUE
, which is determined byedge_type
.- use_nodes
A logical value. Include
geom_dag_point()
?- use_stylized
A logical value. Include
geom_dag_node()
?- use_text
A logical value. Include
geom_dag_text()
?- use_labels
A logical value. Include
geom_dag_label_repel()
?- label
The bare name of a column to use for
geom_dag_label_repel()
. Ifuse_labels = TRUE
, the default is to uselabel
.- text
The bare name of a column to use for
geom_dag_text()
. Ifuse_text = TRUE
, the default is to usename
.- node
Deprecated.
- stylized
Deprecated.
Examples
dag <- dagify(y ~ x + z, x ~ ~z)
ggdag(dag)
node_canonical(dag)
#> # A DAG with 4 nodes and 4 edges
#> #
#> # Latent Variable: L1
#> #
#> # A tibble: 5 × 8
#> name x y direction to xend yend circular
#> <chr> <dbl> <dbl> <fct> <chr> <dbl> <dbl> <lgl>
#> 1 L1 -0.338 -1.11 -> x 0.462 -0.295 FALSE
#> 2 L1 -0.338 -1.11 -> z -1.17 -0.326 FALSE
#> 3 x 0.462 -0.295 -> y -0.369 0.492 FALSE
#> 4 y -0.369 0.492 NA NA NA NA FALSE
#> 5 z -1.17 -0.326 -> y -0.369 0.492 FALSE
ggdag_canonical(dag)