From 28c881f77252e8f917c10f2487ae314102c2e88d Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 18 Sep 2024 14:23:49 +0200 Subject: [PATCH] add test --- R/check_dag.R | 9 ++++++++- man/check_dag.Rd | 9 ++++++++- tests/testthat/test-check_dag.R | 6 ++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/R/check_dag.R b/R/check_dag.R index 2d7bdb42b..7a64ae4d0 100644 --- a/R/check_dag.R +++ b/R/check_dag.R @@ -147,7 +147,14 @@ #' exposure = ~x, #' adjusted = ~ b + c #' ) -#' dag +#' +#' # if not provided, "outcome" is taken from first formula, same for "exposure" +#' # thus, we can simplify the above expression to +#' check_dag( +#' y ~ x + b + c, +#' x ~ b, +#' adjusted = ~ b + c +#' ) #' #' # use specific layout for the DAG #' dag <- check_dag( diff --git a/man/check_dag.Rd b/man/check_dag.Rd index f7c74ee18..fa7e92207 100644 --- a/man/check_dag.Rd +++ b/man/check_dag.Rd @@ -173,7 +173,14 @@ check_dag( exposure = ~x, adjusted = ~ b + c ) -dag + +# if not provided, "outcome" is taken from first formula, same for "exposure" +# thus, we can simplify the above expression to +check_dag( + y ~ x + b + c, + x ~ b, + adjusted = ~ b + c +) # use specific layout for the DAG dag <- check_dag( diff --git a/tests/testthat/test-check_dag.R b/tests/testthat/test-check_dag.R index 12153cf18..0d6efa9d6 100644 --- a/tests/testthat/test-check_dag.R +++ b/tests/testthat/test-check_dag.R @@ -185,4 +185,10 @@ test_that("check_dag, formula-interface", { adjusted = ~ b + c ) expect_identical(attributes(dag)$adjusted, c("b", "c")) + dag2 <- check_dag( + y ~ x + b + c, + x ~ b, + adjusted = ~ b + c + ) + expect_identical(dag, dag2) })