From f7dd890b79d765ec68b921c36ae9ad2c51952f67 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Mon, 6 Feb 2023 12:38:52 +0100 Subject: [PATCH] fixes --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/aa_globals.R | 14 ++++++++++---- R/ab_property.R | 2 +- R/antibiogram.R | 14 +++++++++----- man/antibiogram.Rd | 4 ++++ 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6fe7c1ea..0a30c9b8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.8.2.9106 +Version: 1.8.2.9107 Date: 2023-02-06 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index d66e8e7e..acc5b44b 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9106 +# AMR 1.8.2.9107 *(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)* diff --git a/R/aa_globals.R b/R/aa_globals.R index e87f094f..ee47c959 100755 --- a/R/aa_globals.R +++ b/R/aa_globals.R @@ -94,7 +94,9 @@ TAXONOMY_VERSION <- list( ) globalVariables(c( + ".mo", ".rowid", + ".syndromic_group", "ab", "ab_txt", "affect_ab_name", @@ -105,8 +107,9 @@ globalVariables(c( "atc_group1", "atc_group2", "base_ab", - "ci_min", "ci_max", + "ci_min", + "clinical_breakpoints", "code", "cols", "count", @@ -130,14 +133,15 @@ globalVariables(c( "language", "lookup", "method", - "mic", "mic ", + "mic", "microorganism", "microorganisms", "microorganisms.codes", "mo", "name", "new", + "numerator", "observations", "old", "old_name", @@ -149,13 +153,15 @@ globalVariables(c( "reference.rule_group", "reference.version", "rowid", - "sir", - "clinical_breakpoints", "rule_group", "rule_name", + "S", "se_max", "se_min", + "SI", + "sir", "species", + "syndromic_group", "total", "txt", "type", diff --git a/R/ab_property.R b/R/ab_property.R index 52eb469e..16e9784d 100755 --- a/R/ab_property.R +++ b/R/ab_property.R @@ -363,7 +363,7 @@ set_ab_names <- function(data, ..., property = "name", language = get_AMR_locale if (is.data.frame(data)) { if (tryCatch(length(list(...)) > 0, error = function(e) TRUE)) { - out <- tryCatch(suppressWarnings(c(...)), error = function(e) NULL) + out <- tryCatch(suppressWarnings(unlist(list(...))), error = function(e) NULL) if (!is.null(out)) { df <- data[, out, drop = FALSE] } else { diff --git a/R/antibiogram.R b/R/antibiogram.R index dbec5b7d..4aa951a0 100755 --- a/R/antibiogram.R +++ b/R/antibiogram.R @@ -43,6 +43,8 @@ #' @param minimum the minimum allowed number of available (tested) isolates. Any isolate count lower than `minimum` will return `NA` with a warning. The default number of `30` isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see *Source*. #' @param combine_SI a [logical] to indicate whether all susceptibility should be determined by results of either S or I, instead of only S (defaults to `TRUE`) #' @param sep a separating character for antibiotic columns in combination antibiograms +#' @param object an [antibiogram()] object +#' @param ... method extensions #' @details This function returns a table with values between 0 and 100 for *susceptibility*, not resistance. #' #' **Remember that you should filter your data to let it contain only first isolates!** This is needed to exclude duplicates and to reduce selection bias. Use [first_isolate()] to determine them in your data set with one of the four available algorithms. @@ -314,7 +316,7 @@ antibiogram <- function(x, if (identical(select, import_fn("select", "dplyr", error_on_fail = FALSE))) { antibiotics <- suppressWarnings(x %>% select({{ antibiotics }}) %>% colnames()) } else { - antibiotics <- x %>% select(antibiotics) %>% colnames() + antibiotics <- colnames(x[, antibiotics, drop = FALSE]) } } @@ -447,9 +449,9 @@ plot.antibiogram <- function(x, ...) { df <- df[order(df$mo), , drop = FALSE] } mo_levels = unique(df$mo) - mfrow_old <- par()$mfrow + mfrow_old <- graphics::par()$mfrow sqrt_levels <- sqrt(length(mo_levels)) - par(mfrow = c(ceiling(sqrt_levels), floor(sqrt_levels))) + graphics::par(mfrow = c(ceiling(sqrt_levels), floor(sqrt_levels))) for (i in seq_along(mo_levels)) { mo <- mo_levels[i] df_sub <- df[df$mo == mo, , drop = FALSE] @@ -463,12 +465,14 @@ plot.antibiogram <- function(x, ...) { main = mo, legend = NULL) } - par(mfrow = mfrow_old) + graphics::par(mfrow = mfrow_old) } #' @export #' @noRd -barplot.antibiogram <- plot.antibiogram +barplot.antibiogram <- function(height, ...) { + plot(height, ...) +} #' @method autoplot antibiogram #' @rdname antibiogram diff --git a/man/antibiogram.Rd b/man/antibiogram.Rd index efaabee3..36f122e9 100644 --- a/man/antibiogram.Rd +++ b/man/antibiogram.Rd @@ -63,6 +63,10 @@ antibiogram( \item{sep}{a separating character for antibiotic columns in combination antibiograms} +\item{...}{method extensions} + +\item{object}{an \code{\link[=antibiogram]{antibiogram()}} object} + \item{as_kable}{a \link{logical} to indicate whether the printing should be done using \code{\link[knitr:kable]{knitr::kable()}} (which is the default in non-interactive sessions)} } \description{