diff --git a/DESCRIPTION b/DESCRIPTION index 505b2a7a..1095c44e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.0.0.9000 +Version: 1.0.0.9001 Date: 2020-02-20 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index c6353a4b..f6e4f198 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.0.0.9000 -## Last updated: 20-Feb-2020 +# AMR 1.0.0.9001 + ### Changed * Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole diff --git a/R/rsi.R b/R/rsi.R index de7aa18b..e875069a 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -87,10 +87,8 @@ #' as.rsi() # automatically determines urine isolates #' #' df %>% -#' mutate_at(vars(AMP:TOB), as.rsi, mo = "E. coli", uti = TRUE) +#' 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"), @@ -139,18 +137,25 @@ as.rsi.default <- function(x, ...) { x } else if (identical(levels(x), c("S", "I", "R"))) { structure(x, class = c("rsi", "ordered", "factor")) - } else if (all_valid_mics(x) & !all(is.na(x))) { - as.rsi(as.mic(x), ab = deparse(substitute(x)), ...) - } else if (all_valid_disks(x) & !all(is.na(x))) { - #message("These values seem to be disk diffusion diameters and were treated as such.") - as.rsi(as.disk(x), ab = deparse(substitute(x)), ...) - } else if (identical(class(x), "integer") & all(x %in% c(1:3, NA))) { + } else if (inherits(x, "integer") & all(x %in% c(1:3, NA))) { x[x == 1] <- "S" x[x == 2] <- "I" x[x == 3] <- "R" structure(.Data = factor(x, levels = c("S", "I", "R"), ordered = TRUE), class = c("rsi", "ordered", "factor")) } else { + + ab <- deparse(substitute(x)) + if (!any(x %like% "(R|S|I)", na.rm = TRUE)) { + if (!is.na(suppressWarnings(as.ab(ab)))) { + # check if they are actually MICs or disks now that the antibiotic name is valid + if (all_valid_mics(x)) { + as.rsi(as.mic(x), ab = ab, ...) + } else if (all_valid_disks(x)) { + as.rsi(as.disk(x), ab = ab, ...) + } + } + } x <- x %>% unlist() x.bak <- x @@ -632,9 +637,9 @@ plot.rsi <- function(x, #' @importFrom graphics barplot axis par #' @noRd barplot.rsi <- function(height, - col = c("green3", "orange2", "red3"), + col = c("chartreuse4", "chartreuse3", "brown3"), xlab = ifelse(beside, "Antimicrobial Interpretation", ""), - main = paste("Susceptibility Analysis of", deparse(substitute(height))), + main = paste("Antimicrobial resistance of", deparse(substitute(height))), ylab = "Frequency", beside = TRUE, axes = beside, diff --git a/docs/404.html b/docs/404.html index a0d0864d..34c00121 100644 --- a/docs/404.html +++ b/docs/404.html @@ -78,7 +78,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 7077d1de..be4400d5 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html index 68e7c8ae..33d525f9 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ diff --git a/docs/authors.html b/docs/authors.html index de79af16..65c54bec 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ diff --git a/docs/index.html b/docs/index.html index 7fef5906..6f437a44 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ diff --git a/docs/news/index.html b/docs/news/index.html index 98bdf037..9680a3be 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -78,7 +78,7 @@ @@ -219,14 +219,10 @@ -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