From d9e66fb118a7927ad644b3a3e37409ec07c487e9 Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Mon, 17 Jun 2024 14:52:18 +0200 Subject: [PATCH] (v2.1.1.9056) example fix --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/sir.R | 12 ++++++------ inst/tinytest/test-custom_microorganisms.R | 11 +++++++---- man/as.sir.Rd | 12 ++++++------ 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e39714dc..033a8b86 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9055 +Version: 2.1.1.9056 Date: 2024-06-17 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 45403b32..ce5b37db 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9055 +# AMR 2.1.1.9056 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)* diff --git a/R/sir.R b/R/sir.R index 168ccff8..fd8a8638 100755 --- a/R/sir.R +++ b/R/sir.R @@ -199,13 +199,13 @@ #' ab = "antibiotic", #' guideline = "CLSI"))) #' df_long %>% -#' # given certain columns, e.g. from AMP to TOB -#' mutate_at(vars(AMP:TOB), as.sir, +#' # given certain columns, e.g. from 'cipro' to 'genta' +#' mutate_at(vars(cipro:genta), as.sir, #' mo = "bacteria", #' ab = "antibiotic", #' guideline = "CLSI") #' df_long %>% -#' mutate(across(AMP:TOB, +#' mutate(across(cipro:genta, #' function(x) as.sir(x, #' mo = "bacteria", #' ab = "antibiotic", @@ -229,13 +229,13 @@ #' guideline = "CLSI"))) #' df_long %>% #' # given certain columns, e.g. from AMP to TOB -#' mutate_at(vars(AMP:TOB), as.sir, +#' mutate_at(vars(cipro:genta), as.sir, #' mo = "bacteria", #' ab = "antibiotic", #' host = "animal_species", #' guideline = "CLSI") #' df_long %>% -#' mutate(across(AMP:TOB, +#' mutate(across(cipro:genta, #' function(x) as.sir(x, #' mo = "bacteria", #' ab = "antibiotic", @@ -254,7 +254,7 @@ #' as.sir() # automatically determines urine isolates #' #' df_wide %>% -#' mutate_at(vars(AMP:TOB), as.sir, mo = "E. coli", uti = TRUE) +#' mutate_at(vars(cipro:genta), as.sir, mo = "E. coli", uti = TRUE) #' } #' #' diff --git a/inst/tinytest/test-custom_microorganisms.R b/inst/tinytest/test-custom_microorganisms.R index f7c45b77..040e3cb9 100644 --- a/inst/tinytest/test-custom_microorganisms.R +++ b/inst/tinytest/test-custom_microorganisms.R @@ -42,7 +42,10 @@ expect_identical(as.character(as.mo("ENT_ASB_CLO")), "ENT_ASB_CLO") expect_identical(mo_name("ENT_ASB_CLO"), "Enterobacter asburiae/cloacae") expect_identical(mo_gramstain("ENT_ASB_CLO", language = NULL), "Gram-negative") -expect_identical(paste("B", AMR:::abbreviate_mo("Klebsiella"), AMR:::abbreviate_mo("pneumoniae", 4), sep = "_"), - as.character(as.mo("Klebsiella pneumoniae"))) -expect_identical(paste("B", AMR:::abbreviate_mo("Aerococcus"), AMR:::abbreviate_mo("urinae", 4), sep = "_"), - as.character(as.mo("Aerococcus urinae"))) +if (getRversion() >= "3.3.0") { + # until R 3.2, abbreviate() used a completely different algorithm, making these tests unreproducible + expect_identical(paste("B", AMR:::abbreviate_mo("Klebsiella"), AMR:::abbreviate_mo("pneumoniae", 4), sep = "_"), + as.character(as.mo("Klebsiella pneumoniae"))) + expect_identical(paste("B", AMR:::abbreviate_mo("Aerococcus"), AMR:::abbreviate_mo("urinae", 4), sep = "_"), + as.character(as.mo("Aerococcus urinae"))) +} diff --git a/man/as.sir.Rd b/man/as.sir.Rd index e72953b7..bd10d5d3 100644 --- a/man/as.sir.Rd +++ b/man/as.sir.Rd @@ -296,13 +296,13 @@ if (require("dplyr")) { ab = "antibiotic", guideline = "CLSI"))) df_long \%>\% - # given certain columns, e.g. from AMP to TOB - mutate_at(vars(AMP:TOB), as.sir, + # given certain columns, e.g. from 'cipro' to 'genta' + mutate_at(vars(cipro:genta), as.sir, mo = "bacteria", ab = "antibiotic", guideline = "CLSI") df_long \%>\% - mutate(across(AMP:TOB, + mutate(across(cipro:genta, function(x) as.sir(x, mo = "bacteria", ab = "antibiotic", @@ -326,13 +326,13 @@ if (require("dplyr")) { guideline = "CLSI"))) df_long \%>\% # given certain columns, e.g. from AMP to TOB - mutate_at(vars(AMP:TOB), as.sir, + mutate_at(vars(cipro:genta), as.sir, mo = "bacteria", ab = "antibiotic", host = "animal_species", guideline = "CLSI") df_long \%>\% - mutate(across(AMP:TOB, + mutate(across(cipro:genta, function(x) as.sir(x, mo = "bacteria", ab = "antibiotic", @@ -351,7 +351,7 @@ if (require("dplyr")) { as.sir() # automatically determines urine isolates df_wide \%>\% - mutate_at(vars(AMP:TOB), as.sir, mo = "E. coli", uti = TRUE) + mutate_at(vars(cipro:genta), as.sir, mo = "E. coli", uti = TRUE) }