From ba51c2d92f48df6b4d1a8a1f9c7b900c85f7c8c5 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Mon, 28 Nov 2022 19:39:52 +0100 Subject: [PATCH] add column to `as.mic()` and `as.disk()` warnings --- DESCRIPTION | 4 ++-- NEWS.md | 3 ++- R/disk.R | 14 +++++++++----- R/mic.R | 14 +++++++++----- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0e307b06..4427ae5b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.8.2.9053 -Date: 2022-11-24 +Version: 1.8.2.9054 +Date: 2022-11-28 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by diff --git a/NEWS.md b/NEWS.md index 6b5f8e3a..8802878b 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9053 +# AMR 1.8.2.9054 This version will eventually become v2.0! We're happy to reach a new major milestone soon! @@ -69,6 +69,7 @@ This version will eventually become v2.0! We're happy to reach a new major miles * Updated support for all WHONET 2022 microorganism codes * Antimicrobial interpretation 'SDD' (susceptible dose-dependent, coined by CLSI) will be interpreted as 'I' to comply with EUCAST's 'I' in `as.rsi()` * Fix for `mo_shortname()` in case of higher taxonomic ranks (order, class, phylum) +* Cleaning columns with `as.rsi()`, `as.mic()`, or `as.disk()` will now show the column name in the warning for invalid results ### Other * New website to make use of the new Bootstrap 5 and pkgdown 2.0. The website now contains results for all examples and will be automatically regenerated with every change to our repository, using GitHub Actions diff --git a/R/disk.R b/R/disk.R index 91bc19c4..defc28dc 100644 --- a/R/disk.R +++ b/R/disk.R @@ -118,11 +118,15 @@ as.disk <- function(x, na.rm = FALSE) { unique() %pm>% sort() %pm>% vector_and(quotes = TRUE) - warning_( - "in `as.disk()`: ", na_after - na_before, " results truncated (", - round(((na_after - na_before) / length(x)) * 100), - "%) that were invalid disk zones: ", - list_missing + cur_col <- get_current_column() + warning_("in `as.disk()`: ", na_after - na_before, " result", + ifelse(na_after - na_before > 1, "s", ""), + ifelse(is.null(cur_col), "", paste0(" in column '", cur_col, "'")), + " truncated (", + round(((na_after - na_before) / length(x)) * 100), + "%) that were invalid disk zones: ", + list_missing, + call = FALSE ) } } diff --git a/R/mic.R b/R/mic.R index 04f6577d..e282eb8a 100755 --- a/R/mic.R +++ b/R/mic.R @@ -228,11 +228,15 @@ as.mic <- function(x, na.rm = FALSE) { unique() %pm>% sort() %pm>% vector_and(quotes = TRUE) - warning_("in `as.mic()`: ", na_after - na_before, " results truncated (", - round(((na_after - na_before) / length(x)) * 100), - "%) that were invalid MICs: ", - list_missing, - call = FALSE + cur_col <- get_current_column() + warning_("in `as.mic()`: ", na_after - na_before, " result", + ifelse(na_after - na_before > 1, "s", ""), + ifelse(is.null(cur_col), "", paste0(" in column '", cur_col, "'")), + " truncated (", + round(((na_after - na_before) / length(x)) * 100), + "%) that were invalid MICs: ", + list_missing, + call = FALSE ) }