Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tidy_dagitty

Tidy a dagitty object


Description

Tidy a dagitty object

Usage

tidy_dagitty(.dagitty, seed = NULL, layout = "nicely", ...)

Arguments

.dagitty

a dagitty

seed

a numeric seed for reproducible layout generation

layout

a layout available in ggraph. See ggraph::create_layout() for details.

...

optional arguments passed to ggraph::create_layout()

Value

a tidy_dagitty object

Examples

library(dagitty)
library(ggplot2)

dag <- dagitty( "dag {
  Y <- X <- Z1 <- V -> Z2 -> Y
  Z1 <- W1 <-> W2 -> Z2
  X <- W1 -> Y
  X <- W2 -> Y
  X [exposure]
  Y [outcome]
  }")

tidy_dagitty(dag)

tidy_dagitty(dag, layout = "fr") %>%
  ggplot(aes(x = x, y = y, xend = xend, yend = yend)) +
    geom_dag_node() +
    geom_dag_text() +
    geom_dag_edges() +
    theme_dag()

ggdag

Analyze and Create Elegant Directed Acyclic Graphs

v0.2.3
MIT + file LICENSE
Authors
Malcolm Barrett [aut, cre] (<https://orcid.org/0000-0003-0299-5825>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.