Find descendant nodes for specified variables in a DAG.
Value
A tibble with columns:
node
: The nodedescendant_set
: String representation of descendant nodesdescendants
: List column containing descendant nodesn_descendants
: Number of descendants
Examples
library(ggdag)
dag <- dagify(
y ~ x + z,
x ~ w
)
query_descendants(dag)
#> # A tibble: 4 × 4
#> node descendant_set descendants n_descendants
#> <chr> <chr> <list> <int>
#> 1 w {x, y} <chr [2]> 2
#> 2 x {y} <chr [1]> 1
#> 3 y NA <chr [1]> 0
#> 4 z {y} <chr [1]> 1
query_descendants(dag, .var = "w")
#> # A tibble: 1 × 4
#> node descendant_set descendants n_descendants
#> <chr> <chr> <list> <int>
#> 1 w {x, y} <chr [2]> 2