Skip to content

Commit

Permalink
moved {voi} into Suggests and added requireNamespace checks to instal…
Browse files Browse the repository at this point in the history
…l it if needed
  • Loading branch information
n8thangreen committed Feb 15, 2024
1 parent 96823bb commit 9d10a3e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Imports:
rlang,
rstan,
scales,
voi (>= 1.0.1)
Depends:
R (>= 3.5.0)
Suggests:
Expand All @@ -51,6 +50,7 @@ Suggests:
splancs,
testthat (>= 2.1.0),
vdiffr,
voi (>= 1.0.1),
withr
RdMacros: Rdpack
VignetteBuilder: knitr
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,3 @@ importFrom(utils,methods)
importFrom(utils,modifyList)
importFrom(utils,str)
importFrom(utils,tail)
importFrom(voi,evppi)
8 changes: 7 additions & 1 deletion R/evppi.default.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ evppi.default <- function(he, ...) {

#' @rdname evppi
#'
#' @importFrom voi evppi
#' @examples
#' data(Vaccine, package = "BCEA")
#' treats <- c("Status quo", "Vaccination")
Expand All @@ -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],
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-evppi.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {

Expand Down

0 comments on commit 9d10a3e

Please sign in to comment.