diff --git a/DESCRIPTION b/DESCRIPTION index cfe64475..b187c2de 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.5.0.9010 +Version: 1.5.0.9011 Date: 2021-01-24 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 54a68cb2..350e2da6 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.5.0.9010 +# AMR 1.5.0.9011 ## Last updated: 24 January 2021 ### New @@ -38,7 +38,7 @@ ### Other * Big documentation updates -* Loading the package (i.e., `library(AMR)`) now is ~50 times faster than before +* Loading the package (i.e., `library(AMR)`) now is ~50 times faster than before, in costs of package size (increased with ~3 MB) # AMR 1.5.0 diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R index 5cbf3cef..81b2e005 100644 --- a/R/ab_class_selectors.R +++ b/R/ab_class_selectors.R @@ -207,12 +207,12 @@ ab_selector <- function(ab_class, function_name) { } else { agents_formatted <- paste0("column '", font_bold(agents, collapse = NULL), "'") agents_names <- ab_name(names(agents), tolower = TRUE, language = NULL) - need_name <- tolower(agents) != tolower(agents_names) + need_name <- tolower(gsub("[^a-zA-Z]", "", agents)) != tolower(gsub("[^a-zA-Z]", "", agents_names)) agents_formatted[need_name] <- paste0(agents_formatted[need_name], " (", agents_names[need_name], ")") message_("Selecting ", ab_group, ": ", paste(agents_formatted, collapse = ", "), as_note = FALSE, - extra_indent = nchar(paste0("Selecting ", ab_group, ": "))) + extra_indent = 4) } remember_thrown_message(function_name) } diff --git a/R/episode.R b/R/episode.R index 0ffcad34..17a6d707 100644 --- a/R/episode.R +++ b/R/episode.R @@ -29,7 +29,7 @@ #' @inheritSection lifecycle Stable Lifecycle #' @param x vector of dates (class `Date` or `POSIXt`) #' @param episode_days required episode length in days, can also be less than a day, see *Details* -#' @param ... arguments passed on to [as.POSIXct()] +#' @param ... currently not used #' @details #' Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least `episode_days` days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least `episode_days` days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored. #' @@ -106,8 +106,6 @@ get_episode <- function(x, episode_days, ...) { meet_criteria(x, allow_class = c("Date", "POSIXt")) meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE) - stop_if(inherits(x, "Date") & episode_days < 1, - "argument `episode_days` must be at least 1 (day) when `x` is not a date-time object") exec_episode(type = "sequential", x = x, @@ -120,8 +118,6 @@ get_episode <- function(x, episode_days, ...) { is_new_episode <- function(x, episode_days, ...) { meet_criteria(x, allow_class = c("Date", "POSIXt")) meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE) - stop_if(inherits(x, "Date") & episode_days < 1, - "argument `episode_days` must be at least 1 (day) when `x` is not a date-time object") exec_episode(type = "logical", x = x, @@ -130,7 +126,7 @@ is_new_episode <- function(x, episode_days, ...) { } exec_episode <- function(type, x, episode_days, ...) { - x <- as.double(as.POSIXct(x, ...)) # as.POSIXct() for Date classes + x <- as.double(as.POSIXct(x)) # as.POSIXct() for Date classes # since x is now in seconds, get seconds from episode_days as well episode_seconds <- episode_days * 60 * 60 * 24 diff --git a/R/eucast_rules.R b/R/eucast_rules.R index 37c1e1a9..36f2d42f 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -1196,7 +1196,7 @@ eucast_dosage <- function(ab, administration = "iv", version_breakpoints = 11.0) ab <- as.ab(ab) df <- AMR::dosage[which(AMR::dosage$ab %in% ab & AMR::dosage$administration %in% administration), , drop = FALSE] - df <- df[match(ab, df$ab), colnames(df)[colnames(df) != "administration"], drop = FALSE] + df <- df[which(df$ab == ab), colnames(df)[colnames(df) != "administration"], drop = FALSE] rownames(df) <- NULL df$ab <- ab df diff --git a/data-raw/AMR_1.5.0.9010.tar.gz b/data-raw/AMR_1.5.0.9011.tar.gz similarity index 87% rename from data-raw/AMR_1.5.0.9010.tar.gz rename to data-raw/AMR_1.5.0.9011.tar.gz index 7ac8d896..9fb90f62 100644 Binary files a/data-raw/AMR_1.5.0.9010.tar.gz and b/data-raw/AMR_1.5.0.9011.tar.gz differ diff --git a/data-raw/dosage.dta b/data-raw/dosage.dta index 145ffcd8..0bfa0854 100644 Binary files a/data-raw/dosage.dta and b/data-raw/dosage.dta differ diff --git a/data-raw/dosage.md5 b/data-raw/dosage.md5 index 288f31fe..3497f4f3 100644 --- a/data-raw/dosage.md5 +++ b/data-raw/dosage.md5 @@ -1 +1 @@ -42d032c419117561e5c4b5b402e16f01 +58d6a0589aea598420e37045fb04a5ae diff --git a/data-raw/dosage.rds b/data-raw/dosage.rds index a5f4fbfb..f5e0ef0e 100644 Binary files a/data-raw/dosage.rds and b/data-raw/dosage.rds differ diff --git a/data-raw/dosage.sas b/data-raw/dosage.sas index 1c24925c..c5ab2af2 100644 Binary files a/data-raw/dosage.sas and b/data-raw/dosage.sas differ diff --git a/data-raw/dosage.sav b/data-raw/dosage.sav index 9f4c2dcc..0340b74a 100644 Binary files a/data-raw/dosage.sav and b/data-raw/dosage.sav differ diff --git a/data-raw/dosage.txt b/data-raw/dosage.txt index 7802d43d..7f133bbd 100644 --- a/data-raw/dosage.txt +++ b/data-raw/dosage.txt @@ -14,19 +14,20 @@ "AMP" "Ampicillin" "standard_dosage" "2 g" 3 "iv" "" "2 g x 3 iv" 11 "SAM" "Ampicillin/sulbactam" "high_dosage" "2 g + 1 g" 4 "iv" "" "(2 g ampicillin + 1 g sulbactam) x 4 iv" 11 "SAM" "Ampicillin/sulbactam" "standard_dosage" "2 g + 1 g" 3 "iv" "" "(2 g ampicillin + 1 g sulbactam) x 3 iv" 11 -"AZM" "Azithromycin" "standard_dosage" "0.5 g" 1 "oral" "or 0.5 g x 1 iv" "0.5 g x 1 oral or 0.5 g x 1 iv" 11 +"AZM" "Azithromycin" "standard_dosage" "0.5 g" 1 "iv" "" "0.5 g x 1 iv" 11 +"AZM" "Azithromycin" "standard_dosage" "0.5 g" 1 "oral" "" "0.5 g x 1 oral" 11 "ATM" "Aztreonam" "high_dosage" "2 g" 4 "iv" "" "2 g x 4 iv" 11 "ATM" "Aztreonam" "standard_dosage" "1 g" 3 "iv" "" "1 g x 3 iv" 11 "PEN" "Benzylpenicillin" "high_dosage" "1.2 g" 4 "iv" "" "1.2 g (2 MU) x 4-6 iv" 11 "PEN" "Benzylpenicillin" "standard_dosage" "0.6 g" 4 "iv" "" "0.6 g (1 MU) x 4 iv" 11 "CEC" "Cefaclor" "high_dosage" "1 g" 3 "oral" "" "1 g x 3 oral" 11 -"CEC" "Cefaclor" "standard_dosage" "0.25-0.5 g" 3 "oral" "depending on species and/or infection type" "0.25-0.5 g x 3 oral depending on species and/or infection type" 11 +"CEC" "Cefaclor" "standard_dosage" "0.25-0.5 g" 3 "oral" "" "0.25-0.5 g x 3 oral" 11 "CFR" "Cefadroxil" "standard_dosage" "0.5-1 g" 2 "oral" "" "0.5-1 g x 2 oral" 11 "CFR" "Cefadroxil" "uncomplicated_uti" "0.5-1 g" 2 "oral" "" "0.5-1 g x 2 oral" 11 "CZO" "Cefazolin" "high_dosage" "2 g" 3 "iv" "" "2 g x 3 iv" 11 "CZO" "Cefazolin" "standard_dosage" "1 g" 3 "iv" "" "1 g x 3 iv" 11 "FEP" "Cefepime" "high_dosage" "2 g" 3 "iv" "" "2 g x 3 iv" 11 -"FEP" "Cefepime" "standard_dosage" "1 g" 3 "iv" "or 2 g x 2 iv" "1 g x 3 iv or 2 g x 2 iv" 11 +"FEP" "Cefepime" "standard_dosage" "2 g" 2 "iv" "" "2 g x 2 iv" 11 "FDC" "Cefiderocol" "standard_dosage" "2 g" 3 "iv" "over 3 hours" "2 g x 3 iv over 3 hours" 11 "CFM" "Cefixime" "standard_dosage" "0.2-0.4 g" 2 "oral" "" "0.2-0.4 g x 2 oral" 11 "CFM" "Cefixime" "uncomplicated_uti" "0.2-0.4 g" 2 "oral" "" "0.2-0.4 g x 2 oral" 11 @@ -36,14 +37,14 @@ "CPD" "Cefpodoxime" "uncomplicated_uti" "0.1-0.2 g" 2 "oral" "" "0.1-0.2 g x 2 oral" 11 "CPT" "Ceftaroline" "high_dosage" "0.6 g" 3 "iv" "over 2 hours" "0.6 g x 3 iv over 2 hours" 11 "CPT" "Ceftaroline" "standard_dosage" "0.6 g" 2 "iv" "over 1 hour" "0.6 g x 2 iv over 1 hour" 11 -"CAZ" "Ceftazidime" "high_dosage" "2 g" 3 "iv" "or 1 g x 6 iv" "2 g x 3 iv or 1 g x 6 iv" 11 +"CAZ" "Ceftazidime" "high_dosage" "1 g" 6 "iv" "" "1 g x 6 iv" 11 "CAZ" "Ceftazidime" "standard_dosage" "1 g" 3 "iv" "" "1 g x 3 iv" 11 "CZA" "Ceftazidime/avibactam" "standard_dosage" "2 g + 0.5 g" 3 "iv" "over 2 hours" "(2 g ceftazidime + 0.5 g avibactam) x 3 iv over 2 hours" 11 "CTB" "Ceftibuten" "standard_dosage" "0.4 g" 1 "oral" "" "0.4 g x 1 oral" 11 "BPR" "Ceftobiprole" "standard_dosage" "0.5 g" 3 "iv" "over 2 hours" "0.5 g x 3 iv over 2 hours" 11 "CZT" "Ceftolozane/tazobactam" "standard_dosage" "1 g + 0.5 g" 3 "iv" "over 1 hour" "(1 g ceftolozane + 0.5 g tazobactam) x 3 iv over 1 hour" 11 "CZT" "Ceftolozane/tazobactam" "standard_dosage" "2 g + 1 g" 3 "iv" "over 1 hour" "(2 g ceftolozane + 1 g tazobactam) x 3 iv over 1 hour" 11 -"CRO" "Ceftriaxone" "high_dosage" "2 g" 2 "iv" "or 4 g x 1 iv" "2 g x 2 iv or 4 g x 1 iv" 11 +"CRO" "Ceftriaxone" "high_dosage" "4 g" 1 "iv" "" "4 g x 1 iv" 11 "CRO" "Ceftriaxone" "standard_dosage" "2 g" 1 "iv" "" "2 g x 1 iv" 11 "CXM" "Cefuroxime" "high_dosage" "1.5 g" 3 "iv" "" "1.5 g x 3 iv" 11 "CXM" "Cefuroxime" "standard_dosage" "0.75 g" 3 "iv" "" "0.75 g x 3 iv" 11 @@ -52,70 +53,100 @@ "CXM" "Cefuroxime" "uncomplicated_uti" "0.25 g" 2 "oral" "" "0.25 g x 2 oral" 11 "LEX" "Cephalexin" "standard_dosage" "0.25-1 g" 2 "oral" "" "0.25-1 g x 2-3 oral" 11 "LEX" "Cephalexin" "uncomplicated_uti" "0.25-1 g" 2 "oral" "" "0.25-1 g x 2-3 oral" 11 -"CHL" "Chloramphenicol" "high_dosage" "2 g" 4 "oral" "or 2 g x 4 iv" "2 g x 4 oral or 2 g x 4 iv" 11 -"CHL" "Chloramphenicol" "standard_dosage" "1 g" 4 "oral" "or 1 g x 4 iv" "1 g x 4 oral or 1 g x 4 iv" 11 -"CIP" "Ciprofloxacin" "high_dosage" "0.75 g" 2 "oral" "or 0.4 g x 3 iv" "0.75 g x 2 oral or 0.4 g x 3 iv" 11 -"CIP" "Ciprofloxacin" "standard_dosage" "0.5 g" 2 "oral" "or 0.4 g x 2 iv" "0.5 g x 2 oral or 0.4 g x 2 iv" 11 +"CHL" "Chloramphenicol" "high_dosage" "2 g" 4 "iv" "" "2 g x 4 iv" 11 +"CHL" "Chloramphenicol" "standard_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11 +"CHL" "Chloramphenicol" "high_dosage" "2 g" 4 "oral" "" "2 g x 4 oral" 11 +"CHL" "Chloramphenicol" "standard_dosage" "1 g" 4 "oral" "" "1 g x 4 oral" 11 +"CIP" "Ciprofloxacin" "high_dosage" "0.4 g" 3 "iv" "" "0.4 g x 3 iv" 11 +"CIP" "Ciprofloxacin" "standard_dosage" "0.4 g" 2 "iv" "" "0.4 g x 2 iv" 11 +"CIP" "Ciprofloxacin" "high_dosage" "0.75 g" 2 "oral" "" "0.75 g x 2 oral" 11 +"CIP" "Ciprofloxacin" "standard_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11 "CLR" "Clarithromycin" "high_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11 "CLR" "Clarithromycin" "standard_dosage" "0.25 g" 2 "oral" "" "0.25 g x 2 oral" 11 -"CLI" "Clindamycin" "high_dosage" "0.3 g" 4 "oral" "or 0.9 g x 3 iv" "0.3 g x 4 oral or 0.9 g x 3 iv" 11 -"CLI" "Clindamycin" "standard_dosage" "0.3 g" 2 "oral" "or 0.6 g x 3 iv" "0.3 g x 2 oral or 0.6 g x 3 iv" 11 -"CLO" "Cloxacillin" "high_dosage" "1 g" 4 "oral" "or 2 g x 6 iv" "1 g x 4 oral or 2 g x 6 iv" 11 -"CLO" "Cloxacillin" "standard_dosage" "0.5 g" 4 "oral" "or 1 g x 4 iv" "0.5 g x 4 oral or 1 g x 4 iv" 11 +"CLI" "Clindamycin" "high_dosage" "0.9 g" 3 "iv" "" "0.9 g x 3 iv" 11 +"CLI" "Clindamycin" "standard_dosage" "0.6 g" 3 "iv" "" "0.6 g x 3 iv" 11 +"CLI" "Clindamycin" "high_dosage" "0.3 g" 4 "oral" "" "0.3 g x 4 oral" 11 +"CLI" "Clindamycin" "standard_dosage" "0.3 g" 2 "oral" "" "0.3 g x 2 oral" 11 +"CLO" "Cloxacillin" "high_dosage" "2 g" 6 "iv" "" "2 g x 6 iv" 11 +"CLO" "Cloxacillin" "standard_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11 +"CLO" "Cloxacillin" "high_dosage" "1 g" 4 "oral" "" "1 g x 4 oral" 11 +"CLO" "Cloxacillin" "standard_dosage" "0.5 g" 4 "oral" "" "0.5 g x 4 oral" 11 "COL" "Colistin" "standard_dosage" "4.5 MU" 2 "iv" "loading dose of 9 MU" "4.5 MU x 2 iv with a loading dose of 9 MU" 11 "DAL" "Dalbavancin" "standard_dosage" "1 g" 1 "iv" "over 30 minutes on day 8" "1 g x 1 iv over 30 minutes on day 1 If needed, 0.5 g x 1 iv over 30 minutes on day 8" 11 "DAP" "Daptomycin" "standard_dosage" "4 mg/kg" 1 "iv" "" "4 mg/kg x 1 iv" 11 "DAP" "Daptomycin" "standard_dosage" "6 mg/kg" 1 "iv" "" "6 mg/kg x 1 iv" 11 -"DFX" "Delafloxacin" "standard_dosage" "0.45 g" 2 "oral" "or 0.3 g x 2 iv" "0.45 g x 2 oral or 0.3 g x 2 iv" 11 -"DIC" "Dicloxacillin" "high_dosage" "2 g" 4 "oral" "or 2 g x 6 iv" "2 g x 4 oral or 2 g x 6 iv" 11 -"DIC" "Dicloxacillin" "standard_dosage" "0.5-1 g" 4 "oral" "or 1 g x 4 iv" "0.5-1 g x 4 oral or 1 g x 4 iv" 11 +"DFX" "Delafloxacin" "standard_dosage" "0.3 g" 2 "iv" "" "0.3 g x 2 iv" 11 +"DFX" "Delafloxacin" "standard_dosage" "0.45 g" 2 "oral" "" "0.45 g x 2 oral" 11 +"DIC" "Dicloxacillin" "high_dosage" "2 g" 6 "iv" "" "2 g x 6 iv" 11 +"DIC" "Dicloxacillin" "standard_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11 +"DIC" "Dicloxacillin" "high_dosage" "2 g" 4 "oral" "" "2 g x 4 oral" 11 +"DIC" "Dicloxacillin" "standard_dosage" "0.5-1 g" 4 "oral" "" "0.5-1 g x 4 oral" 11 "DOR" "Doripenem" "high_dosage" "1 g" 3 "iv" "over 1 hour" "1 g x 3 iv over 1 hour" 11 "DOR" "Doripenem" "standard_dosage" "0.5 g" 3 "iv" "over 1 hour" "0.5 g x 3 iv over 1 hour" 11 "DOX" "Doxycycline" "high_dosage" "0.2 g" 1 "oral" "" "0.2 g x 1 oral" 11 "DOX" "Doxycycline" "standard_dosage" "0.1 g" 1 "oral" "" "0.1 g x 1 oral" 11 "ERV" "Eravacycline" "standard_dosage" "1 mg/kg" 2 "iv" "" "1 mg/kg x 2 iv" 11 "ETP" "Ertapenem" "standard_dosage" "1 g" 1 "iv" "over 30 minutes" "1 g x 1 iv over 30 minutes" 11 -"ERY" "Erythromycin" "high_dosage" "1 g" 4 "oral" "or 1 g x 4 iv" "1 g x 4 oral or 1 g x 4 iv" 11 -"ERY" "Erythromycin" "standard_dosage" "0.5 g" 2 "oral" "or 0.5 g x 2-4 iv" "0.5 g x 2-4 oral or 0.5 g x 2-4 iv" 11 +"ERY" "Erythromycin" "high_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11 +"ERY" "Erythromycin" "standard_dosage" "0.5 g" 2 "iv" "" "0.5 g x 2-4 iv" 11 +"ERY" "Erythromycin" "high_dosage" "1 g" 4 "oral" "" "1 g x 4 oral" 11 +"ERY" "Erythromycin" "standard_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2-4 oral" 11 "FDX" "Fidaxomicin" "standard_dosage" "0.2 g" 2 "oral" "" "0.2 g x 2 oral" 11 -"FLC" "Flucloxacillin" "high_dosage" "1 g" 4 "oral" "or 2 g x 6 iv" "1 g x 4 oral or 2 g x 6 iv" 11 -"FLC" "Flucloxacillin" "standard_dosage" "1 g" 3 "oral" "or 2 g x 4 iv (or 1 g x 6 iv)" "1 g x 3 oral or 2 g x 4 iv (or 1 g x 6 iv)" 11 +"FLC" "Flucloxacillin" "high_dosage" "2 g" 6 "iv" "" "2 g x 6 iv" 11 +"FLC" "Flucloxacillin" "standard_dosage" "2 g" 4 "iv" "" "2 g x 4 iv (or 1 g x 6 iv)" 11 +"FLC" "Flucloxacillin" "high_dosage" "1 g" 4 "oral" "" "1 g x 4 oral" 11 +"FLC" "Flucloxacillin" "standard_dosage" "1 g" 3 "oral" "" "1 g x 3 oral" 11 "FOS" "Fosfomycin" "high_dosage" "8 g" 3 "iv" "" "8 g x 3 iv" 11 "FOS" "Fosfomycin" "standard_dosage" "4 g" 3 "iv" "" "4 g x 3 iv" 11 -"FUS" "Fusidic acid" "high_dosage" "0.5 g" 3 "oral" "or 0.5 g x 3 iv" "0.5 g x 3 oral or 0.5 g x 3 iv" 11 -"FUS" "Fusidic acid" "standard_dosage" "0.5 g" 2 "oral" "or 0.5 g x 2 iv" "0.5 g x 2 oral or 0.5 g x 2 iv" 11 +"FUS" "Fusidic acid" "high_dosage" "0.5 g" 3 "iv" "" "0.5 g x 3 iv" 11 +"FUS" "Fusidic acid" "standard_dosage" "0.5 g" 2 "iv" "" "0.5 g x 2 iv" 11 +"FUS" "Fusidic acid" "high_dosage" "0.5 g" 3 "oral" "" "0.5 g x 3 oral" 11 +"FUS" "Fusidic acid" "standard_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11 "GEN" "Gentamicin" "standard_dosage" "6-7 mg/kg" 1 "iv" "" "6-7 mg/kg x 1 iv" 11 "IPM" "Imipenem" "high_dosage" "1 g" 4 "iv" "over 30 minutes" "1 g x 4 iv over 30 minutes" 11 "IPM" "Imipenem" "standard_dosage" "0.5 g" 4 "iv" "over 30 minutes" "0.5 g x 4 iv over 30 minutes" 11 "IMR" "Imipenem/relebactam" "standard_dosage" "0.5 g + 0.25 g" 4 "iv" "over 30 minutes" "(0.5 g imipenem + 0.25 g relebactam) x 4 iv over 30 minutes" 11 +"IMR" "Imipenem/relebactam" "standard_dosage" "0.5 g + 0.25 g" 4 "iv" "over 30 minutes" "(0.5 g imipenem + 0.25 g relebactam) x 4 iv over 30 minutes" 11 "LMU" "Lefamulin" "standard_dosage" "0.15 g" 2 "iv" "or 0.6 g x 2 oral" "0.15 g x 2 iv or 0.6 g x 2 oral" 11 -"LVX" "Levofloxacin" "high_dosage" "0.5 g" 2 "oral" "or 0.5 g x 2 iv" "0.5 g x 2 oral or 0.5 g x 2 iv" 11 -"LVX" "Levofloxacin" "standard_dosage" "0.5 g" 1 "oral" "or 0.5 g x 1 iv" "0.5 g x 1 oral or 0.5 g x 1 iv" 11 -"LNZ" "Linezolid" "standard_dosage" "0.6 g" 2 "oral" "or 0.6 g x 2 iv" "0.6 g x 2 oral or 0.6 g x 2 iv" 11 +"LMU" "Lefamulin" "standard_dosage" "0.6 g" 2 "oral" "" "0.6 g x 2 oral" 11 +"LVX" "Levofloxacin" "high_dosage" "0.5 g" 2 "iv" "" "0.5 g x 2 iv" 11 +"LVX" "Levofloxacin" "standard_dosage" "0.5 g" 1 "iv" "" "0.5 g x 1 iv" 11 +"LVX" "Levofloxacin" "high_dosage" "0.5 g" 2 "oral" "" "0.5 g x 2 oral" 11 +"LVX" "Levofloxacin" "standard_dosage" "0.5 g" 1 "oral" "" "0.5 g x 1 oral" 11 +"LNZ" "Linezolid" "standard_dosage" "0.6 g" 2 "iv" "" "0.6 g x 2 iv" 11 +"LNZ" "Linezolid" "standard_dosage" "0.6 g" 2 "oral" "" "0.6 g x 2 oral" 11 "MEM" "Meropenem" "high_dosage" "2 g" 3 "iv" "over 3 hours" "2 g x 3 iv over 3 hours" 11 "MEM" "Meropenem" "standard_dosage" "1 g" 3 "iv" "over 30 minutes" "1 g x 3 iv over 30 minutes" 11 "MEV" "Meropenem/vaborbactam" "standard_dosage" "2 g + 2 g" 3 "iv" "over 3 hours" "(2 g meropenem + 2 g vaborbactam) x 3 iv over 3 hours" 11 -"MTR" "Metronidazole" "high_dosage" "0.5 g" 3 "oral" "or 0.5 g x 3 iv" "0.5 g x 3 oral or 0.5 g x 3 iv" 11 -"MTR" "Metronidazole" "standard_dosage" "0.4 g" 3 "oral" "or 0.4 g x 3 iv" "0.4 g x 3 oral or 0.4 g x 3 iv" 11 +"MTR" "Metronidazole" "high_dosage" "0.5 g" 3 "iv" "" "0.5 g x 3 iv" 11 +"MTR" "Metronidazole" "standard_dosage" "0.4 g" 3 "iv" "" "0.4 g x 3 iv" 11 +"MTR" "Metronidazole" "high_dosage" "0.5 g" 3 "oral" "" "0.5 g x 3 oral" 11 +"MTR" "Metronidazole" "standard_dosage" "0.4 g" 3 "oral" "" "0.4 g x 3 oral" 11 "MNO" "Minocycline" "standard_dosage" "0.1 g" 2 "oral" "" "0.1 g x 2 oral" 11 -"MFX" "Moxifloxacin" "standard_dosage" "0.4 g" 1 "oral" "or 0.4 g x 1 iv" "0.4 g x 1 oral or 0.4 g x 1 iv" 11 -"OFX" "Ofloxacin" "high_dosage" "0.4 g" 2 "oral" "or 0.4 g x 2 iv" "0.4 g x 2 oral or 0.4 g x 2 iv" 11 -"OFX" "Ofloxacin" "standard_dosage" "0.2 g" 2 "oral" "or 0.2 g x 2 iv" "0.2 g x 2 oral or 0.2 g x 2 iv" 11 +"MFX" "Moxifloxacin" "standard_dosage" "0.4 g" 1 "iv" "" "0.4 g x 1 iv" 11 +"MFX" "Moxifloxacin" "standard_dosage" "0.4 g" 1 "oral" "" "0.4 g x 1 oral" 11 +"OFX" "Ofloxacin" "high_dosage" "0.4 g" 2 "iv" "" "0.4 g x 2 iv" 11 +"OFX" "Ofloxacin" "standard_dosage" "0.2 g" 2 "iv" "" "0.2 g x 2 iv" 11 +"OFX" "Ofloxacin" "high_dosage" "0.4 g" 2 "oral" "" "0.4 g x 2 oral" 11 +"OFX" "Ofloxacin" "standard_dosage" "0.2 g" 2 "oral" "" "0.2 g x 2 oral" 11 "ORI" "Oritavancin" "standard_dosage" "1.2 g" 1 "iv" "" "1.2 g x 1 (single dose) iv over 3 hours" 11 "OXA" "Oxacillin" "high_dosage" "1 g" 6 "iv" "" "1 g x 6 iv" 11 "OXA" "Oxacillin" "standard_dosage" "1 g" 4 "iv" "" "1 g x 4 iv" 11 -"PHN" "Phenoxymethylpenicillin" "standard_dosage" "0.5-2 g" 3 "oral" "depending on species and/or infection type" "0.5-2 g x 3-4 oral depending on species and/or infection type" 11 +"PHN" "Phenoxymethylpenicillin" "standard_dosage" "0.5-2 g" 3 "oral" "" "0.5-2 g x 3-4 oral" 11 "PIP" "Piperacillin" "high_dosage" "4 g" 4 "iv" "" "4 g x 4 iv by extended 3-hour infusion" 11 "PIP" "Piperacillin" "standard_dosage" "4 g" 4 "iv" "" "4 g x 4 iv" 11 "TZP" "Piperacillin/tazobactam" "high_dosage" "4 g + 0.5 g" 4 "iv" "" "(4 g piperacillin + 0.5 g tazobactam) x 4 iv by extended 3-hour infusion" 11 "TZP" "Piperacillin/tazobactam" "standard_dosage" "4 g + 0.5 g" 4 "iv" "" "(4 g piperacillin + 0.5 g tazobactam) x 4 iv or x 3 by extended 4-hour infusion" 11 "QDA" "Quinupristin/dalfopristin" "high_dosage" "7.5 mg/kg" 3 "iv" "" "7.5 mg/kg x 3 iv" 11 "QDA" "Quinupristin/dalfopristin" "standard_dosage" "7.5 mg/kg" 2 "iv" "" "7.5 mg/kg x 2 iv" 11 -"RIF" "Rifampicin" "high_dosage" "0.6 g" 2 "oral" "or 0.6 g x 2 iv" "0.6 g x 2 oral or 0.6 g x 2 iv" 11 -"RIF" "Rifampicin" "standard_dosage" "0.6 g" 1 "oral" "or 0.6 g x 1 iv" "0.6 g x 1 oral or 0.6 g x 1 iv" 11 +"RIF" "Rifampicin" "high_dosage" "0.6 g" 2 "iv" "" "0.6 g x 2 iv" 11 +"RIF" "Rifampicin" "standard_dosage" "0.6 g" 1 "iv" "" "0.6 g x 1 iv" 11 +"RIF" "Rifampicin" "high_dosage" "0.6 g" 2 "oral" "" "0.6 g x 2 oral" 11 +"RIF" "Rifampicin" "standard_dosage" "0.6 g" 1 "oral" "" "0.6 g x 1 oral" 11 "RXT" "Roxithromycin" "standard_dosage" "0.15 g" 2 "oral" "" "0.15 g x 2 oral" 11 "SPT" "Spectinomycin" "standard_dosage" "2 g" 1 "im" "" "2 g x 1 im" 11 -"TZD" "Tedizolid" "standard_dosage" "0.2 g" 1 "oral" "or 0.2 g x 1 iv" "0.2 g x 1 oral or 0.2 g x 1 iv" 11 +"TZD" "Tedizolid" "standard_dosage" "0.2 g" 1 "iv" "" "0.2 g x 1 iv" 11 +"TZD" "Tedizolid" "standard_dosage" "0.2 g" 1 "oral" "" "0.2 g x 1 oral" 11 "TEC" "Teicoplanin" "high_dosage" "0.8 g" 1 "iv" "" "0.8 g x 1 iv" 11 "TEC" "Teicoplanin" "standard_dosage" "0.4 g" 1 "iv" "" "0.4 g x 1 iv" 11 "TLV" "Telavancin" "standard_dosage" "10 mg/kg" 1 "iv" "over 1 hour" "10 mg/kg x 1 iv over 1 hour" 11 @@ -130,7 +161,10 @@ "TCC" "Ticarcillin/clavulanic acid" "standard_dosage" "3 g + 0.1-0.2 g" 4 "iv" "" "(3 g ticarcillin + 0.1-0.2 g clavulanic acid) x 4 iv" 11 "TGC" "Tigecycline" "standard_dosage" "0.1 g" "loading dose followed by 50 mg x 2 iv" "0.1 g loading dose followed by 50 mg x 2 iv" 11 "TOB" "Tobramycin" "standard_dosage" "6-7 mg/kg" 1 "iv" "" "6-7 mg/kg x 1 iv" 11 +"SXT" "Trimethoprim/sulfamethoxazole" "high_dosage" "0.24 g + 1.2 g" 2 "oral" "" "(0.24 g trimethoprim + 1.2 g sulfamethoxazole) x 2 oral" 11 "SXT" "Trimethoprim/sulfamethoxazole" "high_dosage" "0.24 g + 1.2 g" 2 "oral" "" "(0.24 g trimethoprim + 1.2 g sulfamethoxazole) x 2 oral or (0.24 g trimethoprim + 1.2 g sulfamethoxazole) x 2 iv" 11 +"SXT" "Trimethoprim/sulfamethoxazole" "standard_dosage" "0.16 g + 0.8 g" 2 "oral" "" "(0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 oral" 11 "SXT" "Trimethoprim/sulfamethoxazole" "standard_dosage" "0.16 g + 0.8 g" 2 "oral" "" "(0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 oral or (0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 iv" 11 "SXT" "Trimethoprim/sulfamethoxazole" "uncomplicated_uti" "0.16 g + 0.8 g" 2 "oral" "" "(0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 oral" 11 -"VAN" "Vancomycin" "standard_dosage" "0.5 g" 4 "iv" "or 1 g x 2 iv or 2 g x 1 by continuous infusion" "0.5 g x 4 iv or 1 g x 2 iv or 2 g x 1 by continuous infusion" 11 +"SXT" "Trimethoprim/sulfamethoxazole" "uncomplicated_uti" "0.16 g + 0.8 g" 2 "oral" "" "(0.16 g trimethoprim + 0.8 g sulfamethoxazole) x 2 oral" 11 +"VAN" "Vancomycin" "standard_dosage" "1 g" 2 "iv" "" "1 g x 2 iv or 2 g x 1 by continuous infusion" 11 diff --git a/data-raw/dosage.xlsx b/data-raw/dosage.xlsx index 9fffe472..d1925f70 100644 Binary files a/data-raw/dosage.xlsx and b/data-raw/dosage.xlsx differ diff --git a/data-raw/reproduction_of_dosage.R b/data-raw/reproduction_of_dosage.R index ae921e47..1b798694 100644 --- a/data-raw/reproduction_of_dosage.R +++ b/data-raw/reproduction_of_dosage.R @@ -44,6 +44,28 @@ dosage_source <- read_excel("data-raw/Dosages_v_11.0_Breakpoint_Tables.xlsx", sk mutate(ab = as.ab(drug), ab_name = ab_name(ab, language = NULL)) +dosage_source <- bind_rows( + # oral + dosage_source %>% + filter(standard_dosage %like% " oral") %>% + mutate(standard_dosage = gsub("oral.*", "oral", standard_dosage), + high_dosage = if_else(high_dosage %like% "oral", + gsub("oral.*", "oral", high_dosage), + NA_character_)), + # iv + dosage_source %>% + filter(standard_dosage %like% " iv") %>% + mutate(standard_dosage = gsub(".* or ", "", standard_dosage), + high_dosage = if_else(high_dosage %like% "( or | iv)", + gsub(".* or ", "", high_dosage), + NA_character_)), + # im + dosage_source %>% + filter(standard_dosage %like% " im") +) %>% + arrange(drug) + + get_dosage_lst <- function(col_data) { standard <- col_data %>% # remove new lines @@ -90,6 +112,7 @@ standard <- get_dosage_lst(dosage_source$standard_dosage) high <- get_dosage_lst(dosage_source$high_dosage) uti <- get_dosage_lst(dosage_source$uncomplicated_uti) dosage <- bind_rows( + # standard dose data.frame( ab = dosage_source$ab, name = dosage_source$ab_name, @@ -101,6 +124,7 @@ dosage <- bind_rows( original_txt = sapply(standard, function(x) x$original_txt), stringsAsFactors = FALSE ), + # high dose data.frame( ab = dosage_source$ab, name = dosage_source$ab_name, @@ -112,6 +136,7 @@ dosage <- bind_rows( original_txt = sapply(high, function(x) x$original_txt), stringsAsFactors = FALSE ), + # UTIs data.frame( ab = dosage_source$ab, name = dosage_source$ab_name, @@ -124,8 +149,11 @@ dosage <- bind_rows( stringsAsFactors = FALSE )) %>% mutate(eucast_version = breakpoints_version, - dose_times = as.integer(dose_times)) %>% + dose_times = as.integer(dose_times), + administration = gsub("([a-z]+) .*", "\\1", administration)) %>% arrange(name, administration, type) %>% - filter(!is.na(dose), dose != ".") + filter(!is.na(dose), dose != ".") %>% + as.data.frame(stringsAsFactors = FALSE) +rownames(dosage) <- NULL usethis::use_data(dosage, internal = FALSE, overwrite = TRUE, version = 2) diff --git a/data/dosage.rda b/data/dosage.rda index a8a94230..9ca04232 100644 Binary files a/data/dosage.rda and b/data/dosage.rda differ diff --git a/docs/404.html b/docs/404.html index 1bef8ad1..b8dc635d 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ library(dplyr) example_isolates %>% - mutate(mo = mo_fullname(mo)) %>% + mutate(bacteria = mo_fullname(mo)) %>% filter(mo_is_gram_negative(), mo_is_intrinsic_resistant(ab = "cefotax")) %>% - select(mo, aminoglycosides(), carbapenems()) + select(bacteria, aminoglycosides(), carbapenems()) #> NOTE: Using column 'mo' as input for mo_is_gram_negative() #> NOTE: Using column 'mo' as input for mo_is_intrinsic_resistant() #> NOTE: Determining intrinsic resistance based on 'EUCAST Expert Rules' and -#> 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.2 from 2020. +#> 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.2 (2020). #> Selecting aminoglycosides: 'AMK' (amikacin), 'GEN' (gentamicin), #> 'KAN' (kanamycin), 'TOB' (tobramycin) #> Selecting carbapenems: 'IPM' (imipenem), 'MEM' (meropenem)
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 8aa018b1..d9e7fab7 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html index 78f77492..2d02f57a 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 53287bd7..9c0477e2 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ diff --git a/docs/index.html b/docs/index.html index e0757438..46274b68 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ @@ -223,20 +223,20 @@ Since you are one of our users, we would like to know how you use the package anWith only having defined a row filter on Gram-negative bacteria with intrinsic resistance to cefotaxime (mo_is_gram_negative()
and mo_is_intrinsic_resistant()
) and a column selection on two antibiotic groups (aminoglycosides()
and carbapenems()
), the reference data about all microorganisms and all antibiotics in the AMR
package make sure you get what you meant:
mo | +bacteria | AMK | GEN | KAN | @@ -256,6 +256,24 @@ Since you are one of our users, we would like to know how you use the package an||
---|---|---|---|---|---|---|
Pseudomonas aeruginosa | ++ | I | +R | +S | +S | ++ |
Pseudomonas aeruginosa | ++ | I | +R | +S | +S | ++ |
Pseudomonas aeruginosa | S | S | R | @@ -299,14 +317,32 @@ Since you are one of our users, we would like to know how you use the package anS | ||
Pseudomonas aeruginosa | +S | +S | +R | +S | ++ | S | +
Pseudomonas aeruginosa | +S | +S | +R | +S | +S | +S | +
A base R equivalent would be:
-example_isolates$mo <- mo_fullname(example_isolates$mo)
+example_isolates$bacteria <- mo_fullname(example_isolates$mo)
example_isolates[which(mo_is_gram_negative() &
mo_is_intrinsic_resistant(ab = "cefotax")),
- c("mo", aminoglycosides(), carbapenems())]
NEWS.md
- library(AMR)
) now is ~50 times faster than beforelibrary(AMR)
) now is ~50 times faster than before, in costs of package size (increased with ~3 MB)Making this package independent of especially the tidyverse (e.g. packages dplyr
and tidyr
) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Good for users, but hard for package maintainers. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.
Negative effects of this change are:
freq()
that was borrowed from the cleaner
package was removed. Use cleaner::freq()
, or run library("cleaner")
before you use freq()
.freq()
that was borrowed from the cleaner
package was removed. Use cleaner::freq()
, or run library("cleaner")
before you use freq()
.mo
or rsi
in a tibble will no longer be in colour and printing rsi
in a tibble will show the class <ord>
, not <rsi>
anymore. This is purely a visual effect.mo_*
family (like mo_name()
and mo_gramstain()
) are noticeably slower when running on hundreds of thousands of rows.mo
and ab
now both also inherit class character
, to support any data transformation. This change invalidates code that checks for class length == 1.This is important, because a value like "testvalue"
could never be understood by e.g. mo_name()
, although the class would suggest a valid microbial code.
Function freq()
has moved to a new package, clean
(CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq()
function still works, since it is re-exported from the clean
package (which will be installed automatically upon updating this AMR
package).
Function freq()
has moved to a new package, clean
(CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq()
function still works, since it is re-exported from the clean
package (which will be installed automatically upon updating this AMR
package).
Renamed data set septic_patients
to example_isolates
age()
function gained a new argument exact
to determine ages with decimalsguess_mo()
, guess_atc()
, EUCAST_rules()
, interpretive_reading()
, rsi()
freq()
):
+freq()
):
speed improvement for microbial IDs
fixed factor level names for R Markdown
age_groups()
, to let groups of fives and tens end with 100+ instead of 120+freq()
for when all values are NA
+freq()
for when all values are NA
first_isolate()
for when dates are missingguess_ab_col()
@@ -1487,7 +1487,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
freq()
function):
+freq()
function):
Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:
@@ -1497,15 +1497,15 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # OLD WAY septic_patients %>% mutate(genus = mo_genus(mo)) %>% - freq(genus) + freq(genus) # NEW WAY septic_patients %>% - freq(mo_genus(mo)) + freq(mo_genus(mo)) # Even supports grouping variables: septic_patients %>% group_by(gender) %>% - freq(mo_genus(mo)) + freq(mo_genus(mo))Header info is now available as a list, with the header
function
The argument header
is now set to TRUE
at default, even for markdown
Using portion_*
functions now throws a warning when total available isolate is below argument minimum
Functions as.mo
, as.rsi
, as.mic
, as.atc
and freq
will not set package name as attribute anymore
Frequency tables - freq()
:
Frequency tables - freq()
:
Support for grouping variables, test with:
@@ -1596,14 +1596,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
septic_patients %>%
group_by(hospital_id) %>%
- freq(gender)
+ freq(gender)
Support for (un)selecting columns:
Check for hms::is.hms
Removed diacritics from all authors (columns microorganisms$ref
and microorganisms.old$ref
) to comply with CRAN policy to only allow ASCII characters
Fix for mo_property
not working properly
Fix for eucast_rules
where some Streptococci would become ceftazidime R in EUCAST rule 4.5
Support for named vectors of class mo
, useful for top_freq()
Support for named vectors of class mo
, useful for top_freq()
ggplot_rsi
and scale_y_percent
have breaks
argument
AI improvements for as.mo
:
For lists, subsetting is possible:
my_list = list(age = septic_patients$age, gender = septic_patients$gender)
-my_list %>% freq(age)
-my_list %>% freq(gender)
rsi
(antimicrobial resistance) to use as inputtable
to use as input: freq(table(x, y))
+table
to use as input: freq(table(x, y))
hist
and plot
to use a frequency table as input: hist(freq(df$age))
as.vector
, as.data.frame
, as_tibble
and format
freq(mydata, mycolumn)
is the same as mydata %>% freq(mycolumn)
+freq(mydata, mycolumn)
is the same as mydata %>% freq(mycolumn)
top_freq
function to return the top/below n items as vectorA data.frame with 135 observations and 9 variables:
A data.frame with 169 observations and 9 variables:
ab
Antibiotic ID as used in this package (such as AMC
), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available
name
Official name of the antimicrobial agent as used by WHONET/EARS-Net or the WHO
type
Type of the dosage, either "high_dosage", "standard_dosage" or "uncomplicated_uti"
length of the required episode length in days, can also be less than a day, see Details
required episode length in days, can also be less than a day, see Details
arguments passed on to as.POSIXct()
currently not used