diff --git a/R/test_consequences.R b/R/test_consequences.R index 9118a23..438ef50 100644 --- a/R/test_consequences.R +++ b/R/test_consequences.R @@ -86,7 +86,7 @@ test_consequences_data_frame <- function(model_frame, outcome_name, outcome_type # Initial diagnostic stat calculation can be slow with large datasets, # and/or many models, so give the option for parallelization. - if (parallel && "future.apply" %in% rownames(utils::installed.packages())) { + if (parallel && requireNamespace("future.apply", quietly = TRUE)) { lapply_fun = future.apply::future_lapply } else { lapply_fun = lapply diff --git a/tests/testthat/test-test_consequences.R b/tests/testthat/test-test_consequences.R index 1bc5000..61c0327 100644 --- a/tests/testthat/test-test_consequences.R +++ b/tests/testthat/test-test_consequences.R @@ -44,7 +44,8 @@ test_that("test_consequences() works", { ) expect_no_error({ - if ("future.apply" %in% rownames(utils::installed.packages())) { + # This test is only run if the future.apply package is installed. + if (requireNamespace("future.apply", quietly = TRUE)) { future::plan("multisession", workers = 2) test_consequences(formula = cancer ~ cancerpredmarker + marker, data = df_binary, parallel = TRUE)