1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 16:06:11 +01:00

(v2.1.1.9056) example fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2024-06-17 14:52:18 +02:00
parent 1e65b5a289
commit d9e66fb118
5 changed files with 21 additions and 18 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 2.1.1.9055 Version: 2.1.1.9056
Date: 2024-06-17 Date: 2024-06-17
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)

View File

@ -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).)* *(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).)*

12
R/sir.R
View File

@ -199,13 +199,13 @@
#' ab = "antibiotic", #' ab = "antibiotic",
#' guideline = "CLSI"))) #' guideline = "CLSI")))
#' df_long %>% #' df_long %>%
#' # given certain columns, e.g. from AMP to TOB #' # given certain columns, e.g. from 'cipro' to 'genta'
#' mutate_at(vars(AMP:TOB), as.sir, #' mutate_at(vars(cipro:genta), as.sir,
#' mo = "bacteria", #' mo = "bacteria",
#' ab = "antibiotic", #' ab = "antibiotic",
#' guideline = "CLSI") #' guideline = "CLSI")
#' df_long %>% #' df_long %>%
#' mutate(across(AMP:TOB, #' mutate(across(cipro:genta,
#' function(x) as.sir(x, #' function(x) as.sir(x,
#' mo = "bacteria", #' mo = "bacteria",
#' ab = "antibiotic", #' ab = "antibiotic",
@ -229,13 +229,13 @@
#' guideline = "CLSI"))) #' guideline = "CLSI")))
#' df_long %>% #' df_long %>%
#' # given certain columns, e.g. from AMP to TOB #' # 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", #' mo = "bacteria",
#' ab = "antibiotic", #' ab = "antibiotic",
#' host = "animal_species", #' host = "animal_species",
#' guideline = "CLSI") #' guideline = "CLSI")
#' df_long %>% #' df_long %>%
#' mutate(across(AMP:TOB, #' mutate(across(cipro:genta,
#' function(x) as.sir(x, #' function(x) as.sir(x,
#' mo = "bacteria", #' mo = "bacteria",
#' ab = "antibiotic", #' ab = "antibiotic",
@ -254,7 +254,7 @@
#' as.sir() # automatically determines urine isolates #' as.sir() # automatically determines urine isolates
#' #'
#' df_wide %>% #' 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)
#' } #' }
#' #'
#' #'

View File

@ -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_name("ENT_ASB_CLO"), "Enterobacter asburiae/cloacae")
expect_identical(mo_gramstain("ENT_ASB_CLO", language = NULL), "Gram-negative") 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 = "_"), if (getRversion() >= "3.3.0") {
as.character(as.mo("Klebsiella pneumoniae"))) # until R 3.2, abbreviate() used a completely different algorithm, making these tests unreproducible
expect_identical(paste("B", AMR:::abbreviate_mo("Aerococcus"), AMR:::abbreviate_mo("urinae", 4), sep = "_"), expect_identical(paste("B", AMR:::abbreviate_mo("Klebsiella"), AMR:::abbreviate_mo("pneumoniae", 4), sep = "_"),
as.character(as.mo("Aerococcus urinae"))) 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")))
}

View File

@ -296,13 +296,13 @@ if (require("dplyr")) {
ab = "antibiotic", ab = "antibiotic",
guideline = "CLSI"))) guideline = "CLSI")))
df_long \%>\% df_long \%>\%
# given certain columns, e.g. from AMP to TOB # given certain columns, e.g. from 'cipro' to 'genta'
mutate_at(vars(AMP:TOB), as.sir, mutate_at(vars(cipro:genta), as.sir,
mo = "bacteria", mo = "bacteria",
ab = "antibiotic", ab = "antibiotic",
guideline = "CLSI") guideline = "CLSI")
df_long \%>\% df_long \%>\%
mutate(across(AMP:TOB, mutate(across(cipro:genta,
function(x) as.sir(x, function(x) as.sir(x,
mo = "bacteria", mo = "bacteria",
ab = "antibiotic", ab = "antibiotic",
@ -326,13 +326,13 @@ if (require("dplyr")) {
guideline = "CLSI"))) guideline = "CLSI")))
df_long \%>\% df_long \%>\%
# given certain columns, e.g. from AMP to TOB # 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", mo = "bacteria",
ab = "antibiotic", ab = "antibiotic",
host = "animal_species", host = "animal_species",
guideline = "CLSI") guideline = "CLSI")
df_long \%>\% df_long \%>\%
mutate(across(AMP:TOB, mutate(across(cipro:genta,
function(x) as.sir(x, function(x) as.sir(x,
mo = "bacteria", mo = "bacteria",
ab = "antibiotic", ab = "antibiotic",
@ -351,7 +351,7 @@ if (require("dplyr")) {
as.sir() # automatically determines urine isolates as.sir() # automatically determines urine isolates
df_wide \%>\% 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)
} }