Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Aug 3, 2024
1 parent 5b8a7c8 commit d770222
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/check_dag.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ print.check_dag <- function(x, ...) {
#' @export
plot.check_dag <- function(x, ...) {
insight::check_if_installed(c("ggdag", "ggplot2"))
p1 <- suppressWarnings(ggdag::ggdag_adjust(x, stylized = TRUE))
p2 <- suppressWarnings(ggdag::ggdag_adjustment_set(shadow = TRUE, stylized = TRUE))

# tweak data
p1$data$type <- as.character(p1$data$adjusted)
p1$data$type[p1$data$name == attributes(x)$outcome] <- "outcome"
p1$data$type[p1$data$name %in% attributes(x)$exposure] <- "exposure"

p1$data$type <- as.character(p2$data$adjusted)
p2$data$type[p2$data$name == attributes(x)$outcome] <- "outcome"
p2$data$type[p2$data$name %in% attributes(x)$exposure] <- "exposure"

p1 <- ggdag::ggdag_status(x, text = FALSE, use_labels = "name", stylized = TRUE, shadow = TRUE) +
ggplot2::guides(color = "none") +
ggdag::theme_dag()
Expand Down

0 comments on commit d770222

Please sign in to comment.