1
0
mirror of https://github.com/msberends/AMR.git synced 2026-06-29 12:16:17 +02:00

(v3.0.1.9062) Fix older R versions

This commit is contained in:
2026-06-24 10:19:15 +02:00
parent 0c1709c999
commit ab38fb911d
6 changed files with 26 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
Package: AMR
Version: 3.0.1.9061
Date: 2026-06-23
Version: 3.0.1.9062
Date: 2026-06-24
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

View File

@@ -1,4 +1,4 @@
# AMR 3.0.1.9061
# AMR 3.0.1.9062
Planned as v3.1.0, end of June 2026.

View File

@@ -708,7 +708,7 @@ stop_ifnot <- function(expr, ..., call = TRUE) {
}
}
"%or%" <- function(x, y) {
"%or_if_na%" <- function(x, y) {
if (is.null(x) || is.null(y)) {
if (is.null(x)) {
return(y)
@@ -1846,4 +1846,10 @@ if (getRversion() < "4.0.0") {
}
}
if (getRversion() < "4.4.0") {
`%||%` <- function(x, y) {
if (is.null(x)) y else x
}
}
# nolint end

View File

@@ -1511,8 +1511,8 @@ mdro <- function(x = NULL,
fluoroquinolones <- c(CIP, NOR, LVX) # note 5: ciprofloxacin or norfloxacin or levofloxacin
carbapenems <- carbapenems[!is.na(carbapenems)]
carbapenems_without_imipenem <- carbapenems[carbapenems != IPM]
amino <- AMX %or% AMP
third <- CAZ %or% CTX
amino <- AMX %or_if_na% AMP
third <- CAZ %or_if_na% CTX
ESBLs <- c(amino, third)
ESBLs <- ESBLs[!is.na(ESBLs)]
if (length(ESBLs) != 2) {
@@ -1524,7 +1524,7 @@ mdro <- function(x = NULL,
trans_tbl(
2, # positive, unconfirmed
rows = which(x$order == "Enterobacterales" & col_values(x, ESBLs[1]) == "R" & col_values(x, ESBLs[2]) == "R" & is.na(esbl)),
cols = c(AMX %or% AMP, cephalosporins_3rd),
cols = c(AMX %or_if_na% AMP, cephalosporins_3rd),
any_all = "all",
reason = "Enterobacterales: potential ESBL"
)
@@ -1634,7 +1634,7 @@ mdro <- function(x = NULL,
trans_tbl(
3,
rows = which(x$genus == "Enterococcus" & x$species == "faecium"),
cols = c(PEN %or% AMX %or% AMP, VAN),
cols = c(PEN %or_if_na% AMX %or_if_na% AMP, VAN),
any_all = "all",
reason = "E. faecium: vancomycin + penicillin group"
)
@@ -1677,8 +1677,8 @@ mdro <- function(x = NULL,
aminoglycosides <- aminoglycosides[!is.na(aminoglycosides)]
fluoroquinolones <- fluoroquinolones[!is.na(fluoroquinolones)]
carbapenems <- carbapenems[!is.na(carbapenems)]
amino <- AMX %or% AMP
third <- CAZ %or% CTX
amino <- AMX %or_if_na% AMP
third <- CAZ %or_if_na% CTX
ESBLs <- c(amino, third)
ESBLs <- ESBLs[!is.na(ESBLs)]
if (length(ESBLs) != 2) {

12
R/sir.R
View File

@@ -2292,12 +2292,12 @@ c.sir <- function(...) {
lst <- list(...)
# TODO for #170
# guideline <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$guideline %or% NA_character_)
# mo <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$mo %or% NA_character_)
# ab <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ab %or% NA_character_)
# method <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$method %or% NA_character_)
# ref_tbl <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ref_tbl %or% NA_character_)
# ref_breakpoints <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ref_breakpoints %or% NA_character_)
# guideline <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$guideline %||% NA_character_)
# mo <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$mo %||% NA_character_)
# ab <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ab %||% NA_character_)
# method <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$method %||% NA_character_)
# ref_tbl <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ref_tbl %||% NA_character_)
# ref_breakpoints <- vapply(FUN.VALUE = character(1), lst, function(x) attributes(x)$ref_breakpoints %||% NA_character_)
out <- as.sir(unlist(lapply(list(...), as.character)))

View File

@@ -86,10 +86,10 @@ AMR_env$chmatch <- import_fn("chmatch", "data.table", error_on_fail = FALSE)
AMR_env$chin <- import_fn("%chin%", "data.table", error_on_fail = FALSE)
# take cli symbols and error function if available
AMR_env$bullet_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$bullet %or% "*"
AMR_env$ellipsis_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$ellipsis %or% "..."
AMR_env$info_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$info %or% "i"
AMR_env$sup_1_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$sup_1 %or% "*"
AMR_env$bullet_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$bullet %||% "*"
AMR_env$ellipsis_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$ellipsis %||% "..."
AMR_env$info_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$info %||% "i"
AMR_env$sup_1_icon <- import_fn("symbol", "cli", error_on_fail = FALSE)$sup_1 %||% "*"
AMR_env$cli_abort <- import_fn("cli_abort", "cli", error_on_fail = FALSE)
AMR_env$cross_icon <- if (isTRUE(base::l10n_info()$`UTF-8`)) "\u00d7" else "x"