{"id":13401154,"url":"https://github.com/r-causal/ggdag","last_synced_at":"2025-06-27T01:02:51.960Z","repository":{"id":29261647,"uuid":"116412625","full_name":"r-causal/ggdag","owner":"r-causal","description":":arrow_lower_left: :arrow_lower_right: An R package for working with causal directed acyclic graphs (DAGs)","archived":false,"fork":false,"pushed_at":"2025-04-15T16:41:38.000Z","size":193858,"stargazers_count":449,"open_issues_count":40,"forks_count":31,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-06-25T19:52:56.899Z","etag":null,"topics":["causal-inference","dag","ggplot-extension","r","rstats"],"latest_commit_sha":null,"homepage":"https://r-causal.github.io/ggdag/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-causal.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"malcolmbarrett","custom":"https://paypal.me/malcobarrett"}},"created_at":"2018-01-05T17:59:46.000Z","updated_at":"2025-06-12T15:28:52.000Z","dependencies_parsed_at":"2024-02-04T20:17:40.839Z","dependency_job_id":"0bf9051a-92f0-48d4-b8b8-92f38d1ccad2","html_url":"https://github.com/r-causal/ggdag","commit_stats":{"total_commits":344,"total_committers":5,"mean_commits":68.8,"dds":"0.046511627906976716","last_synced_commit":"975bafd0d8f44c69ff77610095ecaaaae6057b76"},"previous_names":["malcolmbarrett/ggdag"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/r-causal/ggdag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-causal%2Fggdag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-causal%2Fggdag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-causal%2Fggdag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-causal%2Fggdag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-causal","download_url":"https://codeload.github.com/r-causal/ggdag/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-causal%2Fggdag/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262170228,"owners_count":23269604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["causal-inference","dag","ggplot-extension","r","rstats"],"created_at":"2024-07-30T19:00:59.290Z","updated_at":"2025-06-27T01:02:51.762Z","avatar_url":"https://github.com/r-causal.png","language":"R","funding_links":["https://github.com/sponsors/malcolmbarrett","https://paypal.me/malcobarrett"],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/\",\n  out.width = \"100%\"\n)\nlibrary(ggplot2)\nset.seed(1542)\n```\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/r-causal/ggdag/workflows/R-CMD-check/badge.svg)](https://github.com/r-causal/ggdag/actions)\n[![CRAN status](https://www.r-pkg.org/badges/version/ggdag)](https://cran.r-project.org/package=ggdag)\n[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![Codecov test coverage](https://codecov.io/gh/malcolmbarrett/ggdag/branch/main/graph/badge.svg)](https://app.codecov.io/gh/malcolmbarrett/ggdag?branch=main)\n[![Total CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/ggdag)](https://cran.r-project.org/package=ggdag)\n\u003c!-- badges: end --\u003e\n\n# ggdag: An R Package for visualizing and analyzing causal directed acyclic graphs \u003ca href=\"https://r-causal.github.io/ggdag/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" /\u003e\u003c/a\u003e\n\nTidy, analyze, and plot causal directed acyclic graphs (DAGs). `ggdag` uses the powerful `dagitty` package to create and analyze structural causal models and plot them using `ggplot2` and `ggraph` in a consistent and easy manner. \n\n## Installation\n\nYou can install `ggdag` with:\n\n```{r cran-installation, eval = FALSE}\ninstall.packages(\"ggdag\")\n```\n\nOr you can install the development version from GitHub with:\n\n```{r gh-installation, eval = FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"r-causal/ggdag\")\n```\n\n## Example\n\n`ggdag` makes it easy to use `dagitty` in the context of the tidyverse. You can directly tidy `dagitty` objects or use convenience functions to create DAGs using a more R-like syntax:\n\n```{r tidydag, dpi=300, message=FALSE}\nlibrary(ggdag)\nlibrary(ggplot2)\n\n#  example from the dagitty package\ndag \u003c- dagitty::dagitty(\"dag {\n    y \u003c- x \u003c- z1 \u003c- v -\u003e z2 -\u003e y\n    z1 \u003c- w1 \u003c-\u003e w2 -\u003e z2\n    x \u003c- w1 -\u003e y\n    x \u003c- w2 -\u003e y\n    x [exposure]\n    y [outcome]\n  }\")\n\ntidy_dag \u003c- tidy_dagitty(dag)\n\ntidy_dag\n\n#  using more R-like syntax to create the same DAG\ntidy_ggdag \u003c- dagify(\n  y ~ x + z2 + w2 + w1,\n  x ~ z1 + w1 + w2,\n  z1 ~ w1 + v,\n  z2 ~ w2 + v,\n  w1 ~ ~w2, # bidirected path\n  exposure = \"x\",\n  outcome = \"y\"\n) %\u003e%\n  tidy_dagitty()\n\ntidy_ggdag\n```\n\n`ggdag` also provides functionality for analyzing DAGs and plotting them in `ggplot2`:\n\n```{r ggdag, dpi=300}\nggdag(tidy_ggdag) +\n  theme_dag()\nggdag_adjustment_set(tidy_ggdag, node_size = 14) +\n  theme(legend.position = \"bottom\")\n```\n\nAs well as geoms and other functions for plotting them directly in `ggplot2`:\n\n```{r ggdag_geoms, dpi=300} \ndagify(m ~ x + y) %\u003e%\n  tidy_dagitty() %\u003e%\n  node_dconnected(\"x\", \"y\", controlling_for = \"m\") %\u003e%\n  ggplot(aes(\n    x = x,\n    y = y,\n    xend = xend,\n    yend = yend,\n    shape = adjusted,\n    col = d_relationship\n  )) +\n  geom_dag_edges(end_cap = ggraph::circle(10, \"mm\")) +\n  geom_dag_collider_edges() +\n  geom_dag_point() +\n  geom_dag_text(col = \"white\") +\n  theme_dag() +\n  scale_adjusted() +\n  expand_plot(expand_y = expansion(c(0.2, 0.2))) +\n  scale_color_viridis_d(\n    name = \"d-relationship\",\n    na.value = \"grey85\",\n    begin = .35\n  )\n```\n\nAnd common structures of bias:\n```{r ggdag_common, dpi=300}\nggdag_equivalent_dags(confounder_triangle())\n\nggdag_butterfly_bias(edge_type = \"diagonal\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-causal%2Fggdag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-causal%2Fggdag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-causal%2Fggdag/lists"}