mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 18:46:11 +01:00
(v1.6.0.9028) new unit test flow
This commit is contained in:
parent
5b9fb8daf4
commit
9ed2f6490f
10
.github/workflows/check.yaml
vendored
10
.github/workflows/check.yaml
vendored
@ -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
|
||||
|
@ -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(
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# `AMR` 1.6.0.9027
|
||||
# `AMR` 1.6.0.9028
|
||||
## <small>Last updated: 13 May 2021</small>
|
||||
|
||||
### New
|
||||
|
Binary file not shown.
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9028</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9028</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9028</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9028</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9028</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9028</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,9 +236,9 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1609027" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0.9027">
|
||||
<a href="#amr-1609027" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9027</h1>
|
||||
<div id="amr-1609028" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.6.0.9028">
|
||||
<a href="#amr-1609028" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9028</h1>
|
||||
<div id="last-updated-13-may-2021" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-13-may-2021" class="anchor"></a><small>Last updated: 13 May 2021</small>
|
||||
|
@ -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
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9028</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9027</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9028</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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)))
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
})
|
||||
|
@ -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)
|
||||
|
@ -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))))
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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)))
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -121,28 +121,34 @@ test_that("first isolates work", {
|
||||
col_date = "non-existing col",
|
||||
col_mo = "mo"))
|
||||
|
||||
require("dplyr")
|
||||
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))
|
||||
|
||||
# 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))
|
||||
|
||||
# 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)
|
||||
|
||||
})
|
||||
|
@ -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
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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))))
|
||||
}
|
||||
})
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -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) %>%
|
||||
|
@ -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",
|
||||
|
@ -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")
|
||||
}
|
||||
})
|
||||
|
@ -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"))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user