From 461793dc34501ffe51962d41b830eafe61a94c57 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Mon, 8 Mar 2021 01:24:37 +0100 Subject: [PATCH] (v1.5.0.9038) quick test --- DESCRIPTION | 2 +- R/ab.R | 34 +++++++++++++++++----------------- R/rsi.R | 23 +++++++---------------- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6688e9fd..bd1d00d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.5.0.9037 +Version: 1.5.0.9038 Date: 2021-03-07 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/R/ab.R b/R/ab.R index 2379b41c..57271ee7 100755 --- a/R/ab.R +++ b/R/ab.R @@ -109,23 +109,23 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) { x <- toupper(x) x_nonNA <- x[!is.na(x)] - if (all(x_nonNA %in% antibiotics$ab, na.rm = TRUE)) { - # all valid AB codes, but not yet right class - return(set_clean_class(x, - new_class = c("ab", "character"))) - } - if (all(x_nonNA %in% toupper(antibiotics$name), na.rm = TRUE)) { - # all valid AB names - out <- antibiotics$ab[match(x, toupper(antibiotics$name))] - out[is.na(x)] <- NA_character_ - return(out) - } - if (all(x_nonNA %in% antibiotics$atc, na.rm = TRUE)) { - # all valid ATC codes - out <- antibiotics$ab[match(x, antibiotics$atc)] - out[is.na(x)] <- NA_character_ - return(out) - } + # if (all(x_nonNA %in% antibiotics$ab, na.rm = TRUE)) { + # # all valid AB codes, but not yet right class + # return(set_clean_class(x, + # new_class = c("ab", "character"))) + # } + # if (all(x_nonNA %in% toupper(antibiotics$name), na.rm = TRUE)) { + # # all valid AB names + # out <- antibiotics$ab[match(x, toupper(antibiotics$name))] + # out[is.na(x)] <- NA_character_ + # return(out) + # } + # if (all(x_nonNA %in% antibiotics$atc, na.rm = TRUE)) { + # # all valid ATC codes + # out <- antibiotics$ab[match(x, antibiotics$atc)] + # out[is.na(x)] <- NA_character_ + # return(out) + # } # remove diacritics x <- iconv(x, from = "UTF-8", to = "ASCII//TRANSLIT") diff --git a/R/rsi.R b/R/rsi.R index d341f319..8a17ea28 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -337,6 +337,8 @@ as.rsi.mic <- function(x, meet_criteria(reference_data, allow_class = "data.frame") check_reference_data(reference_data) + pkg_env$strange <- list(before = ab) + # for dplyr's across() cur_column_dplyr <- import_fn("cur_column", "dplyr", error_on_fail = FALSE) if (!is.null(cur_column_dplyr)) { @@ -345,6 +347,8 @@ as.rsi.mic <- function(x, error = function(e) ab) } + pkg_env$strange$afteracross <- ab + # for auto-determining mo mo_var_found <- "" if (is.null(mo)) { @@ -369,6 +373,7 @@ as.rsi.mic <- function(x, } ab_coerced <- suppressWarnings(as.ab(ab)) + pkg_env$strange$coerced <- ab_coerced mo_coerced <- suppressWarnings(as.mo(mo)) guideline_coerced <- get_guideline(guideline, reference_data) if (is.na(ab_coerced)) { @@ -704,6 +709,8 @@ exec_as.rsi <- function(method, conserve_capped_values, add_intrinsic_resistance, reference_data) { + pkg_env$strange$exec <- ab + pkg_env$strange$names <- names(pkg_env$strange) metadata_mo <- get_mo_failures_uncertainties_renamed() @@ -812,22 +819,6 @@ exec_as.rsi <- function(method, get_record <- get_record[1L, , drop = FALSE] if (NROW(get_record) > 0) { - pkg_env$strange <- list(x_dbl = as.double(x[i]), - x_chr = as.character(x[i]), - get_record = get_record, - guideline_coerced = guideline_coerced, - lookup = c(lookup_mo[i], - lookup_genus[i], - lookup_family[i], - lookup_order[i], - lookup_becker[i], - lookup_lancefield[i], - lookup_other[i]), - is_intrinsic_r = is_intrinsic_r, - c1 = x[i] <= get_record$breakpoint_S, - c2 = guideline_coerced %like% "EUCAST" & x[i] > get_record$breakpoint_R, - c2 = guideline_coerced %like% "CLSI" & x[i] >= get_record$breakpoint_R) - if (is.na(x[i]) | (is.na(get_record$breakpoint_S) & is.na(get_record$breakpoint_R))) { new_rsi[i] <- NA_character_ } else if (method == "mic") {