From f720c9ba0b4e7c5cffd21202a5ae16276e27b5c6 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Wed, 21 Oct 2020 15:28:48 +0200 Subject: [PATCH] (v1.4.0.9007) bugfix --- DESCRIPTION | 2 +- NEWS.md | 3 ++- R/first_isolate.R | 14 +++++++------- R/like.R | 18 +++++++++++++++--- 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 | 9 +++++---- docs/pkgdown.yml | 2 +- docs/reference/index.html | 2 +- docs/survey.html | 2 +- 13 files changed, 38 insertions(+), 24 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e80cb630..e54f581e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.4.0.9006 +Version: 1.4.0.9007 Date: 2020-10-21 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 656c7fd2..f9123a95 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,9 @@ -# AMR 1.4.0.9006 +# AMR 1.4.0.9007 ## Last updated: 21 October 2020 ### New * Functions `is_gram_negative()` and `is_gram_positive()` as wrappers around `mo_gramstain()`. They always return `TRUE` or `FALSE`, thus always return `FALSE` for species outside the taxonomic kingdom of Bacteria. +* Functions `%not_like%` and `%like_perl%` as wrappers around `%like%`. ### Changed * For all function parameters in the code, it is now defined what the exact type of user input should be (inspired by the [`typed`](https://github.com/moodymudskipper/typed) package). If the user input for a certain function does not meet the requirements for a specific parameter (such as the class or length), an informative error will be thrown. This makes the package more robust and the use of it more reproducible and reliable. In total, more than 400 arguments were defined. diff --git a/R/first_isolate.R b/R/first_isolate.R index 51e72fdf..77436ead 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -144,8 +144,14 @@ first_isolate <- function(x, meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) meet_criteria(col_testcode, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + if (isFALSE(col_specimen)) { + col_specimen <- NULL + } meet_criteria(col_specimen, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) meet_criteria(col_icu, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + if (isFALSE(col_keyantibiotics)) { + col_keyantibiotics <- NULL + } meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1) meet_criteria(testcodes_exclude, allow_class = "character", allow_NULL = TRUE) @@ -206,17 +212,11 @@ first_isolate <- function(x, if (is.null(col_keyantibiotics)) { col_keyantibiotics <- search_type_in_df(x = x, type = "keyantibiotics") } - if (isFALSE(col_keyantibiotics)) { - col_keyantibiotics <- NULL - } - + # -- specimen if (is.null(col_specimen) & !is.null(specimen_group)) { col_specimen <- search_type_in_df(x = x, type = "specimen") } - if (isFALSE(col_specimen)) { - col_specimen <- NULL - } # check if columns exist check_columns_existance <- function(column, tblname = x) { diff --git a/R/like.R b/R/like.R index 0c981158..d132341e 100755 --- a/R/like.R +++ b/R/like.R @@ -42,6 +42,8 @@ #' * Tries again with `perl = TRUE` if regex fails #' #' Using RStudio? This function can also be inserted from the Addins menu and can have its own Keyboard Shortcut like `Ctrl+Shift+L` or `Cmd+Shift+L` (see `Tools` > `Modify Keyboard Shortcuts...`). +#' +#' The `"%not_like%"` and `"%like_perl%"` functions are wrappers around `"%like%"`. #' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/master/R/like.R) #' @seealso [grep()] #' @inheritSection AMR Read more on our website! @@ -146,10 +148,18 @@ like <- function(x, pattern, ignore.case = TRUE) { #' @export "%like%" <- function(x, pattern) { meet_criteria(x, allow_NA = TRUE) - meet_criteria(pattern, allow_class = "character") + meet_criteria(pattern, allow_NA = FALSE) like(x, pattern, ignore.case = TRUE) } +#' @rdname like +#' @export +"%not_like%" <- function(x, pattern) { + meet_criteria(x, allow_NA = TRUE) + meet_criteria(pattern, allow_NA = FALSE) + !like(x, pattern, ignore.case = TRUE) +} + #' @rdname like #' @export "%like_case%" <- function(x, pattern) { @@ -158,11 +168,13 @@ like <- function(x, pattern, ignore.case = TRUE) { like(x, pattern, ignore.case = FALSE) } -# don't export his one, it's just for convenience in eucast_rules() -# match all Klebsiella and Raoultella, but not K. aerogenes: fullname %like_perl% "^(Klebsiella(?! aerogenes)|Raoultella)" +#' @rdname like +#' @export "%like_perl%" <- function(x, pattern) { meet_criteria(x, allow_NA = TRUE) meet_criteria(pattern, allow_NA = FALSE) + # convenient for e.g. matching all Klebsiella and Raoultella, but not + # K. aerogenes: fullname %like_perl% "^(Klebsiella(?! aerogenes)|Raoultella)" grepl(x = tolower(x), pattern = tolower(pattern), perl = TRUE, diff --git a/docs/404.html b/docs/404.html index 9eceb7f8..fc139ae1 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9006 + 1.4.0.9007 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index e1d99796..a8efcc17 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9006 + 1.4.0.9007 diff --git a/docs/articles/index.html b/docs/articles/index.html index a4e2ebc3..938b71e1 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9006 + 1.4.0.9007 diff --git a/docs/authors.html b/docs/authors.html index 63d3cdfc..5f89f267 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9006 + 1.4.0.9007 diff --git a/docs/index.html b/docs/index.html index 39675e91..6880b98b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.4.0.9006 + 1.4.0.9007 diff --git a/docs/news/index.html b/docs/news/index.html index 47e0185e..520cbd93 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9006 + 1.4.0.9007 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

-AMR 1.4.0.9006 Unreleased +
+

+AMR 1.4.0.9007 Unreleased

@@ -249,6 +249,7 @@ New

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 2fb3c63b..cdcc68f9 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: 2020-10-21T12:39Z +last_built: 2020-10-21T13:25Z 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 df3074ab..9bf4c5c6 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9006 + 1.4.0.9007
diff --git a/docs/survey.html b/docs/survey.html index d7b48558..287f0388 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9006 + 1.4.0.9007