diff --git a/DESCRIPTION b/DESCRIPTION index 5015e87b..be61564e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,7 +34,6 @@ Imports: rlang, rstan, scales, - voi (>= 1.0.1) Depends: R (>= 3.5.0) Suggests: @@ -51,6 +50,7 @@ Suggests: splancs, testthat (>= 2.1.0), vdiffr, + voi (>= 1.0.1), withr RdMacros: Rdpack VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index 67fcab31..799589d8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -157,4 +157,3 @@ importFrom(utils,methods) importFrom(utils,modifyList) importFrom(utils,str) importFrom(utils,tail) -importFrom(voi,evppi) diff --git a/R/evppi.default.R b/R/evppi.default.R index dcab8566..32484451 100644 --- a/R/evppi.default.R +++ b/R/evppi.default.R @@ -9,7 +9,6 @@ evppi.default <- function(he, ...) { #' @rdname evppi #' -#' @importFrom voi evppi #' @examples #' data(Vaccine, package = "BCEA") #' treats <- c("Status quo", "Vaccination") @@ -26,6 +25,13 @@ evppi.bcea <- function(he, residuals = TRUE, method = NULL, ...) { + if (!requireNamespace("voi", quietly = TRUE)) { + stop( + "Package \"voi (>= 1.0.1)\" must be installed to use this function.", + call. = FALSE + ) + } + comp_ids <- c(he$comp, he$ref) outputs <- list(e = he$e[, comp_ids], c = he$c[, comp_ids], diff --git a/tests/testthat/test-evppi.R b/tests/testthat/test-evppi.R index 2e185d13..17cb17a7 100644 --- a/tests/testthat/test-evppi.R +++ b/tests/testthat/test-evppi.R @@ -7,6 +7,12 @@ # library(BCEA) if (interactive()) library(testthat) +if (!requireNamespace("voi", quietly = TRUE)) { + stop( + "Package \"voi (>= 1.0.1)\" must be installed to use this function.", + call. = FALSE + ) +} test_that("GAM regression (default) with vaccine data", {