` for [random_disk()] (see [as.disk()])
@@ -56,18 +56,26 @@
#' random_disk(100, "Streptococcus pneumoniae", "ampicillin") # range 12-27
#' }
random_mic <- function(size, mo = NULL, ab = NULL, ...) {
+ meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
+ meet_criteria(mo, allow_class = "character", has_length = 1, allow_NULL = TRUE)
+ meet_criteria(ab, allow_class = "character", has_length = 1, allow_NULL = TRUE)
random_exec("MIC", size = size, mo = mo, ab = ab)
}
#' @rdname random
#' @export
random_disk <- function(size, mo = NULL, ab = NULL, ...) {
+ meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
+ meet_criteria(mo, allow_class = "character", has_length = 1, allow_NULL = TRUE)
+ meet_criteria(ab, allow_class = "character", has_length = 1, allow_NULL = TRUE)
random_exec("DISK", size = size, mo = mo, ab = ab)
}
#' @rdname random
#' @export
random_rsi <- function(size, prob_RSI = c(0.33, 0.33, 0.33), ...) {
+ meet_criteria(size, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
+ meet_criteria(prob_RSI, allow_class = c("numeric", "integer"), has_length = 3)
sample(as.rsi(c("R", "S", "I")), size = size, replace = TRUE, prob = prob_RSI)
}
diff --git a/R/rsi.R b/R/rsi.R
index cc5fa42c..308c4274 100755
--- a/R/rsi.R
+++ b/R/rsi.R
@@ -349,7 +349,7 @@ as.rsi.mic <- function(x,
# for dplyr's across()
cur_column_dplyr <- import_fn("cur_column", "dplyr", error_on_fail = FALSE)
- if (!is.null(cur_column_dplyr) && tryCatch(is.data.frame(get_current_data("ab", call = 0, reuse_from_1st_call = FALSE)), error = function(e) FALSE)) {
+ if (!is.null(cur_column_dplyr) && tryCatch(is.data.frame(get_current_data("ab", call = 0)), error = function(e) FALSE)) {
# try to get current column, which will only be available when in across()
ab <- tryCatch(cur_column_dplyr(),
error = function(e) ab)
@@ -438,7 +438,7 @@ as.rsi.disk <- function(x,
# for dplyr's across()
cur_column_dplyr <- import_fn("cur_column", "dplyr", error_on_fail = FALSE)
- if (!is.null(cur_column_dplyr) && tryCatch(is.data.frame(get_current_data("ab", call = 0, reuse_from_1st_call = FALSE)), error = function(e) FALSE)) {
+ if (!is.null(cur_column_dplyr) && tryCatch(is.data.frame(get_current_data("ab", call = 0)), error = function(e) FALSE)) {
# try to get current column, which will only be available when in across()
ab <- tryCatch(cur_column_dplyr(),
error = function(e) ab)
@@ -448,7 +448,7 @@ as.rsi.disk <- function(x,
mo_var_found <- ""
if (is.null(mo)) {
tryCatch({
- df <- get_current_data(arg_name = "mo", call = -3, reuse_from_1st_call = FALSE) # will return an error if not found
+ df <- get_current_data(arg_name = "mo", call = -3) # will return an error if not found
mo <- NULL
try({
mo <- suppressMessages(search_type_in_df(df, "mo"))
diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz
index 328e744a..e574aea9 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 42aac100..78762f55 100644
--- a/data-raw/_install_deps.R
+++ b/data-raw/_install_deps.R
@@ -24,8 +24,8 @@
# ==================================================================== #
# some old R instances have trouble installing tinytest, so we ship it too
-install.packages("data-raw/tinytest_1.2.4.10.tar.gz")
-install.packages("data-raw/AMR_latest.tar.gz", dependencies = FALSE)
+install.packages("data-raw/tinytest_1.2.4.10.tar.gz", repos = "https://cran.rstudio.com/", type = "source")
+install.packages("data-raw/AMR_latest.tar.gz", repos = "https://cran.rstudio.com/", type = "source", dependencies = FALSE)
pkg_suggests <- gsub("[^a-zA-Z0-9]+", "", unlist(strsplit(packageDescription("AMR", fields = "Suggests"), ", ?")))
cat("Packages listed in Suggests:", paste(pkg_suggests, collapse = ", "), "\n")
diff --git a/docs/404.html b/docs/404.html
index a8039e26..889cf6fb 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.7.1.9004
+ 1.7.1.9005
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html
index 36fbf52a..e6725334 100644
--- a/docs/LICENSE-text.html
+++ b/docs/LICENSE-text.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.7.1.9004
+ 1.7.1.9005
diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html
index 3a85c03f..9cd2cede 100644
--- a/docs/articles/datasets.html
+++ b/docs/articles/datasets.html
@@ -39,7 +39,7 @@
AMR (for R)
- 1.7.1.9004
+ 1.7.1.9005
@@ -192,7 +192,7 @@
diff --git a/docs/authors.html b/docs/authors.html
index 865cc4a8..e28124f9 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.7.1.9004
+ 1.7.1.9005
diff --git a/docs/index.html b/docs/index.html
index e45f10f1..994b266e 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -42,7 +42,7 @@
AMR (for R)
- 1.7.1.9004
+ 1.7.1.9005
@@ -217,16 +217,12 @@
library(dplyr)
example_isolates %>%
- mutate(bacteria = mo_fullname(mo)) %>%
- filter(mo_is_gram_negative(), mo_is_intrinsic_resistant(ab = "cefotax")) %>%
- select(bacteria, aminoglycosides(), carbapenems())
-#> ℹ Using column 'mo' as input for `mo_is_gram_negative()`
-#> ℹ Using column 'mo' as input for `mo_is_intrinsic_resistant()`
-#> ℹ Determining intrinsic resistance based on 'EUCAST Expert Rules' and 'EUCAST Intrinsic
-#> Resistance and Unusual Phenotypes' v3.2 (2020)
-#> ℹ For `aminoglycosides()` using columns: 'AMK' (amikacin), 'GEN' (gentamicin), 'KAN'
-#> (kanamycin) and 'TOB' (tobramycin)
-#> ℹ For `carbapenems()` using columns: 'IPM' (imipenem) and 'MEM' (meropenem)
+ mutate(bacteria = mo_fullname()) %>%
+ filter(mo_is_gram_negative(),
+ mo_is_intrinsic_resistant(ab = "cefotax")) %>%
+ select(bacteria,
+ aminoglycosides(),
+ carbapenems())
With only having defined a row filter on Gram-negative bacteria with intrinsic resistance to cefotaxime (mo_is_gram_negative()
and mo_is_intrinsic_resistant()
) and a column selection on two antibiotic groups (aminoglycosides()
and carbapenems()
), the reference data about all microorganisms and all antibiotics in the AMR
package make sure you get what you meant: