library(tidyverse)
library(ggdag)
library(ggraph)
theory_dag <- dagify(AE ~ PF,
PF ~ IC + RC,
FIC ~ AE,
labels = c("AE" = "Advocacy\neffects",
"PF" = "Programmatic\nflexibility",
"IC" = "Institutional\nconstraints",
"RC" = "Resource\nconfiguration",
"FIC" = "Future\ninstitutional\nconstraints"),
exposure = "PF",
outcome = "AE") %>%
tidy_dagitty(layout = "sugiyama")
theory_dag$data <- theory_dag$data %>%
mutate(linetype = ifelse(name == "AE", "dotted", "solid"))
plot_dag <- ggplot(theory_dag, aes(x = x, y = y, xend = xend, yend = yend)) +
geom_dag_point(size = 8) +
geom_dag_edges(start_cap = circle(4, "mm"),
end_cap = circle(4, "mm"),
aes(edge_linetype = linetype)) +
geom_dag_label_repel(aes(label = label), direction = "x", seed = 12345, size = 3) +
scale_dag() +
scale_edge_linetype_manual(values = c("dotted", "solid"), guide = FALSE) +
theme_void()
plot_dag
Created on 2019-05-20 by the reprex package (v0.2.1)