From bb3728f023151d0eeef80e7d21e2258d7e2d4655 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Fri, 21 Feb 2020 13:13:34 +0100 Subject: [PATCH] (v1.0.0.9003) prepare for short update --- DESCRIPTION | 4 ++-- NEWS.md | 6 +++--- R/rsi.R | 25 +++++++++---------------- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 14 +++++++------- docs/reference/as.rsi.html | 5 ++++- docs/reference/index.html | 2 +- man/as.rsi.Rd | 5 ++++- tests/testthat/test-rsi.R | 10 ++++++++++ 13 files changed, 45 insertions(+), 36 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 618e56c4..727772bb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.0.0.9002 -Date: 2020-02-20 +Version: 1.0.0.9003 +Date: 2020-02-21 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 45e97681..1e17777c 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,7 @@ -# AMR 1.0.0.9002 -## Last updated: 20-Feb-2020 +# AMR 1.0.0.9003 +## Last updated: 21-Feb-2020 ### Changed -* Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole * Fixed floating point error for some MIC compa in EUCAST 2020 guideline * Interpretation from MIC values to R/SI can now be used with `mutate_at()` of the dplyr package: ```r @@ -12,6 +11,7 @@ yourdata %>% mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = .$mybacteria) ``` +* Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole * Added `uti` (as abbreviation of urinary tract infections) as parameter to `as.rsi()`, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs # AMR 1.0.0 diff --git a/R/rsi.R b/R/rsi.R index 33d0aa4f..6e9894de 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -67,6 +67,8 @@ #' NIT = as.mic(32)) #' as.rsi(df) #' +#' \donttest{ +#' #' # the dplyr way #' library(dplyr) #' df %>% @@ -88,7 +90,8 @@ #' #' df %>% #' mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE) -#' +#' } +#' #' # for single values #' as.rsi(x = as.mic(2), #' mo = as.mo("S. pneumoniae"), @@ -199,20 +202,6 @@ as.rsi.default <- function(x, ...) { } } -#' @importFrom dplyr %>% -input_resembles_mic <- function(x) { - mic <- x %>% - gsub("[^0-9.,]+", "", .) %>% - unique() - mic_valid <- suppressWarnings(as.mic(mic)) - result <- sum(!is.na(mic_valid)) / length(mic) - if (is.na(result)) { - 0 - } else { - result - } -} - #' @rdname as.rsi #' @export as.rsi.mic <- function(x, mo, ab = deparse(substitute(x)), guideline = "EUCAST", uti = FALSE, ...) { @@ -402,10 +391,14 @@ get_guideline <- function(guideline) { rev() %>% .[1] } + if (!guideline_param %like% " ") { + # like 'EUCAST2020', should be 'EUCAST 2020' + guideline_param <- gsub("([a-z]+)([0-9]+)", "\\1 \\2", guideline_param, ignore.case = TRUE) + } if (!guideline_param %in% rsi_translation$guideline) { stop(paste0("invalid guideline: '", guideline, - "'.\nValid guidelines are: ", paste0("'", rev(sort(unique(rsi_translation$guideline))), "'", collapse = ", ")), + "'.\nValid guidelines are: ", paste0("'", unique(rsi_translation$guideline), "'", collapse = ", "), "."), call. = FALSE) } diff --git a/docs/404.html b/docs/404.html index 87b19b90..0b45f7dc 100644 --- a/docs/404.html +++ b/docs/404.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9002 + 1.0.0.9003 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 5e578863..7ef89b7a 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9002 + 1.0.0.9003 diff --git a/docs/articles/index.html b/docs/articles/index.html index 6cbfb963..a6853f39 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9002 + 1.0.0.9003 diff --git a/docs/authors.html b/docs/authors.html index 45518727..1e94e3d9 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9002 + 1.0.0.9003 diff --git a/docs/index.html b/docs/index.html index 54443350..cf3f6574 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.0.0.9002 + 1.0.0.9003 diff --git a/docs/news/index.html b/docs/news/index.html index e0ac389c..19ada721 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9002 + 1.0.0.9003 @@ -219,19 +219,18 @@ -
+

-AMR 1.0.0.9002 Unreleased +AMR 1.0.0.9003 Unreleased

-
+

-Last updated: 20-Feb-2020 +Last updated: 21-Feb-2020

Changed

    -
  • Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole

  • Fixed floating point error for some MIC compa in EUCAST 2020 guideline

  • Interpretation from MIC values to R/SI can now be used with mutate_at() of the dplyr package:

    @@ -241,6 +240,7 @@ yourdata %>% mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = .$mybacteria)
+
  • Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole

  • Added uti (as abbreviation of urinary tract infections) as parameter to as.rsi(), so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs

  • @@ -1473,7 +1473,7 @@

    Contents

    @@ -342,6 +342,8 @@ The lifecycle of this function is stableNIT = as.mic(32)) as.rsi(df) +# \donttest{ + # the dplyr way library(dplyr) df %>% @@ -363,6 +365,7 @@ The lifecycle of this function is stabledf %>% mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE) +# } # for single values as.rsi(x = as.mic(2), diff --git a/docs/reference/index.html b/docs/reference/index.html index 19e10a72..1f0f2588 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -78,7 +78,7 @@ AMR (for R) - 1.0.0.9002 + 1.0.0.9003
    diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd index 477e0346..f1c02c0c 100755 --- a/man/as.rsi.Rd +++ b/man/as.rsi.Rd @@ -108,6 +108,8 @@ df <- data.frame(microorganism = "E. coli", NIT = as.mic(32)) as.rsi(df) +\donttest{ + # the dplyr way library(dplyr) df \%>\% @@ -129,7 +131,8 @@ data.frame(mo = "E. coli", df \%>\% mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE) - +} + # for single values as.rsi(x = as.mic(2), mo = as.mo("S. pneumoniae"), diff --git a/tests/testthat/test-rsi.R b/tests/testthat/test-rsi.R index b80858ab..46dd1be8 100644 --- a/tests/testthat/test-rsi.R +++ b/tests/testthat/test-rsi.R @@ -34,6 +34,8 @@ test_that("rsi works", { barplot(as.rsi(c("S", "I", "R"))) plot(as.rsi(c("S", "I", "R"))) 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) @@ -55,9 +57,17 @@ test_that("rsi works", { as.logical() %>% sum(), 40) + + expect_output(tibble(ab = as.rsi("S"))) + + 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")) }) + test_that("mic2rsi works", { skip_on_cran()