diff --git a/DESCRIPTION b/DESCRIPTION index e3418f585..7dd2cacb4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.3.0.9016 +Version: 1.3.0.9017 Date: 2020-09-12 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index c18501a80..6c57494a8 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.3.0.9016 +# AMR 1.3.0.9017 ## Last updated: 12 September 2020 Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly! diff --git a/R/mo.R b/R/mo.R index b0700fda3..75e2dceb9 100755 --- a/R/mo.R +++ b/R/mo.R @@ -281,6 +281,43 @@ exec_as.mo <- function(x, reference_data_to_use = MO_lookup) { check_dataset_integrity() + + lookup <- function(needle, column = property, haystack = reference_data_to_use, n = 1, debug_mode = debug, input = "") { + # `column` can be NULL for all columns, or a selection + # returns a character (vector) - if `column` > length 1 then with columns as names + if (isTRUE(debug_mode)) { + cat(font_silver("looking up: ", substitute(needle), "\n", collapse = "")) + } + if (length(column) == 1) { + res_df <- haystack[which(eval(substitute(needle), envir = haystack, enclos = parent.frame())), , drop = FALSE] + res <- as.character(res_df[, column, drop = TRUE]) + if (length(res) == 0) { + NA_character_ + } else { + if (length(res) > n) { + # save the other possible results as well + uncertainties <<- rbind(uncertainties, + format_uncertainty_as_df(uncertainty_level = 1, + input = x_backup[i], + result_mo = res_df[1, "mo", drop = TRUE], + candidates = as.character(res_df[, "fullname", drop = TRUE]))) + } + res[seq_len(min(n, length(res)))] + } + } else { + if (is.null(column)) { + column <- names(haystack) + } + res <- haystack[which(eval(substitute(needle), envir = haystack, enclos = parent.frame())), , drop = FALSE] + res <- res[seq_len(min(n, nrow(res))), column, drop = TRUE] + if (NROW(res) == 0) { + res <- rep(NA_character_, length(column)) + } + res <- as.character(res) + names(res) <- column + res + } + } # start off with replaced language-specific non-ASCII characters with ASCII characters x <- parse_and_convert(x) @@ -383,43 +420,6 @@ exec_as.mo <- function(x, } else if (!all(x %in% microorganisms[, property])) { - lookup <- function(needle, column = property, haystack = reference_data_to_use, n = 1, debug_mode = debug, input = "") { - # `column` can be NULL for all columns, or a selection - # returns a character (vector) - if `column` > length 1 then with columns as names - if (isTRUE(debug_mode)) { - cat(font_silver("looking up: ", substitute(needle), "\n", collapse = "")) - } - if (length(column) == 1) { - res_df <- haystack[which(eval(substitute(needle), envir = haystack, enclos = parent.frame())), , drop = FALSE] - res <- as.character(res_df[, column, drop = TRUE]) - if (length(res) == 0) { - NA_character_ - } else { - if (length(res) > n) { - # save the other possible results as well - uncertainties <<- rbind(uncertainties, - format_uncertainty_as_df(uncertainty_level = 1, - input = x_backup[i], - result_mo = res_df[1, "mo", drop = TRUE], - candidates = as.character(res_df[, "fullname", drop = TRUE]))) - } - res[seq_len(min(n, length(res)))] - } - } else { - if (is.null(column)) { - column <- names(haystack) - } - res <- haystack[which(eval(substitute(needle), envir = haystack, enclos = parent.frame())), , drop = FALSE] - res <- res[seq_len(min(n, nrow(res))), column, drop = TRUE] - if (NROW(res) == 0) { - res <- rep(NA_character_, length(column)) - } - res <- as.character(res) - names(res) <- column - res - } - } - strip_whitespace <- function(x, dyslexia_mode) { # all whitespaces (tab, new lines, etc.) should be one space # and spaces before and after should be omitted diff --git a/data-raw/antibiotics.dta b/data-raw/antibiotics.dta index 776d4ea9c..c5e259bac 100644 Binary files a/data-raw/antibiotics.dta and b/data-raw/antibiotics.dta differ diff --git a/data-raw/antibiotics.sas b/data-raw/antibiotics.sas index c1900173d..0c24fa7f0 100644 Binary files a/data-raw/antibiotics.sas and b/data-raw/antibiotics.sas differ diff --git a/data-raw/antibiotics.sav b/data-raw/antibiotics.sav index 3c580d16c..529bd5e1b 100644 Binary files a/data-raw/antibiotics.sav and b/data-raw/antibiotics.sav differ diff --git a/data-raw/antibiotics.xlsx b/data-raw/antibiotics.xlsx index 529a4caf5..5ea53f199 100644 Binary files a/data-raw/antibiotics.xlsx and b/data-raw/antibiotics.xlsx differ diff --git a/data-raw/antivirals.dta b/data-raw/antivirals.dta index 221d01cea..918b103ef 100644 Binary files a/data-raw/antivirals.dta and b/data-raw/antivirals.dta differ diff --git a/data-raw/antivirals.sas b/data-raw/antivirals.sas index faa7fe333..58c852da7 100644 Binary files a/data-raw/antivirals.sas and b/data-raw/antivirals.sas differ diff --git a/data-raw/antivirals.sav b/data-raw/antivirals.sav index 24ba37abe..e8ae0140e 100644 Binary files a/data-raw/antivirals.sav and b/data-raw/antivirals.sav differ diff --git a/data-raw/antivirals.xlsx b/data-raw/antivirals.xlsx index 06c1c5a83..8701bc7bf 100644 Binary files a/data-raw/antivirals.xlsx and b/data-raw/antivirals.xlsx differ diff --git a/data-raw/intrinsic_resistant.dta b/data-raw/intrinsic_resistant.dta index 33908d000..67cd66036 100644 Binary files a/data-raw/intrinsic_resistant.dta and b/data-raw/intrinsic_resistant.dta differ diff --git a/data-raw/intrinsic_resistant.sas b/data-raw/intrinsic_resistant.sas index 158bd444d..c0324c7a9 100644 Binary files a/data-raw/intrinsic_resistant.sas and b/data-raw/intrinsic_resistant.sas differ diff --git a/data-raw/intrinsic_resistant.sav b/data-raw/intrinsic_resistant.sav index 1e3109fb6..ecb9af18c 100644 Binary files a/data-raw/intrinsic_resistant.sav and b/data-raw/intrinsic_resistant.sav differ diff --git a/data-raw/intrinsic_resistant.xlsx b/data-raw/intrinsic_resistant.xlsx index 910424fc5..3c6ed5189 100644 Binary files a/data-raw/intrinsic_resistant.xlsx and b/data-raw/intrinsic_resistant.xlsx differ diff --git a/data-raw/microorganisms.dta b/data-raw/microorganisms.dta index 68f139dcc..eaa32821d 100644 Binary files a/data-raw/microorganisms.dta and b/data-raw/microorganisms.dta differ diff --git a/data-raw/microorganisms.old.dta b/data-raw/microorganisms.old.dta index ad04a5e44..c59577407 100644 Binary files a/data-raw/microorganisms.old.dta and b/data-raw/microorganisms.old.dta differ diff --git a/data-raw/microorganisms.old.sas b/data-raw/microorganisms.old.sas index b16aa247d..dbba859b9 100644 Binary files a/data-raw/microorganisms.old.sas and b/data-raw/microorganisms.old.sas differ diff --git a/data-raw/microorganisms.old.sav b/data-raw/microorganisms.old.sav index 03f45adab..1b4180c68 100644 Binary files a/data-raw/microorganisms.old.sav and b/data-raw/microorganisms.old.sav differ diff --git a/data-raw/microorganisms.old.xlsx b/data-raw/microorganisms.old.xlsx index 4f7bc5dc0..0e0f4ddc8 100644 Binary files a/data-raw/microorganisms.old.xlsx and b/data-raw/microorganisms.old.xlsx differ diff --git a/data-raw/microorganisms.sas b/data-raw/microorganisms.sas index 991e1fa53..54d05698c 100644 Binary files a/data-raw/microorganisms.sas and b/data-raw/microorganisms.sas differ diff --git a/data-raw/microorganisms.sav b/data-raw/microorganisms.sav index 90b895ba5..0e4463a98 100644 Binary files a/data-raw/microorganisms.sav and b/data-raw/microorganisms.sav differ diff --git a/data-raw/microorganisms.xlsx b/data-raw/microorganisms.xlsx index afe20d7df..2af770de4 100644 Binary files a/data-raw/microorganisms.xlsx and b/data-raw/microorganisms.xlsx differ diff --git a/data-raw/rsi_translation.dta b/data-raw/rsi_translation.dta index 2b01fec7d..108d707f9 100644 Binary files a/data-raw/rsi_translation.dta and b/data-raw/rsi_translation.dta differ diff --git a/data-raw/rsi_translation.sas b/data-raw/rsi_translation.sas index 56f71cc99..27d39ccfe 100644 Binary files a/data-raw/rsi_translation.sas and b/data-raw/rsi_translation.sas differ diff --git a/data-raw/rsi_translation.sav b/data-raw/rsi_translation.sav index f7808452d..28d207ea4 100644 Binary files a/data-raw/rsi_translation.sav and b/data-raw/rsi_translation.sav differ diff --git a/data-raw/rsi_translation.xlsx b/data-raw/rsi_translation.xlsx index 5f1a05490..678dc5266 100644 Binary files a/data-raw/rsi_translation.xlsx and b/data-raw/rsi_translation.xlsx differ diff --git a/docs/404.html b/docs/404.html index 1287c7c6d..942ccef7f 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9016 + 1.3.0.9017 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index e167677ea..cde6600dd 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9016 + 1.3.0.9017 diff --git a/docs/articles/index.html b/docs/articles/index.html index 8ded38986..445d9b12b 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9016 + 1.3.0.9017 diff --git a/docs/authors.html b/docs/authors.html index e5db534d0..2708d2b1f 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9016 + 1.3.0.9017 diff --git a/docs/index.html b/docs/index.html index 85eef5eb0..e31429fdc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.3.0.9016 + 1.3.0.9017 diff --git a/docs/news/index.html b/docs/news/index.html index f1acb44a3..52768e232 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9016 + 1.3.0.9017 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

-AMR 1.3.0.9016 Unreleased +
+

+AMR 1.3.0.9017 Unreleased

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 0de1f7b5d..897777749 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 2.7.3 pkgdown: 1.5.1.9000 pkgdown_sha: eae56f08694abebf93cdfc0dd8e9ede06d8c815f articles: [] -last_built: 2020-09-12T06:48Z +last_built: 2020-09-12T11:54Z 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 a975d9d8c..853de104c 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9016 + 1.3.0.9017

diff --git a/docs/survey.html b/docs/survey.html index 2606a95f3..6114c652e 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.3.0.9016 + 1.3.0.9017
diff --git a/tests/testthat.R b/tests/testthat.R index a1bf37359..671ba9e79 100755 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -23,3 +23,4 @@ library(testthat) library(AMR) test_check("AMR") +unlink("tests/testthat/Rplots.pdf")