Skip to content

Commit

Permalink
add conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Aug 3, 2024
1 parent 435af39 commit 293dad4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ S3method(test_vuong,default)
S3method(test_wald,ListNestedRegressions)
S3method(test_wald,ListNonNestedRegressions)
S3method(test_wald,default)
export(as.dag.check_dag)
export(binned_residuals)
export(check_autocorrelation)
export(check_clusterstructure)
Expand Down
10 changes: 9 additions & 1 deletion R/check_dag.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ check_dag <- function(...,
outcome = NULL,
exposure = NULL,
adjusted = NULL,
latent = NULL,
effect = c("all", "total", "direct")) {
insight::check_if_installed(
c("ggdag", "dagitty"),
Expand Down Expand Up @@ -48,7 +49,7 @@ check_dag <- function(...,
}

# convert to dag
dag_args <- c(formulas, list(exposure = exposure, outcome = outcome))
dag_args <- c(formulas, list(exposure = exposure, outcome = outcome, latent = latent))
dag <- do.call(ggdag::dagify, dag_args)

# add adjustments
Expand Down Expand Up @@ -92,6 +93,13 @@ check_dag <- function(...,

# methods --------------------------------------------------------------------

#' @rdname check_dag
#' @export
as.dag.check_dag <- function(x, ...) {
cat(as.character(x))
}


#' @export
print.check_dag <- function(x, ...) {
effect <- attributes(x)$effect
Expand Down
4 changes: 4 additions & 0 deletions man/check_dag.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 293dad4

Please sign in to comment.