diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml
index b9756395..bc48d10a 100644
--- a/.github/workflows/check.yaml
+++ b/.github/workflows/check.yaml
@@ -52,7 +52,7 @@ jobs:
config:
- {os: macOS-latest, r: 'devel', allowfail: true}
- {os: macOS-latest, r: 'release', allowfail: false}
- - {os: macOS-latest, r: 'oldrel', allowfail: false}
+ - {os: macOS-latest, r: 'oldrel', allowfail: true}
- {os: windows-latest, r: 'devel', allowfail: false}
- {os: windows-latest, r: 'release', allowfail: false}
@@ -106,8 +106,7 @@ jobs:
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
- key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3
- restore-keys: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-3
+ key: ${{ matrix.config.os }}-r-${{ matrix.config.r }}-v4
- name: Update AMR package dependencies
run: |
diff --git a/DESCRIPTION b/DESCRIPTION
index c73af0a0..3671c90f 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,5 +1,5 @@
Package: AMR
-Version: 1.6.0.9040
+Version: 1.6.0.9041
Date: 2021-05-16
Title: Antimicrobial Resistance Data Analysis
Authors@R: c(
diff --git a/NEWS.md b/NEWS.md
index 1e0ddd7c..43aa1a8d 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,4 @@
-# `AMR` 1.6.0.9040
+# `AMR` 1.6.0.9041
## Last updated: 16 May 2021
### New
@@ -6,7 +6,7 @@
* Function `italicise_taxonomy()` to make taxonomic names within a string italic, with support for markdown and ANSI
* Support for all four methods to determine first isolates as summarised by Hindler *et al.* (doi: [10.1086/511864](https://doi.org/10.1086/511864)): isolate-based, patient-based, episode-based and phenotype-based. The last method is now the default.
* The `first_isolate()` function gained the argument `method` that has to be "phenotype-based", "episode-based", "patient-based", or "isolate-based". The old behaviour is equal to "episode-based". The new default is "phenotype-based" if antimicrobial test results are available, and "episode-based" otherwise. This new default will yield slightly more isolates for selection (which is a good thing).
- * Since fungal isolates can also be selected, the functions `key_antibiotics()` and `key_antibiotics_equal()` are now deprecated in favour of the `key_antimicrobials()` and `antimicrobial_equal()` functions. Also, the new `all_antimicrobials()` function works like the old `key_antibiotics()` function, but includes any column with antimicrobial test results. Using `key_antimicrobials()` still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new `antifungal` argument to set antifungal agents (antimycotics).
+ * Since fungal isolates can also be selected, the functions `key_antibiotics()` and `key_antibiotics_equal()` are now deprecated in favour of the `key_antimicrobials()` and `antimicrobials_equal()` functions. Also, the new `all_antimicrobials()` function works like the old `key_antibiotics()` function, but includes any column with antimicrobial test results. Using `key_antimicrobials()` still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new `antifungal` argument to set antifungal agents (antimycotics).
* Using `type == "points"` in the `first_isolate()` function for phenotype-based selection will now consider all antimicrobial drugs in the data set, using the new `all_antimicrobials()`
* The `first_isolate()` function can now take a vector of values for `col_keyantibiotics` and can have an episode length of `Inf`
* Since the phenotype-based method is the new default, `filter_first_isolate()` renders the `filter_first_weighted_isolate()` function redundant. For this reason, `filter_first_weighted_isolate()` is now deprecated.
@@ -41,6 +41,7 @@
* Updated `skimr::skim()` usage for MIC values to also include 25th and 75th percentiles
* Fix for plotting missing MIC/disk diffusion values
* Updated join functions to always use `dplyr` join functions if the `dplyr` package is installed - now also preserving grouped variables
+* Fix for filtering on antibiotic classes (such as `filter_cephalosporins()`)
### Other
* All unit tests are now processed by the `tinytest` package, instead of the `testthat` package. The `testthat` package unfortunately requires tons of dependencies that are also heavy and only usable for recent R versions, defeating the purpose to test our package under less recent R versions. On the contrary, the `tinytest` package is very lightweight and dependency-free.
diff --git a/R/filter_ab_class.R b/R/filter_ab_class.R
index 3b39b1de..3824edb3 100644
--- a/R/filter_ab_class.R
+++ b/R/filter_ab_class.R
@@ -125,11 +125,11 @@ filter_ab_class <- function(x,
group %like% ab_class |
atc_group1 %like% ab_class |
atc_group2 %like% ab_class)
- ab_group <- find_ab_group(ab_class)
- if (ab_group == "") {
+ if (nrow(ab_reference) == 0) {
message_("Unknown antimicrobial class '", ab_class.bak, "', data left unchanged.")
return(x.bak)
}
+ ab_group <- find_ab_group(ab_class.bak)
# get the columns with a group names in the chosen ab class
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
if (length(agents) == 0) {
diff --git a/R/first_isolate.R b/R/first_isolate.R
index 539ecfc4..8ee669ac 100755
--- a/R/first_isolate.R
+++ b/R/first_isolate.R
@@ -435,7 +435,7 @@ first_isolate <- function(x = NULL,
if (length(c(row.start:row.end)) == pm_n_distinct(x[c(row.start:row.end), col_mo, drop = TRUE])) {
if (info == TRUE) {
message_("=> Found ", font_bold(paste(length(c(row.start:row.end)), "first isolates")),
- ", as all isolates were different microorganisms",
+ ", as all isolates were different microbial species",
add_fn = font_black,
as_note = FALSE)
}
diff --git a/R/mdro.R b/R/mdro.R
index 9c098edf..35a1c1b0 100755
--- a/R/mdro.R
+++ b/R/mdro.R
@@ -306,7 +306,7 @@ mdro <- function(x = NULL,
}
if (is.null(col_mo) & guideline$code == "tb") {
message_("No column found as input for `col_mo`, ",
- font_bold(paste0("assuming all records contain", font_italic("Mycobacterium tuberculosis"), ".")))
+ font_bold(paste0("assuming all rows contain ", font_italic("Mycobacterium tuberculosis"), ".")))
x$mo <- as.mo("Mycobacterium tuberculosis") # consider overkill at all times: MO_lookup[which(MO_lookup$fullname == "Mycobacterium tuberculosis"), "mo", drop = TRUE]
col_mo <- "mo"
}
diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz
index 30419455..b95567af 100644
Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ
diff --git a/data-raw/_install_deps.R b/data-raw/_install_deps.R
index 45101a3f..2ee13c5b 100644
--- a/data-raw/_install_deps.R
+++ b/data-raw/_install_deps.R
@@ -26,7 +26,7 @@
pkg_suggests <- AMR:::trimws(unlist(strsplit(packageDescription("AMR")$Suggests, ",(\n)?")))
to_install <- pkg_suggests[!pkg_suggests %in% rownames(utils::installed.packages())]
-to_update <- as.data.frame(old.packages(), stringsAsFactors = FALSE)
+to_update <- as.data.frame(utils::old.packages(repos = "https://cran.rstudio.com/"), stringsAsFactors = FALSE)
for (i in seq_len(length(to_install))) {
cat("Installing package", to_install[i], "\n")
@@ -37,7 +37,7 @@ for (i in seq_len(length(to_install))) {
}
for (i in seq_len(length(to_update))) {
- cat("Updating package", to_install[i], "\n")
+ cat("Updating package", to_update[i], "\n")
tryCatch(update.packages(to_update[i], repos = "https://cran.rstudio.com/", ask = FALSE),
# message = function(m) invisible(),
warning = function(w) message(w$message),
diff --git a/docs/404.html b/docs/404.html
index c233e496..ac51a244 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html
index 585a1a73..797d0977 100644
--- a/docs/LICENSE-text.html
+++ b/docs/LICENSE-text.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html
index 14460448..e0d97259 100644
--- a/docs/articles/datasets.html
+++ b/docs/articles/datasets.html
@@ -39,7 +39,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
diff --git a/docs/articles/index.html b/docs/articles/index.html
index 41083db5..3d510192 100644
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
diff --git a/docs/authors.html b/docs/authors.html
index 182737e4..b6f838ea 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
diff --git a/docs/index.html b/docs/index.html
index 482d591e..9a1939cd 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -42,7 +42,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
diff --git a/docs/news/index.html b/docs/news/index.html
index 1178e830..4723b739 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
@@ -236,9 +236,9 @@
Source: NEWS.md
-
-
+
+
Last updated: 16 May 2021
@@ -253,7 +253,7 @@
Support for all four methods to determine first isolates as summarised by Hindler et al. (doi: 10.1086/511864): isolate-based, patient-based, episode-based and phenotype-based. The last method is now the default.
- The
first_isolate()
function gained the argument method
that has to be “phenotype-based”, “episode-based”, “patient-based”, or “isolate-based”. The old behaviour is equal to “episode-based”. The new default is “phenotype-based” if antimicrobial test results are available, and “episode-based” otherwise. This new default will yield slightly more isolates for selection (which is a good thing).
-- Since fungal isolates can also be selected, the functions
key_antibiotics()
and key_antibiotics_equal()
are now deprecated in favour of the key_antimicrobials()
and antimicrobial_equal()
functions. Also, the new all_antimicrobials()
function works like the old key_antibiotics()
function, but includes any column with antimicrobial test results. Using key_antimicrobials()
still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new antifungal
argument to set antifungal agents (antimycotics).
+- Since fungal isolates can also be selected, the functions
key_antibiotics()
and key_antibiotics_equal()
are now deprecated in favour of the key_antimicrobials()
and antimicrobials_equal()
functions. Also, the new all_antimicrobials()
function works like the old key_antibiotics()
function, but includes any column with antimicrobial test results. Using key_antimicrobials()
still only selects six preferred antibiotics for Gram-negatives, six for Gram-positives, and six universal antibiotics. It has a new antifungal
argument to set antifungal agents (antimycotics).
- Using
type == "points"
in the first_isolate()
function for phenotype-based selection will now consider all antimicrobial drugs in the data set, using the new all_antimicrobials()
- The
first_isolate()
function can now take a vector of values for col_keyantibiotics
and can have an episode length of Inf
@@ -306,6 +306,7 @@
- Updated
skimr::skim()
usage for MIC values to also include 25th and 75th percentiles
- Fix for plotting missing MIC/disk diffusion values
- Updated join functions to always use
dplyr
join functions if the dplyr
package is installed - now also preserving grouped variables
+- Fix for filtering on antibiotic classes (such as
filter_cephalosporins()
)
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index bd358c12..8f4fdc31 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-16T07:24Z
+last_built: 2021-05-16T08:48Z
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 0452af7d..01b6a0de 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
diff --git a/docs/survey.html b/docs/survey.html
index 9f955e98..4c9d06e9 100644
--- a/docs/survey.html
+++ b/docs/survey.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.6.0.9040
+ 1.6.0.9041
diff --git a/git_premaster.sh b/git_premaster.sh
index 185d6164..a2848381 100755
--- a/git_premaster.sh
+++ b/git_premaster.sh
@@ -133,7 +133,7 @@ echo
echo "•••••••••••••••••"
echo "• Building site •"
echo "•••••••••••••••••"
-Rscript -e "suppressMessages(pkgdown::build_site(lazy = $lazy, examples = FALSE))"
+Rscript -e "suppressMessages(pkgdown::build_site(lazy = $lazy, examples = FALSE, install = FALSE))"
# always rebuild datasets vignette
Rscript -e "pkgdown::build_article('datasets', lazy = FALSE, quiet = TRUE)"
# add the survey page
diff --git a/inst/tinytest/test-_misc.R b/inst/tinytest/test-_misc.R
index af898a51..f6cc297d 100755
--- a/inst/tinytest/test-_misc.R
+++ b/inst/tinytest/test-_misc.R
@@ -23,33 +23,33 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
-expect_equal(percentage(0.25), "25%")
-expect_equal(percentage(0.5), "50%")
-expect_equal(percentage(0.500, digits = 1), "50.0%")
-expect_equal(percentage(0.1234), "12.3%")
+expect_equal(AMR:::percentage(0.25), "25%")
+expect_equal(AMR:::percentage(0.5), "50%")
+expect_equal(AMR:::percentage(0.500, digits = 1), "50.0%")
+expect_equal(AMR:::percentage(0.1234), "12.3%")
# round up 0.5
-expect_equal(percentage(0.0054), "0.5%")
-expect_equal(percentage(0.0055), "0.6%")
+expect_equal(AMR:::percentage(0.0054), "0.5%")
+expect_equal(AMR:::percentage(0.0055), "0.6%")
-expect_equal(strrep("A", 5), "AAAAA")
-expect_equal(strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))
-expect_equal(trimws(" test "), "test")
-expect_equal(trimws(" test ", "l"), "test ")
-expect_equal(trimws(" test ", "r"), " test")
+expect_equal(AMR:::strrep("A", 5), "AAAAA")
+expect_equal(AMR:::strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))
+expect_equal(AMR:::trimws(" test "), "test")
+expect_equal(AMR:::trimws(" test ", "l"), "test ")
+expect_equal(AMR:::trimws(" test ", "r"), " test")
-expect_warning(generate_warning_abs_missing(c("AMP", "AMX")))
-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"))
- 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))
+expect_warning(AMR:::generate_warning_abs_missing(c("AMP", "AMX")))
+expect_warning(AMR:::generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
+expect_warning(AMR:::get_column_abx(example_isolates, hard_dependencies = "FUS"))
+expect_message(AMR:::get_column_abx(example_isolates, soft_dependencies = "FUS"))
+ if (pkg_is_available("dplyr")) {
+ expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
+ expect_warning(AMR:::get_column_abx(rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
}
# we rely on "grouped_tbl" being a class of grouped tibbles, so implement a test that checks for this:
- if (suppressWarnings(require("dplyr"))) {
- expect_true(is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id)))
+ if (pkg_is_available("dplyr")) {
+ expect_true(AMR:::is_null_or_grouped_tbl(example_isolates %>% group_by(hospital_id)))
}
diff --git a/inst/tinytest/test-ab_class_selectors.R b/inst/tinytest/test-ab_class_selectors.R
index 56327f57..76bf9a23 100644
--- a/inst/tinytest/test-ab_class_selectors.R
+++ b/inst/tinytest/test-ab_class_selectors.R
@@ -23,20 +23,20 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
-if (suppressWarnings(require("dplyr"))) {
-expect_true(example_isolates %>% select(aminoglycosides()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(carbapenems()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(cephalosporins()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(cephalosporins_1st()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(cephalosporins_2nd()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(cephalosporins_3rd()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(cephalosporins_4th()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(cephalosporins_5th()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(fluoroquinolones()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(glycopeptides()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(macrolides()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(oxazolidinones()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(penicillins()) %>% ncol() < ncol(example_isolates))
-expect_true(example_isolates %>% select(tetracyclines()) %>% ncol() < ncol(example_isolates))
+if (pkg_is_available("dplyr")) {
+ expect_true(example_isolates %>% select(aminoglycosides()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(carbapenems()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(cephalosporins()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(cephalosporins_1st()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(cephalosporins_2nd()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(cephalosporins_3rd()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(cephalosporins_4th()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(cephalosporins_5th()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(fluoroquinolones()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(glycopeptides()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(macrolides()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(oxazolidinones()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(penicillins()) %>% ncol() < ncol(example_isolates))
+ expect_true(example_isolates %>% select(tetracyclines()) %>% ncol() < ncol(example_isolates))
}
diff --git a/inst/tinytest/test-bug_drug_combinations.R b/inst/tinytest/test-bug_drug_combinations.R
index 50ae048c..f79d81f8 100644
--- a/inst/tinytest/test-bug_drug_combinations.R
+++ b/inst/tinytest/test-bug_drug_combinations.R
@@ -25,6 +25,6 @@
b <- suppressWarnings(bug_drug_combinations(example_isolates))
expect_inherits(b, "bug_drug_combinations")
-expect_stdout(print(b))
+expect_stdout(suppressMessages(print(b)))
expect_true(is.data.frame(format(b)))
expect_true(is.data.frame(format(b, combine_IR = TRUE, add_ab_group = FALSE)))
diff --git a/inst/tinytest/test-count.R b/inst/tinytest/test-count.R
index 38cbcd93..ba634402 100644
--- a/inst/tinytest/test-count.R
+++ b/inst/tinytest/test-count.R
@@ -38,9 +38,9 @@ expect_equal(suppressWarnings(count_S(example_isolates$AMX)) + count_I(example_i
# warning for speed loss
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(count_resistant(as.character(example_isolates$AMC)))
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(count_resistant(example_isolates$AMC,
as.character(example_isolates$GEN)))
@@ -53,7 +53,7 @@ expect_error(count_susceptible("test", as_percent = "test"))
expect_error(count_df(c("A", "B", "C")))
expect_error(count_df(example_isolates[, "date"]))
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("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/inst/tinytest/test-data.R b/inst/tinytest/test-data.R
index 76be3511..9577ad38 100644
--- a/inst/tinytest/test-data.R
+++ b/inst/tinytest/test-data.R
@@ -23,7 +23,7 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
-expect_true(check_dataset_integrity()) # in misc.R
+expect_true(AMR:::check_dataset_integrity()) # in misc.R
# IDs should always be unique
expect_identical(nrow(microorganisms), length(unique(microorganisms$mo)))
@@ -34,14 +34,14 @@ expect_identical(class(antibiotics$ab), c("ab", "character"))
# check cross table reference
expect_true(all(microorganisms.codes$mo %in% microorganisms$mo))
expect_true(all(example_isolates$mo %in% microorganisms$mo))
-expect_true(all(microorganisms.translation$mo_new %in% microorganisms$mo))
+expect_true(all(AMR:::microorganisms.translation$mo_new %in% microorganisms$mo))
+expect_false(any(AMR:::microorganisms.translation$mo_old %in% microorganisms$mo))
expect_true(all(rsi_translation$mo %in% microorganisms$mo))
expect_true(all(rsi_translation$ab %in% antibiotics$ab))
expect_true(all(intrinsic_resistant$microorganism %in% microorganisms$fullname)) # also important for mo_is_intrinsic_resistant()
expect_true(all(intrinsic_resistant$antibiotic %in% antibiotics$name))
expect_false(any(is.na(microorganisms.codes$code)))
expect_false(any(is.na(microorganisms.codes$mo)))
-expect_false(any(microorganisms.translation$mo_old %in% microorganisms$mo))
expect_true(all(dosage$ab %in% antibiotics$ab))
expect_true(all(dosage$name %in% antibiotics$name))
@@ -52,7 +52,7 @@ expect_identical(as.ab(antibiotics$name), antibiotics$ab)
datasets <- data(package = "AMR", envir = asNamespace("AMR"))$results[, "Item"]
for (i in seq_len(length(datasets))) {
dataset <- get(datasets[i], envir = asNamespace("AMR"))
- expect_identical(dataset_UTF8_to_ASCII(dataset), dataset, info = datasets[i])
+ expect_identical(AMR:::dataset_UTF8_to_ASCII(dataset), dataset, info = datasets[i])
}
df <- AMR:::MO_lookup
@@ -76,7 +76,7 @@ expect_stdout(print(catalogue_of_life_version()))
uncategorised <- subset(microorganisms,
genus == "Staphylococcus" &
!species %in% c("", "aureus") &
- !mo %in% c(MO_CONS, MO_COPS))
+ !mo %in% c(AMR:::MO_CONS, AMR:::MO_COPS))
expect_true(NROW(uncategorised) == 0,
info = ifelse(NROW(uncategorised) == 0,
"All staphylococcal species categorised as CoNS/CoPS.",
diff --git a/inst/tinytest/test-disk.R b/inst/tinytest/test-disk.R
index 5187bd7c..c4f82894 100755
--- a/inst/tinytest/test-disk.R
+++ b/inst/tinytest/test-disk.R
@@ -43,13 +43,13 @@ expect_silent(barplot(as.disk(c(10, 20, 40))))
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 (suppressWarnings(require("ggplot2"))) {
+if (pkg_is_available("ggplot2")) {
expect_inherits(ggplot(as.disk(c(10, 20, 40))), "gg")
expect_inherits(ggplot(as.disk(c(10, 20, 40)), expand = FALSE), "gg")
expect_inherits(ggplot(as.disk(c(10, 20, 40)), mo = "esco", ab = "cipr"), "gg")
}
expect_stdout(print(as.disk(12)))
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
expect_stdout(print(tibble(d = as.disk(12))))
}
diff --git a/inst/tinytest/test-episode.R b/inst/tinytest/test-episode.R
index 618963f5..d2305f66 100644
--- a/inst/tinytest/test-episode.R
+++ b/inst/tinytest/test-episode.R
@@ -36,7 +36,7 @@ test_df <- rbind(
expect_equal(get_episode(test_df$date, 365),
c(1, 1, 2, 2, 2, 3, 3, 4, 1, 2, 2, 2, 3))
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("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/inst/tinytest/test-eucast_rules.R b/inst/tinytest/test-eucast_rules.R
index 014f073f..2549d175 100755
--- a/inst/tinytest/test-eucast_rules.R
+++ b/inst/tinytest/test-eucast_rules.R
@@ -24,15 +24,15 @@
# ==================================================================== #
# thoroughly check input table
-expect_equal(colnames(eucast_rules_file),
+expect_equal(colnames(AMR:::eucast_rules_file),
c("if_mo_property", "like.is.one_of", "this_value",
"and_these_antibiotics", "have_these_values",
"then_change_these_antibiotics", "to_value",
"reference.rule", "reference.rule_group",
"reference.version",
"note"))
-MOs_mentioned <- unique(eucast_rules_file$this_value)
-MOs_mentioned <- sort(trimws(unlist(strsplit(MOs_mentioned[!is_valid_regex(MOs_mentioned)], ",", fixed = TRUE))))
+MOs_mentioned <- unique(AMR:::eucast_rules_file$this_value)
+MOs_mentioned <- sort(trimws(unlist(strsplit(MOs_mentioned[!AMR:::is_valid_regex(MOs_mentioned)], ",", fixed = TRUE))))
MOs_test <- suppressWarnings(suppressMessages(mo_name(MOs_mentioned)))
expect_true(length(MOs_mentioned[MOs_test != MOs_mentioned]) == 0)
@@ -71,7 +71,7 @@ b <- data.frame(mo = c("Staphylococcus aureus",
expect_equal(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)
# piperacillin must be R in Enterobacteriaceae when tica is R
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
expect_equal(suppressWarnings(
example_isolates %>%
filter(mo_family(mo) == "Enterobacteriaceae") %>%
@@ -109,7 +109,7 @@ expect_equal(
"S")
# also test norf
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
expect_stdout(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"), info = TRUE)))
}
diff --git a/inst/tinytest/test-filter_ab_class.R b/inst/tinytest/test-filter_ab_class.R
index 1476933d..a8132cf5 100644
--- a/inst/tinytest/test-filter_ab_class.R
+++ b/inst/tinytest/test-filter_ab_class.R
@@ -23,22 +23,22 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
-if (suppressWarnings(require("dplyr"))) {
- expect_true(example_isolates %>% filter_ab_class("carbapenem") %>% nrow() > 0)
- expect_true(example_isolates %>% filter_aminoglycosides() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_carbapenems() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_cephalosporins() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_1st_cephalosporins() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_2nd_cephalosporins() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_3rd_cephalosporins() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_4th_cephalosporins() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_5th_cephalosporins() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_fluoroquinolones() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_glycopeptides() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_macrolides() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_oxazolidinones() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_penicillins() %>% ncol() > 0)
- expect_true(example_isolates %>% filter_tetracyclines() %>% ncol() > 0)
+if (pkg_is_available("dplyr")) {
+ expect_true(example_isolates %>% filter_ab_class("carbapenem") %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_aminoglycosides() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_carbapenems() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_cephalosporins() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_1st_cephalosporins() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_2nd_cephalosporins() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_3rd_cephalosporins() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_4th_cephalosporins() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_5th_cephalosporins() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_fluoroquinolones() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_glycopeptides() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_macrolides() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_oxazolidinones() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_penicillins() %>% nrow() < nrow(example_isolates))
+ expect_true(example_isolates %>% filter_tetracyclines() %>% nrow() < nrow(example_isolates))
expect_true(example_isolates %>% filter_carbapenems("R", "all") %>% nrow() > 0)
diff --git a/inst/tinytest/test-first_isolate.R b/inst/tinytest/test-first_isolate.R
index fa591837..81807922 100755
--- a/inst/tinytest/test-first_isolate.R
+++ b/inst/tinytest/test-first_isolate.R
@@ -110,7 +110,7 @@ expect_error(first_isolate(example_isolates,
col_date = "non-existing col",
col_mo = "mo"))
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
# if mo is not an mo class, result should be the same
expect_identical(example_isolates %>%
mutate(mo = as.character(mo)) %>%
@@ -174,9 +174,7 @@ expect_identical(filter_first_isolate(example_isolates),
# notice that all mo's are distinct, so all are TRUE
-expect_true(all(example_isolates %pm>%
- pm_distinct(mo, .keep_all = TRUE) %pm>%
- first_isolate(info = TRUE) == TRUE))
+expect_true(all(first_isolate(AMR:::pm_distinct(example_isolates, mo, .keep_all = TRUE), info = TRUE) == TRUE))
# only one isolate, so return fast
expect_true(first_isolate(data.frame(mo = "Escherichia coli", date = Sys.Date(), patient = "patient"), info = TRUE))
diff --git a/inst/tinytest/test-ggplot_rsi.R b/inst/tinytest/test-ggplot_rsi.R
index b328ce12..55e2435f 100644
--- a/inst/tinytest/test-ggplot_rsi.R
+++ b/inst/tinytest/test-ggplot_rsi.R
@@ -23,7 +23,7 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
-if (suppressWarnings(require("dplyr")) & suppressWarnings(require("ggplot2"))) {
+if (pkg_is_available("dplyr") & pkg_is_available("ggplot2")) {
pdf(NULL) # prevent Rplots.pdf being created
diff --git a/inst/tinytest/test-italicise_taxonomy.R b/inst/tinytest/test-italicise_taxonomy.R
index 5d88a775..7474e80a 100644
--- a/inst/tinytest/test-italicise_taxonomy.R
+++ b/inst/tinytest/test-italicise_taxonomy.R
@@ -27,7 +27,7 @@ expect_identical(italicise_taxonomy("test for E. coli"),
"test for *E. coli*")
expect_identical(italicise_taxonomy("test for E. coli"),
italicize_taxonomy("test for E. coli"))
-if (has_colour()) {
+if (AMR:::has_colour()) {
expect_identical(italicise_taxonomy("test for E. coli", type = "ansi"),
"test for \033[3mE. coli\033[23m")
}
diff --git a/inst/tinytest/test-mdro.R b/inst/tinytest/test-mdro.R
index 38644726..7e15f1a3 100755
--- a/inst/tinytest/test-mdro.R
+++ b/inst/tinytest/test-mdro.R
@@ -232,7 +232,7 @@ expect_warning(mdro(example_isolates,
info = FALSE))
# print groups
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
expect_stdout(x <- mdro(example_isolates %>% group_by(hospital_id), info = TRUE))
expect_stdout(x <- mdro(example_isolates %>% group_by(hospital_id), guideline = custom, info = TRUE))
}
diff --git a/inst/tinytest/test-mic.R b/inst/tinytest/test-mic.R
index acefa5e0..f4a027ec 100755
--- a/inst/tinytest/test-mic.R
+++ b/inst/tinytest/test-mic.R
@@ -49,7 +49,7 @@ expect_silent(barplot(as.mic(c(1, 2, 4, 8))))
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 (suppressWarnings(require("ggplot2"))) {
+if (pkg_is_available("ggplot2")) {
expect_inherits(ggplot(as.mic(c(1, 2, 4, 8))), "gg")
expect_inherits(ggplot(as.mic(c(1, 2, 4, 8)), expand = FALSE), "gg")
expect_inherits(ggplot(as.mic(c(1, 2, 4, 8, 32)), mo = "esco", ab = "cipr"), "gg")
@@ -58,7 +58,7 @@ expect_stdout(print(as.mic(c(1, 2, 4, 8))))
expect_inherits(summary(as.mic(c(2, 8))), c("summaryDefault", "table"))
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
expect_stdout(print(tibble(m = as.mic(2:4))))
}
diff --git a/inst/tinytest/test-mo.R b/inst/tinytest/test-mo.R
index fedb479d..bbe870ee 100644
--- a/inst/tinytest/test-mo.R
+++ b/inst/tinytest/test-mo.R
@@ -144,7 +144,7 @@ expect_identical(as.character(as.mo("S. sanguinis", Lancefield = TRUE)), "B_S
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 (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
# select with one column
expect_identical(
example_isolates[1:10, ] %>%
@@ -273,7 +273,7 @@ expect_equal(as.character(as.mo(c("meningococ", "gonococ", "pneumococ"))),
expect_equal(suppressWarnings(as.character(as.mo(c("yeasts", "fungi")))),
c("F_YEAST", "F_FUNGUS"))
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
# print tibble
expect_stdout(print(tibble(mo = as.mo("B_ESCHR_COLI"))))
}
@@ -292,6 +292,6 @@ expect_equal(as.character(as.mo(c("E. coli", "E. coli ignorethis"), ignore_patte
c("B_ESCHR_COLI", NA))
# frequency tables
-if (suppressWarnings(require("cleaner"))) {
+if (pkg_is_available("cleaner")) {
expect_inherits(cleaner::freq(example_isolates$mo), "freq")
}
diff --git a/inst/tinytest/test-mo_property.R b/inst/tinytest/test-mo_property.R
index ece3e6bc..a4d7acec 100644
--- a/inst/tinytest/test-mo_property.R
+++ b/inst/tinytest/test-mo_property.R
@@ -119,7 +119,7 @@ expect_equal(mo_is_intrinsic_resistant(c("Escherichia coli", "Staphylococcus aur
# with reference data
expect_equal(mo_name("test", reference_df = data.frame(col1 = "test", mo = "B_ESCHR_COLI")),
"Escherichia coli")
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("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/inst/tinytest/test-pca.R b/inst/tinytest/test-pca.R
index d0868094..3ba78b25 100644
--- a/inst/tinytest/test-pca.R
+++ b/inst/tinytest/test-pca.R
@@ -42,12 +42,12 @@ expect_inherits(pca_model, "pca")
pdf(NULL) # prevent Rplots.pdf being created
-if (suppressWarnings(require("ggplot2"))) {
+if (pkg_is_available("ggplot2")) {
ggplot_pca(pca_model, ellipse = TRUE)
ggplot_pca(pca_model, arrows_textangled = FALSE)
}
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
resistance_data <- example_isolates %>%
group_by(order = mo_order(mo),
genus = mo_genus(mo)) %>%
@@ -56,7 +56,7 @@ if (suppressWarnings(require("dplyr"))) {
pca(AMC, CXM, CTX, CAZ, GEN, TOB, TMP, "SXT")
expect_inherits(pca_result, "prcomp")
- if (suppressWarnings(require("ggplot2"))) {
+ if (pkg_is_available("ggplot2")) {
ggplot_pca(pca_result, ellipse = TRUE)
ggplot_pca(pca_result, ellipse = FALSE, arrows_textangled = FALSE, scale = FALSE)
}
diff --git a/inst/tinytest/test-proportion.R b/inst/tinytest/test-proportion.R
index 6de6476d..93927483 100755
--- a/inst/tinytest/test-proportion.R
+++ b/inst/tinytest/test-proportion.R
@@ -45,7 +45,7 @@ expect_equal(example_isolates %>% proportion_SI(AMC, GEN, only_all_tested = TRUE
0.9382647,
tolerance = 0.0001)
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
# percentages
expect_equal(example_isolates %>%
group_by(hospital_id) %>%
@@ -88,14 +88,14 @@ if (suppressWarnings(require("dplyr"))) {
example_isolates$AMX %>% proportion_R())
)
}
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(proportion_R(as.character(example_isolates$AMC)))
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(proportion_S(as.character(example_isolates$AMC)))
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(proportion_S(as.character(example_isolates$AMC,
example_isolates$GEN)))
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(n_rsi(as.character(example_isolates$AMC,
example_isolates$GEN)))
expect_equal(suppressWarnings(n_rsi(as.character(example_isolates$AMC,
@@ -120,11 +120,11 @@ expect_identical(suppressWarnings(proportion_S(example_isolates$AMX, minimum = n
NA_real_)
# warning for speed loss
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(proportion_R(as.character(example_isolates$GEN)))
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(proportion_I(as.character(example_isolates$GEN)))
-reset_all_thrown_messages()
+AMR:::reset_all_thrown_messages()
expect_warning(proportion_S(example_isolates$AMC, as.character(example_isolates$GEN)))
expect_error(proportion_df(c("A", "B", "C")))
expect_error(proportion_df(example_isolates[, "date"]))
diff --git a/inst/tinytest/test-resistance_predict.R b/inst/tinytest/test-resistance_predict.R
index a19584f2..4293fe14 100644
--- a/inst/tinytest/test-resistance_predict.R
+++ b/inst/tinytest/test-resistance_predict.R
@@ -23,7 +23,7 @@
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
# ==================================================================== #
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
expect_stdout(AMX_R <- example_isolates %>%
filter(mo == "B_ESCHR_COLI") %>%
rsi_predict(col_ab = "AMX",
@@ -43,7 +43,7 @@ expect_stdout(x <- suppressMessages(resistance_predict(example_isolates,
info = TRUE)))
pdf(NULL) # prevent Rplots.pdf being created
expect_silent(plot(x))
-if (suppressWarnings(require("ggplot2"))) {
+if (pkg_is_available("ggplot2")) {
expect_silent(ggplot_rsi_predict(x))
expect_silent(ggplot(x))
expect_error(ggplot_rsi_predict(example_isolates))
diff --git a/inst/tinytest/test-rsi.R b/inst/tinytest/test-rsi.R
index afcac559..f046d628 100644
--- a/inst/tinytest/test-rsi.R
+++ b/inst/tinytest/test-rsi.R
@@ -34,7 +34,7 @@ expect_inherits(unique(x[1], x[9]), "rsi")
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 (suppressWarnings(require("ggplot2"))) expect_inherits(ggplot(as.rsi(c("S", "I", "R"))), "gg")
+if (pkg_is_available("ggplot2")) expect_inherits(ggplot(as.rsi(c("S", "I", "R"))), "gg")
expect_stdout(print(as.rsi(c("S", "I", "R"))))
expect_equal(as.character(as.rsi(c(1:3))), c("S", "I", "R"))
expect_equal(suppressWarnings(as.logical(as.rsi("INVALID VALUE"))), NA)
@@ -49,7 +49,7 @@ expect_identical(as.logical(lapply(example_isolates, is.rsi.eligible)),
expect_error(as.rsi.mic(as.mic(16)))
expect_error(as.rsi.disk(as.disk(16)))
expect_error(get_guideline("this one does not exist"))
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
# 40 rsi columns
expect_equal(example_isolates %>%
mutate_at(vars(PEN:RIF), as.character) %>%
@@ -61,10 +61,10 @@ if (suppressWarnings(require("dplyr"))) {
expect_stdout(print(tibble(ab = as.rsi("S"))))
}
-if (suppressWarnings(require("skimr"))) {
+if (pkg_is_available("skimr")) {
expect_inherits(skim(example_isolates),
"data.frame")
- if (suppressWarnings(require("dplyr"))) {
+ if (pkg_is_available("dplyr")) {
expect_inherits(example_isolates %>%
mutate(m = as.mic(2),
d = as.disk(20)) %>%
@@ -94,7 +94,7 @@ expect_equal(as.rsi(as.mic(2), "E. coli", "ampicillin", guideline = "EUCAST 2020
as.rsi("S"))
expect_equal(as.rsi(as.mic(32), "E. coli", "ampicillin", guideline = "EUCAST 2020"),
as.rsi("R"))
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
expect_true(suppressWarnings(example_isolates %>%
mutate(amox_mic = as.mic(2)) %>%
select(mo, amox_mic) %>%
@@ -121,7 +121,7 @@ expect_equal(as.character(
ab = "ERY",
guideline = "CLSI")),
"R")
-if (suppressWarnings(require("dplyr"))) {
+if (pkg_is_available("dplyr")) {
expect_true(example_isolates %>%
mutate(amox_disk = as.disk(15)) %>%
select(mo, amox_disk) %>%
@@ -130,7 +130,7 @@ if (suppressWarnings(require("dplyr"))) {
is.rsi())
}
# frequency tables
-if (suppressWarnings(require("cleaner"))) {
+if (pkg_is_available("cleaner")) {
expect_inherits(cleaner::freq(example_isolates$AMX), "freq")
}
diff --git a/inst/tinytest/test-zzz.R b/inst/tinytest/test-zzz.R
index 5fa85f89..64fa0e29 100644
--- a/inst/tinytest/test-zzz.R
+++ b/inst/tinytest/test-zzz.R
@@ -103,7 +103,7 @@ for (i in seq_len(length(import_functions))) {
pkg <- unname(import_functions[i])
# function should exist in foreign pkg namespace
if (pkg %in% rownames(installed.packages())) {
- tst <- !is.null(import_fn(name = fn, pkg = pkg, error_on_fail = FALSE))
+ tst <- !is.null(AMR:::import_fn(name = fn, pkg = pkg, error_on_fail = FALSE))
expect_true(tst,
info = ifelse(tst,
"All external function references exist.",
diff --git a/tests/tinytest.R b/tests/tinytest.R
index 1c35830f..588b5fb8 100644
--- a/tests/tinytest.R
+++ b/tests/tinytest.R
@@ -27,8 +27,18 @@
if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) {
# env var 'R_LIBS_USER' got overwritten during 'R CMD check' in GitHub Actions, so:
.libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths()))
- print(.libPaths())
- library(tinytest)
- library(AMR)
- test_package("AMR")
+ # helper function
+ pkg_is_available <- function(pkg, also_load = TRUE) {
+ if (also_load == TRUE) {
+ out <- suppressWarnings(require(pkg, character.only = TRUE, warn.conflicts = FALSE, quietly = TRUE))
+ } else {
+ out <- requireNamespace(pkg, quietly = TRUE)
+ }
+ isTRUE(out)
+ }
+
+ if (pkg_is_available("tinytest")) {
+ library(AMR)
+ out <- test_package("AMR")
+ }
}