r-causal/ggdag

:arrow_lower_left: :arrow_lower_right: An R package for working with causal directed acyclic graphs (DAGs)

What it solves

It provides a way to tidy, analyze, and visualize causal directed acyclic graphs (DAGs) within the R ecosystem, specifically making the dagitty package compatible with the tidyverse and ggplot2 workflows.

How it works

The package leverages dagitty to create and analyze structural causal models. It allows users to define DAGs using either a specialized syntax or a more R-like formula syntax via dagify(). It then converts these DAGs into "tidy" data frames that can be plotted using ggplot2 and ggraph through a set of dedicated geoms and helper functions.

Who it’s for

Researchers and data scientists using R who need to map out causal relationships and identify adjustment sets for causal inference.

Highlights

  • Uses dagitty for the underlying causal analysis.
  • Integrates with ggplot2 for flexible, high-quality visualization.
  • Supports the creation of DAGs via a tidy-style formula syntax.
  • Includes built-in functions for visualizing common bias structures like butterfly bias and confounder triangles.

Related

  • Project
  • Project
  • Project
  • Project
  • Project