diff --git a/DESCRIPTION b/DESCRIPTION index 01569208a..e840243f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,7 +30,7 @@ Suggests: broom.helpers (>= 1.15.0), broom.mixed (>= 0.2.9), car (>= 3.0-11), - effectsize (>= 0.6.0), + effectsize (>= 0.8.8), emmeans (>= 1.7.3), geepack (>= 1.3.2), ggsurvfit (>= 1.1.0), diff --git a/R/ard_effectsize_hedges_g.R b/R/ard_effectsize_hedges_g.R index 7cd99263d..2d1a68224 100644 --- a/R/ard_effectsize_hedges_g.R +++ b/R/ard_effectsize_hedges_g.R @@ -30,7 +30,7 @@ #' The data are then passed as #' `effectsize::hedges_g(x = data_wide[[]], y = data_wide[[]], paired = TRUE, ...)`. #' -#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters", "withr"), reference_pkg = "cardx")) +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters"), reference_pkg = "cardx")) #' cards::ADSL |> #' dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> #' ard_effectsize_hedges_g(by = ARM, variables = AGE) @@ -52,7 +52,7 @@ ard_effectsize_hedges_g <- function(data, by, variables, conf.level = 0.95, ...) set_cli_abort_call() # check installed packages --------------------------------------------------- - check_pkg_installed(c("effectsize", "parameters", "withr"), reference_pkg = "cardx") + check_pkg_installed(c("effectsize", "parameters"), reference_pkg = "cardx") # check/process inputs ------------------------------------------------------- check_not_missing(data) @@ -77,19 +77,12 @@ ard_effectsize_hedges_g <- function(data, by, variables, conf.level = 0.95, ...) variable = variable, lst_tidy = cards::eval_capture_conditions( - # Need to eval in NAMESAPCE DUE TO BUG IN effectsize v0.8.7. - # Can remove this later along with requirements for withr to be installed. - # Will also need to remove `hedges_g` from globalVariables() - withr::with_namespace( - package = "effectsize", - code = - hedges_g( - reformulate2(by, response = variable), - data = data |> tidyr::drop_na(all_of(c(by, variable))), - paired = FALSE, - ci = conf.level, - ... - ) + effectsize::hedges_g( + reformulate2(by, response = variable), + data = data |> tidyr::drop_na(all_of(c(by, variable))), + paired = FALSE, + ci = conf.level, + ... ) |> parameters::standardize_names(style = "broom") |> dplyr::mutate(method = "Hedge's G") @@ -143,10 +136,7 @@ ard_effectsize_paired_hedges_g <- function(data, by, variables, id, conf.level = .paired_data_pivot_wider(by = by, variable = variable, id = id) |> tidyr::drop_na(any_of(c("by1", "by2"))) # perform paired cohen's d test - withr::with_namespace( - package = "effectsize", - code = hedges_g(x = data_wide[["by1"]], y = data_wide[["by2"]], paired = TRUE, ci = conf.level, ...) - ) |> + effectsize::hedges_g(x = data_wide[["by1"]], y = data_wide[["by2"]], paired = TRUE, ci = conf.level, ...) |> parameters::standardize_names(style = "broom") |> dplyr::mutate(method = "Paired Hedge's G") }), diff --git a/R/cardx-package.R b/R/cardx-package.R index 9a843b1bf..5e11aba49 100644 --- a/R/cardx-package.R +++ b/R/cardx-package.R @@ -7,4 +7,4 @@ ## usethis namespace: end NULL -utils::globalVariables(c(".", "hedges_g")) +utils::globalVariables(c(".")) diff --git a/man/ard_effectsize_hedges_g.Rd b/man/ard_effectsize_hedges_g.Rd index 23c43e8d2..60c04f1e8 100644 --- a/man/ard_effectsize_hedges_g.Rd +++ b/man/ard_effectsize_hedges_g.Rd @@ -46,7 +46,7 @@ The data are then passed as \verb{effectsize::hedges_g(x = data_wide[[]], y = data_wide[[]], paired = TRUE, ...)}. } \examples{ -\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters", "withr"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} cards::ADSL |> dplyr::filter(ARM \%in\% c("Placebo", "Xanomeline High Dose")) |> ard_effectsize_hedges_g(by = ARM, variables = AGE) diff --git a/tests/testthat/test-ard_effectsize_hedges_g.R b/tests/testthat/test-ard_effectsize_hedges_g.R index 3bd0024e0..b21748c60 100644 --- a/tests/testthat/test-ard_effectsize_hedges_g.R +++ b/tests/testthat/test-ard_effectsize_hedges_g.R @@ -1,8 +1,6 @@ -skip_if_not(is_pkg_installed(c("effectsize", "parameters", "withr"), reference_pkg = "cardx")) +skip_if_not(is_pkg_installed(c("effectsize", "parameters"), reference_pkg = "cardx")) test_that("ard_effectsize_hedges_g() works", { - withr::local_namespace("effectsize") - expect_error( ard_hedges_g <- cards::ADSL |> @@ -14,7 +12,7 @@ test_that("ard_effectsize_hedges_g() works", { expect_equal( ard_hedges_g |> cards::get_ard_statistics(stat_name %in% c("estimate", "conf.low", "conf.high")), - hedges_g( + effectsize::hedges_g( AGE ~ ARM, data = cards::ADSL |> dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) ) |> @@ -45,8 +43,6 @@ test_that("ard_effectsize_hedges_g() works", { }) test_that("ard_effectsize_paired_hedges_g() works", { - withr::local_namespace("effectsize") - ADSL_paired <- cards::ADSL[c("ARM", "AGE")] |> dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> @@ -72,7 +68,7 @@ test_that("ard_effectsize_paired_hedges_g() works", { by = "USUBJID" ), expr = - hedges_g( + effectsize::hedges_g( x = AGE1, y = AGE2, paired = TRUE