diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 6f0cd595..5e0f9a51 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -78,8 +78,8 @@ jobs: - {os: ubuntu-16.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - {os: ubuntu-16.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - {os: ubuntu-16.04, r: '3.3', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - # - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - # - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - {os: ubuntu-16.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} env: @@ -161,14 +161,12 @@ jobs: run: | tar -xf data-raw/AMR_latest.tar.gz rm -rf AMR/vignettes - Rscript -e "utils::installed.packages()" - R CMD check AMR --no-manual --as-cran + R CMD check AMR --no-manual --as-cran --no-vignettes --library='/Users/runner/work/_temp/Library' shell: bash - name: Show testthat output if: always() run: | - ls -lh find . -name 'testthat.Rout*' -exec cat '{}' \; || true shell: bash @@ -177,4 +175,4 @@ jobs: uses: actions/upload-artifact@master with: name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results - path: check + path: *.Rcheck diff --git a/DESCRIPTION b/DESCRIPTION index 274a3dd8..f0d58ecb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.6.0.9027 +Version: 1.6.0.9028 Date: 2021-05-13 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 8cafac13..cc8b053d 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# `AMR` 1.6.0.9027 +# `AMR` 1.6.0.9028 ## Last updated: 13 May 2021 ### New diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 2b7fb842..bbb90353 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/404.html b/docs/404.html index 0de95077..2965cacd 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9027 + 1.6.0.9028 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 9f19f672..b6137c4d 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9027 + 1.6.0.9028 diff --git a/docs/articles/index.html b/docs/articles/index.html index 9774790e..0fffc9dc 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9027 + 1.6.0.9028 diff --git a/docs/authors.html b/docs/authors.html index 9e8f75b5..6ed6a3c1 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9027 + 1.6.0.9028 diff --git a/docs/index.html b/docs/index.html index 142bce06..06280279 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.6.0.9027 + 1.6.0.9028 diff --git a/docs/news/index.html b/docs/news/index.html index ce2edfdc..8a6912f1 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9027 + 1.6.0.9028 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

- Unreleased AMR 1.6.0.9027

+
+

+ Unreleased AMR 1.6.0.9028

Last updated: 13 May 2021 diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 105bfeb3..75389aea 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2021-05-13T19:35Z +last_built: 2021-05-13T20:43Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/index.html b/docs/reference/index.html index c87dd6d3..03e9e9c3 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9027 + 1.6.0.9028

diff --git a/docs/survey.html b/docs/survey.html index 3368ca0c..2c068b0d 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9027 + 1.6.0.9028
diff --git a/tests/testthat/test-_misc.R b/tests/testthat/test-_misc.R index b1b82ab0..5561429e 100755 --- a/tests/testthat/test-_misc.R +++ b/tests/testthat/test-_misc.R @@ -51,15 +51,17 @@ test_that("looking up ab columns works", { expect_warning(generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE)) expect_warning(get_column_abx(example_isolates, hard_dependencies = "FUS")) expect_message(get_column_abx(example_isolates, soft_dependencies = "FUS")) - expect_warning(get_column_abx(dplyr::rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE)) - expect_warning(get_column_abx(dplyr::rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE)) + if (suppressWarnings(require("dplyr"))) { + expect_warning(get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE)) + expect_warning(get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE)) + } }) test_that("looking up ab columns works", { skip_on_cran() - + # we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this: - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_true(is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id))) } diff --git a/tests/testthat/test-ab_class_selectors.R b/tests/testthat/test-ab_class_selectors.R index bc215db8..a02ff5da 100644 --- a/tests/testthat/test-ab_class_selectors.R +++ b/tests/testthat/test-ab_class_selectors.R @@ -28,19 +28,20 @@ context("ab_class_selectors.R") test_that("Antibiotic class selectors work", { skip_on_cran() - expect_lt(example_isolates %>% dplyr::select(aminoglycosides()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(carbapenems()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(cephalosporins()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(cephalosporins_1st()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(cephalosporins_2nd()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(cephalosporins_3rd()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(cephalosporins_4th()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(cephalosporins_5th()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(fluoroquinolones()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(glycopeptides()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(macrolides()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(oxazolidinones()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(penicillins()) %>% ncol(), ncol(example_isolates)) - expect_lt(example_isolates %>% dplyr::select(tetracyclines()) %>% ncol(), ncol(example_isolates)) - + if (suppressWarnings(require("dplyr"))) { + expect_lt(example_isolates %>% select(aminoglycosides()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(carbapenems()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(cephalosporins()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(cephalosporins_1st()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(cephalosporins_2nd()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(cephalosporins_3rd()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(cephalosporins_4th()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(cephalosporins_5th()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(fluoroquinolones()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(glycopeptides()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(macrolides()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(oxazolidinones()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(penicillins()) %>% ncol(), ncol(example_isolates)) + expect_lt(example_isolates %>% select(tetracyclines()) %>% ncol(), ncol(example_isolates)) + } }) diff --git a/tests/testthat/test-count.R b/tests/testthat/test-count.R index f60f62ae..fd988c4e 100644 --- a/tests/testthat/test-count.R +++ b/tests/testthat/test-count.R @@ -58,7 +58,7 @@ test_that("counts work", { expect_error(count_df(c("A", "B", "C"))) expect_error(count_df(example_isolates[, "date"])) - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_equal(example_isolates %>% count_susceptible(AMC), 1433) expect_equal(example_isolates %>% count_susceptible(AMC, GEN, only_all_tested = TRUE), 1687) expect_equal(example_isolates %>% count_susceptible(AMC, GEN, only_all_tested = FALSE), 1764) diff --git a/tests/testthat/test-disk.R b/tests/testthat/test-disk.R index 82a94e4d..15bb359d 100755 --- a/tests/testthat/test-disk.R +++ b/tests/testthat/test-disk.R @@ -47,14 +47,14 @@ test_that("disk works", { expect_silent(plot(as.disk(c(10, 20, 40)))) expect_silent(plot(as.disk(c(10, 20, 40)), expand = FALSE)) expect_silent(plot(as.disk(c(10, 20, 40)), mo = "esco", ab = "cipr")) - if (require("ggplot2")) { + if (suppressWarnings(require("ggplot2"))) { expect_s3_class(ggplot(as.disk(c(10, 20, 40))), "gg") expect_s3_class(ggplot(as.disk(c(10, 20, 40)), expand = FALSE), "gg") expect_s3_class(ggplot(as.disk(c(10, 20, 40)), mo = "esco", ab = "cipr"), "gg") } expect_output(print(as.disk(12))) - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_output(print(tibble(d = as.disk(12)))) } diff --git a/tests/testthat/test-episode.R b/tests/testthat/test-episode.R index e909cfc9..c7005393 100644 --- a/tests/testthat/test-episode.R +++ b/tests/testthat/test-episode.R @@ -41,7 +41,7 @@ test_that("episodes work", { expect_equal(get_episode(test_df$date, 365), c(1, 1, 2, 2, 2, 3, 3, 4, 1, 2, 2, 2, 3)) - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_identical(test_df %>% group_by(patient_id) %>% mutate(f = is_new_episode(date, 365)) %>% pull(f), c(TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE)) diff --git a/tests/testthat/test-eucast_rules.R b/tests/testthat/test-eucast_rules.R index d9aaaf4d..55c42202 100755 --- a/tests/testthat/test-eucast_rules.R +++ b/tests/testthat/test-eucast_rules.R @@ -77,7 +77,7 @@ test_that("EUCAST rules work", { expect_equal(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b) # piperacillin must be R in Enterobacteriaceae when tica is R - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_equal(suppressWarnings( example_isolates %>% filter(mo_family(mo) == "Enterobacteriaceae") %>% @@ -115,7 +115,7 @@ test_that("EUCAST rules work", { "S") # also test norf - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_output(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"), info = TRUE))) } diff --git a/tests/testthat/test-filter_ab_class.R b/tests/testthat/test-filter_ab_class.R index 4065bc6b..94f55e43 100644 --- a/tests/testthat/test-filter_ab_class.R +++ b/tests/testthat/test-filter_ab_class.R @@ -28,7 +28,7 @@ context("filter_ab_class.R") test_that("ATC-group filtering works", { skip_on_cran() - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_gt(example_isolates %>% filter_ab_class("carbapenem") %>% nrow(), 0) expect_gt(example_isolates %>% filter_aminoglycosides() %>% ncol(), 0) expect_gt(example_isolates %>% filter_carbapenems() %>% ncol(), 0) diff --git a/tests/testthat/test-first_isolate.R b/tests/testthat/test-first_isolate.R index 5cd6aca0..9b673eec 100755 --- a/tests/testthat/test-first_isolate.R +++ b/tests/testthat/test-first_isolate.R @@ -121,28 +121,34 @@ test_that("first isolates work", { col_date = "non-existing col", col_mo = "mo")) - require("dplyr") - - # if mo is not an mo class, result should be the same - expect_identical(example_isolates %>% - mutate(mo = as.character(mo)) %>% - first_isolate(col_date = "date", - col_mo = "mo", - col_patient_id = "patient_id", - info = FALSE), - example_isolates %>% - first_isolate(col_date = "date", - col_mo = "mo", - col_patient_id = "patient_id", - info = FALSE)) - - # support for WHONET - expect_message(example_isolates %>% - select(-patient_id) %>% - mutate(`First name` = "test", - `Last name` = "test", - Sex = "Female") %>% - first_isolate(info = TRUE)) + if (suppressWarnings(require("dplyr"))) { + # if mo is not an mo class, result should be the same + expect_identical(example_isolates %>% + mutate(mo = as.character(mo)) %>% + first_isolate(col_date = "date", + col_mo = "mo", + col_patient_id = "patient_id", + info = FALSE), + example_isolates %>% + first_isolate(col_date = "date", + col_mo = "mo", + col_patient_id = "patient_id", + info = FALSE)) + + # support for WHONET + expect_message(example_isolates %>% + select(-patient_id) %>% + mutate(`First name` = "test", + `Last name` = "test", + Sex = "Female") %>% + first_isolate(info = TRUE)) + + # groups + x <- example_isolates %>% group_by(ward_icu) %>% mutate(first = first_isolate()) + y <- example_isolates %>% group_by(ward_icu) %>% mutate(first = first_isolate(.)) + expect_identical(x, y) + + } # missing dates should be no problem df <- example_isolates @@ -185,10 +191,4 @@ test_that("first isolates work", { # only one isolate, so return fast expect_true(first_isolate(data.frame(mo = "Escherichia coli", date = Sys.Date(), patient = "patient"), info = TRUE)) - - # groups - x <- example_isolates %>% group_by(ward_icu) %>% mutate(first = first_isolate()) - y <- example_isolates %>% group_by(ward_icu) %>% mutate(first = first_isolate(.)) - expect_identical(x, y) - }) diff --git a/tests/testthat/test-ggplot_rsi.R b/tests/testthat/test-ggplot_rsi.R index 5ce82c08..67be05b4 100644 --- a/tests/testthat/test-ggplot_rsi.R +++ b/tests/testthat/test-ggplot_rsi.R @@ -32,7 +32,7 @@ test_that("ggplot_rsi works", { skip_if_not_installed("ggplot2") skip_if_not_installed("dplyr") - if (require("dplyr") & require("ggplot2")) { + if (suppressWarnings(require("dplyr")) & suppressWarnings(require("ggplot2"))) { pdf(NULL) # prevent Rplots.pdf being created diff --git a/tests/testthat/test-mdro.R b/tests/testthat/test-mdro.R index 838a9cd6..e17141b5 100755 --- a/tests/testthat/test-mdro.R +++ b/tests/testthat/test-mdro.R @@ -244,7 +244,7 @@ test_that("mdro works", { info = FALSE)) # print groups - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_output(x <- mdro(example_isolates %>% group_by(hospital_id), info = TRUE)) expect_output(x <- mdro(example_isolates %>% group_by(hospital_id), guideline = custom, info = TRUE)) } diff --git a/tests/testthat/test-mic.R b/tests/testthat/test-mic.R index d4afad7b..2144a4d4 100755 --- a/tests/testthat/test-mic.R +++ b/tests/testthat/test-mic.R @@ -53,7 +53,7 @@ test_that("mic works", { expect_silent(plot(as.mic(c(1, 2, 4, 8)))) expect_silent(plot(as.mic(c(1, 2, 4, 8)), expand = FALSE)) expect_silent(plot(as.mic(c(1, 2, 4, 8)), mo = "esco", ab = "cipr")) - if (require("ggplot2")) { + if (suppressWarnings(require("ggplot2"))) { expect_s3_class(ggplot(as.mic(c(1, 2, 4, 8))), "gg") expect_s3_class(ggplot(as.mic(c(1, 2, 4, 8)), expand = FALSE), "gg") expect_s3_class(ggplot(as.mic(c(1, 2, 4, 8, 32)), mo = "esco", ab = "cipr"), "gg") @@ -62,7 +62,7 @@ test_that("mic works", { expect_s3_class(summary(as.mic(c(2, 8))), c("summaryDefault", "table")) - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_output(print(tibble(m = as.mic(2:4)))) } }) diff --git a/tests/testthat/test-mo.R b/tests/testthat/test-mo.R index 7afb945d..c1e8a144 100644 --- a/tests/testthat/test-mo.R +++ b/tests/testthat/test-mo.R @@ -150,7 +150,7 @@ test_that("as.mo works", { expect_identical(as.character(as.mo("S. salivarius", Lancefield = FALSE)), "B_STRPT_SLVR") expect_identical(as.character(as.mo("S. salivarius", Lancefield = TRUE)), "B_STRPT_GRPK") # group K - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { # select with one column expect_identical( example_isolates[1:10, ] %>% @@ -282,8 +282,10 @@ test_that("as.mo works", { expect_equal(suppressWarnings(as.character(as.mo(c("yeasts", "fungi")))), c("F_YEAST", "F_FUNGUS")) - # print tibble - expect_output(print(tibble(mo = as.mo("B_ESCHR_COLI")))) + if (suppressWarnings(require("dplyr"))) { + # print tibble + expect_output(print(tibble(mo = as.mo("B_ESCHR_COLI")))) + } # assigning and subsetting x <- example_isolates$mo @@ -299,7 +301,7 @@ test_that("as.mo works", { c("B_ESCHR_COLI", NA)) # frequency tables - if (require("cleaner")) { + if (suppressWarnings(require("cleaner"))) { expect_s3_class(cleaner::freq(example_isolates$mo), "freq") } diff --git a/tests/testthat/test-mo_property.R b/tests/testthat/test-mo_property.R index c7b338c8..29c61533 100644 --- a/tests/testthat/test-mo_property.R +++ b/tests/testthat/test-mo_property.R @@ -131,7 +131,7 @@ test_that("mo_property works", { expect_equal(mo_name("test", reference_df = data.frame(col1 = "test", mo = "B_ESCHR_COLI")), "Escherichia coli") - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_equal(example_isolates %>% filter(mo_is_gram_negative()) %>% nrow(), 730) expect_equal(example_isolates %>% filter(mo_is_gram_positive()) %>% nrow(), diff --git a/tests/testthat/test-pca.R b/tests/testthat/test-pca.R index f1feef64..0475165e 100644 --- a/tests/testthat/test-pca.R +++ b/tests/testthat/test-pca.R @@ -49,10 +49,12 @@ test_that("PCA works", { expect_s3_class(pca_model, "pca") pdf(NULL) # prevent Rplots.pdf being created - ggplot_pca(pca_model, ellipse = TRUE) - ggplot_pca(pca_model, arrows_textangled = FALSE) + if (suppressWarnings(require("ggplot2"))) { + ggplot_pca(pca_model, ellipse = TRUE) + ggplot_pca(pca_model, arrows_textangled = FALSE) + } - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { resistance_data <- example_isolates %>% group_by(order = mo_order(mo), genus = mo_genus(mo)) %>% @@ -60,7 +62,9 @@ test_that("PCA works", { pca_result <- resistance_data %>% pca(AMC, CXM, CTX, CAZ, GEN, TOB, TMP, "SXT") expect_s3_class(pca_result, "prcomp") - ggplot_pca(pca_result, ellipse = TRUE) - ggplot_pca(pca_result, ellipse = FALSE, arrows_textangled = FALSE, scale = FALSE) + if (suppressWarnings(require("ggplot2"))) { + ggplot_pca(pca_result, ellipse = TRUE) + ggplot_pca(pca_result, ellipse = FALSE, arrows_textangled = FALSE, scale = FALSE) + } } }) diff --git a/tests/testthat/test-proportion.R b/tests/testthat/test-proportion.R index 987c1fa0..5949fa7c 100755 --- a/tests/testthat/test-proportion.R +++ b/tests/testthat/test-proportion.R @@ -52,7 +52,7 @@ test_that("proportions works", { 0.9382647, tolerance = 0.0001) - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { # percentages expect_equal(example_isolates %>% group_by(hospital_id) %>% diff --git a/tests/testthat/test-resistance_predict.R b/tests/testthat/test-resistance_predict.R index e66bdd6b..87041d80 100644 --- a/tests/testthat/test-resistance_predict.R +++ b/tests/testthat/test-resistance_predict.R @@ -28,7 +28,7 @@ context("resistance_predict.R") test_that("prediction of rsi works", { skip_on_cran() - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_output(AMX_R <- example_isolates %>% filter(mo == "B_ESCHR_COLI") %>% rsi_predict(col_ab = "AMX", diff --git a/tests/testthat/test-rsi.R b/tests/testthat/test-rsi.R index e70829ed..d51eaf57 100644 --- a/tests/testthat/test-rsi.R +++ b/tests/testthat/test-rsi.R @@ -42,7 +42,7 @@ test_that("rsi works", { pdf(NULL) # prevent Rplots.pdf being created expect_silent(barplot(as.rsi(c("S", "I", "R")))) expect_silent(plot(as.rsi(c("S", "I", "R")))) - if (require("ggplot2")) expect_s3_class(ggplot(as.rsi(c("S", "I", "R"))), "gg") + if (suppressWarnings(require("ggplot2"))) expect_s3_class(ggplot(as.rsi(c("S", "I", "R"))), "gg") expect_output(print(as.rsi(c("S", "I", "R")))) expect_equal(as.character(as.rsi(c(1:3))), c("S", "I", "R")) @@ -64,7 +64,7 @@ test_that("rsi works", { expect_error(get_guideline("this one does not exist")) - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { # 40 rsi columns expect_equal(example_isolates %>% mutate_at(vars(PEN:RIF), as.character) %>% @@ -77,10 +77,10 @@ test_that("rsi works", { expect_output(print(tibble(ab = as.rsi("S")))) } - if (require("skimr")) { + if (suppressWarnings(require("skimr"))) { expect_s3_class(skim(example_isolates), "data.frame") - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_s3_class(example_isolates %>% mutate(m = as.mic(2), d = as.disk(20)) %>% @@ -116,7 +116,7 @@ test_that("mic2rsi works", { expect_equal(as.rsi(as.mic(32), "E. coli", "ampicillin", guideline = "EUCAST 2020"), as.rsi("R")) - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_true(suppressWarnings(example_isolates %>% mutate(amox_mic = as.mic(2)) %>% select(mo, amox_mic) %>% @@ -149,7 +149,7 @@ test_that("disk2rsi works", { guideline = "CLSI")), "R") - if (require("dplyr")) { + if (suppressWarnings(require("dplyr"))) { expect_true(example_isolates %>% mutate(amox_disk = as.disk(15)) %>% select(mo, amox_disk) %>% @@ -159,7 +159,7 @@ test_that("disk2rsi works", { } # frequency tables - if (require("cleaner")) { + if (suppressWarnings(require("cleaner"))) { expect_s3_class(cleaner::freq(example_isolates$AMX), "freq") } }) diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index 6e8dcc2c..3891d353 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -109,7 +109,9 @@ test_that("imports work", { fn <- names(import_functions)[i] pkg <- unname(import_functions[i]) # function should exist in foreign pkg namespace - expect(!is.null(import_fn(name = fn, pkg = pkg, error_on_fail = FALSE)), - failure_message = paste0("Function ", pkg, "::", fn, "() does not exist anymore")) + if (pkg %in% rownames(installed.packages())) { + expect(!is.null(import_fn(name = fn, pkg = pkg, error_on_fail = FALSE)), + failure_message = paste0("Function ", pkg, "::", fn, "() does not exist anymore")) + } } })