diff --git a/DESCRIPTION b/DESCRIPTION index e3418f58..7dd2cacb 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 c18501a8..6c57494a 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 b0700fda..75e2dceb 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 776d4ea9..c5e259ba 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 c1900173..0c24fa7f 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 3c580d16..529bd5e1 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 529a4caf..5ea53f19 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 221d01ce..918b103e 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 faa7fe33..58c852da 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 24ba37ab..e8ae0140 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 06c1c5a8..8701bc7b 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 33908d00..67cd6603 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 158bd444..c0324c7a 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 1e3109fb..ecb9af18 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 910424fc..3c6ed518 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 68f139dc..eaa32821 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 ad04a5e4..c5957740 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 b16aa247..dbba859b 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 03f45ada..1b4180c6 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 4f7bc5dc..0e0f4ddc 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 991e1fa5..54d05698 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 90b895ba..0e4463a9 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 afe20d7d..2af770de 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 2b01fec7..108d707f 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 56f71cc9..27d39ccf 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 f7808452..28d207ea 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 5f1a0549..678dc526 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 1287c7c6..942ccef7 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 e167677e..cde6600d 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 8ded3898..445d9b12 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 e5db534d..2708d2b1 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 85eef5eb..e31429fd 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 f1acb44a..52768e23 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 0de1f7b5..89777774 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 a975d9d8..853de104 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 2606a95f..6114c652 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 a1bf3735..671ba9e7 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")