diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index e9c8d06c..5fdf647c 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -127,7 +127,7 @@ jobs: tar -xf data-raw/AMR_latest.tar.gz rm -rf AMR/vignettes Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[!grepl('VignetteBuilder', readLines('AMR/DESCRIPTION'))], 'AMR/DESCRIPTION')" - cat AMR/DESCRIPTION + find AMR -name 'DESCRIPTION' -exec cat '{}' \; || true shell: bash - name: Run R CMD check diff --git a/DESCRIPTION b/DESCRIPTION index 43b4f48d..fdb9ef3d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.6.0.9047 -Date: 2021-05-18 +Version: 1.6.0.9048 +Date: 2021-05-19 Title: Antimicrobial Resistance Data Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NAMESPACE b/NAMESPACE index 5d94b329..87cb42e8 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ # Generated by roxygen2: do not edit by hand S3method("!",mic) +S3method("!=",ab_selector) S3method("!=",mic) S3method("%%",mic) S3method("%/%",mic) @@ -11,6 +12,7 @@ S3method("-",mic) S3method("/",mic) S3method("<",mic) S3method("<=",mic) +S3method("==",ab_selector) S3method("==",mic) S3method(">",mic) S3method(">=",mic) @@ -37,7 +39,11 @@ S3method("|",mic) S3method(abs,mic) S3method(acos,mic) S3method(acosh,mic) +S3method(all,ab_selector) +S3method(all,ab_selector_any_all) S3method(all,mic) +S3method(any,ab_selector) +S3method(any,ab_selector_any_all) S3method(any,mic) S3method(as.data.frame,ab) S3method(as.data.frame,mo) @@ -59,6 +65,7 @@ S3method(barplot,disk) S3method(barplot,mic) S3method(barplot,rsi) S3method(c,ab) +S3method(c,ab_selector) S3method(c,custom_eucast_rules) S3method(c,custom_mdro_guideline) S3method(c,disk) diff --git a/NEWS.md b/NEWS.md index 075dd9ec..26b8fd5b 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,24 @@ -# `AMR` 1.6.0.9047 -## Last updated: 18 May 2021 +# `AMR` 1.6.0.9048 +## Last updated: 19 May 2021 + +### Breaking change +* All antibiotic class selectors (such as `carbapenems()`, `aminoglycosides()`) can now be used for filtering as well, making all their accompanying `filter_*()` functions redundant (such as `filter_carbapenems()`, `filter_aminoglycosides()`). These functions are now deprecated and will be removed in a next release. + ```r + # select columns with results for carbapenems + example_isolates[, carbapenems()] # base R + example_isolates %>% select(carbapenems()) # dplyr + + # filter rows for resistance in any carbapenem + example_isolates[any(carbapenems() == "R"), ] # base R + example_isolates %>% filter(any(carbapenems() == "R")) # dplyr + example_isolates %>% filter(if_any(carbapenems(), ~.x == "R")) # dplyr (formal) + + # filter rows for resistance in all carbapenems + example_isolates[all(carbapenems() == "R"), ] # base R + example_isolates[carbapenems() == "R", ] + example_isolates %>% filter(all(carbapenems() == "R")) # dplyr + example_isolates %>% filter(carbapenems() == "R") + ``` ### New * Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()` diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index d2d79cb1..d4728c45 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -336,6 +336,9 @@ word_wrap <- function(..., collapse = "\n")) } + # correct for operators (will add the space later on) + ops <- "([,./><\\]\\[])" + msg <- gsub(paste0(ops, " ", ops), "\\1\\2", msg, perl = TRUE) # we need to correct for already applied style, that adds text like "\033[31m\" msg_stripped <- font_stripstyle(msg) # where are the spaces now? @@ -352,6 +355,8 @@ word_wrap <- function(..., # put it together msg <- unlist(strsplit(msg, " ")) msg[replace_spaces] <- paste0(msg[replace_spaces], "\n") + # add space around operators again + msg <- gsub(paste0(ops, ops), "\\1 \\2", msg, perl = TRUE) msg <- paste0(msg, collapse = " ") msg <- gsub("\n ", "\n", msg, fixed = TRUE) @@ -365,7 +370,7 @@ word_wrap <- function(..., msg <- gsub("\n", paste0("\n", strrep(" ", indentation)), msg, fixed = TRUE) # remove trailing empty characters msg <- gsub("(\n| )+$", "", msg) - + if (length(add_fn) > 0) { if (!is.list(add_fn)) { add_fn <- list(add_fn) @@ -709,7 +714,7 @@ get_current_data <- function(arg_name, call) { if (!is.null(cur_data_all)) { out <- tryCatch(cur_data_all(), error = function(e) NULL) if (is.data.frame(out)) { - return(out) + return(structure(out, type = "dplyr_cur_data_all")) } } @@ -727,6 +732,7 @@ get_current_data <- function(arg_name, call) { # try a (base R) method, by going over the complete system call stack with sys.frames() not_set <- TRUE + source <- "base_R" frms <- lapply(sys.frames(), function(el) { if (not_set == TRUE && ".Generic" %in% names(el)) { if (tryCatch(".data" %in% names(el) && is.data.frame(el$`.data`), error = function(e) FALSE)) { @@ -736,6 +742,7 @@ get_current_data <- function(arg_name, call) { # an element `.data` will be in the system call stack when using dplyr::select() # [but not when using dplyr::filter(), dplyr::mutate() or dplyr::summarise()] not_set <<- FALSE + source <<- "dplyr_selector" el$`.data` } else if (tryCatch(any(c("x", "xx") %in% names(el)), error = function(e) FALSE)) { # - - - - @@ -763,7 +770,7 @@ get_current_data <- function(arg_name, call) { # lookup the matched frame and return its value: a data.frame vars_df <- tryCatch(frms[[which(!vapply(FUN.VALUE = logical(1), frms, is.null))]], error = function(e) NULL) if (is.data.frame(vars_df)) { - return(vars_df) + return(structure(vars_df, type = source)) } # nothing worked, so: diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R index a29608f2..0381717b 100644 --- a/R/ab_class_selectors.R +++ b/R/ab_class_selectors.R @@ -25,17 +25,19 @@ #' Antibiotic Class Selectors #' -#' These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} +#' These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} #' @inheritSection lifecycle Stable Lifecycle +#' @param ab_class an antimicrobial class, like `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value. #' @param only_rsi_columns a [logical] to indicate whether only columns of class `` must be selected (defaults to `FALSE`), see [as.rsi()] -#' @inheritParams filter_ab_class #' @details \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} #' -#' All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the [antibiotics] data set. This means that a selector like e.g. [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. +#' +#' These functions can be used in data set calls for selecting columns and filtering rows, see *Examples*. They support base R, but work more convenient in dplyr functions such as [`select()`][dplyr::select()], [`filter()`][dplyr::filter()] and [`summarise()`][dplyr::summarise()]. +#' +#' All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) in the [antibiotics] data set. This means that a selector like e.g. [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. #' #' The group of betalactams consists of all carbapenems, cephalosporins and penicillins. #' @rdname antibiotic_class_selectors -#' @seealso [filter_ab_class()] for the `filter()` equivalent. #' @name antibiotic_class_selectors #' @export #' @inheritSection AMR Reference Data Publicly Available @@ -44,11 +46,31 @@ #' # `example_isolates` is a data set available in the AMR package. #' # See ?example_isolates. #' -#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): +#' # Base R ------------------------------------------------------------------ +#' +#' # select columns 'IPM' (imipenem) and 'MEM' (meropenem) #' example_isolates[, carbapenems()] -#' # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB': +#' +#' # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB' #' example_isolates[, c("mo", aminoglycosides())] #' +#' # filter using any() or all() +#' example_isolates[any(carbapenems() == "R"), ] +#' subset(example_isolates, any(carbapenems() == "R")) +#' +#' # filter on any or all results in the carbapenem columns (i.e., IPM, MEM): +#' example_isolates[any(carbapenems()), ] +#' example_isolates[all(carbapenems()), ] +#' +#' # filter with multiple antibiotic selectors using c() +#' example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ] +#' +#' # filter + select in one go: get penicillins in carbapenems-resistant strains +#' example_isolates[any(carbapenems() == "R"), penicillins()] +#' +#' +#' # dplyr ------------------------------------------------------------------- +#' #' if (require("dplyr")) { #' #' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): @@ -59,6 +81,20 @@ #' example_isolates %>% #' select(mo, aminoglycosides()) #' +#' # any() and all() work in dplyr's filter() too: +#' example_isolates %>% +#' filter(any(aminoglycosides() == "R"), +#' all(cephalosporins_2nd() == "R")) +#' +#' # also works with c(): +#' example_isolates %>% +#' filter(any(c(carbapenems(), aminoglycosides()) == "R")) +#' +#' # not setting any/all will automatically apply all(): +#' example_isolates %>% +#' filter(aminoglycosides() == "R") +#' #> i Assuming a filter on all 4 aminoglycosides. +#' #' # this will select columns 'mo' and all antimycobacterial drugs ('RIF'): #' example_isolates %>% #' select(mo, ab_class("mycobact")) @@ -77,10 +113,11 @@ #' select(penicillins()) # only the 'J01CA01' column will be selected #' #' -#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is equal: +#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal: #' # (though the row names on the first are more correct) -#' example_isolates %>% filter_carbapenems("R", "all") -#' example_isolates %>% filter(across(carbapenems(), ~. == "R")) +#' example_isolates[carbapenems() == "R", ] +#' example_isolates %>% filter(carbapenems() == "R") +#' example_isolates %>% filter(across(carbapenems(), ~.x == "R")) #' } ab_class <- function(ab_class, only_rsi_columns = FALSE) { @@ -229,11 +266,204 @@ ab_selector <- function(ab_class, 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_("Applying `", function_name, "()`: selecting ", - ifelse(length(agents) == 1, "column ", "columns "), + message_("For `", function_name, "(", ifelse(function_name == "ab_class", paste0("\"", ab_class, "\""), ""), ")` using ", + ifelse(length(agents) == 1, "column: ", "columns: "), vector_and(agents_formatted, quotes = FALSE)) } remember_thrown_message(function_name) } - unname(agents) + + if (!is.null(attributes(vars_df)$type) && + attributes(vars_df)$type %in% c("dplyr_cur_data_all", "base_R") && + !any(as.character(sys.calls()) %like% paste0("(across|if_any|if_all)\\((c\\()?[a-z(), ]*", function_name))) { + structure(unname(agents), + class = c("ab_selector", "character")) + } else { + # don't return with "ab_selector" class if method is a dplyr selector, + # dplyr::select() will complain: + # > Subscript has the wrong type `ab_selector`. + # > It must be numeric or character. + unname(agents) + } +} + +#' @method c ab_selector +#' @export +#' @noRd +c.ab_selector <- function(...) { + structure(unlist(lapply(list(...), as.character)), + class = c("ab_selector", "character")) +} + +all_any_ab_selector <- function(type, ..., na.rm = TRUE) { + cols_ab <- c(...) + result <- cols_ab[toupper(cols_ab) %in% c("R", "S", "I")] + if (length(result) == 0) { + result <- c("R", "S", "I") + } + cols_ab <- cols_ab[!cols_ab %in% result] + df <- get_current_data(arg_name = NA, call = -3) + + if (type == "all") { + scope_fn <- all + } else { + scope_fn <- any + } + + x_transposed <- as.list(as.data.frame(t(df[, cols_ab, drop = FALSE]), stringsAsFactors = FALSE)) + vapply(FUN.VALUE = logical(1), + X = x_transposed, + FUN = function(y) scope_fn(y %in% result, na.rm = na.rm), + USE.NAMES = FALSE) +} + +#' @method all ab_selector +#' @export +#' @noRd +all.ab_selector <- function(..., na.rm = FALSE) { + # this is all() for + all_any_ab_selector("all", ..., na.rm = na.rm) +} + +#' @method any ab_selector +#' @export +#' @noRd +any.ab_selector <- function(..., na.rm = FALSE) { + all_any_ab_selector("any", ..., na.rm = na.rm) +} + + +#' @method all ab_selector_any_all +#' @export +#' @noRd +all.ab_selector_any_all <- function(..., na.rm = FALSE) { + # this is all() on a logical vector from `==.ab_selector` or `!=.ab_selector` + # e.g., example_isolates %>% filter(all(carbapenems() == "R")) + # so just return the vector as is, only correcting for na.rm + out <- unclass(c(...)) + if (na.rm == TRUE) { + out <- out[!is.na(out)] + } + out +} + +#' @method any ab_selector_any_all +#' @export +#' @noRd +any.ab_selector_any_all <- function(..., na.rm = FALSE) { + # this is any() on a logical vector from `==.ab_selector` or `!=.ab_selector` + # e.g., example_isolates %>% filter(any(carbapenems() == "R")) + # so just return the vector as is, only correcting for na.rm + out <- unclass(c(...)) + if (na.rm == TRUE) { + out <- out[!is.na(out)] + } + out +} + +#' @method == ab_selector +#' @export +#' @noRd +`==.ab_selector` <- function(e1, e2) { + calls <- as.character(match.call()) + fn_name <- calls[2] + # keep only the ... in c(...) + fn_name <- gsub("^(c\\()(.*)(\\))$", "\\2", fn_name) + if (is_any(fn_name)) { + type <- "any" + } else if (is_all(fn_name)) { + type <- "all" + } else { + type <- "all" + if (length(e1) > 1) { + message_("Assuming a filter on ", type, " ", length(e1), " ", gsub("[\\(\\)]", "", fn_name), + ". Wrap around `all()` or `any()` to prevent this note.") + } + } + structure(all_any_ab_selector(type = type, e1, e2), + class = c("ab_selector_any_all", "logical")) +} + +#' @method != ab_selector +#' @export +#' @noRd +`!=.ab_selector` <- function(e1, e2) { + calls <- as.character(match.call()) + fn_name <- calls[2] + # keep only the ... in c(...) + fn_name <- gsub("^(c\\()(.*)(\\))$", "\\2", fn_name) + if (is_any(fn_name)) { + type <- "any" + } else if (is_all(fn_name)) { + type <- "all" + } else { + type <- "all" + if (length(e1) > 1) { + message_("Assuming a filter on ", type, " ", length(e1), " ", gsub("[\\(\\)]", "", fn_name), + ". Wrap around `all()` or `any()` to prevent this note.") + } + } + # this is `!=`, so turn around the values + rsi <- c("R", "S", "I") + e2 <- rsi[rsi != e2] + structure(all_any_ab_selector(type = type, e1, e2), + class = c("ab_selector_any_all", "logical")) +} + +is_any <- function(el1) { + syscall <- paste0(trimws(deparse(sys.calls()[[1]])), collapse = " ") + el1 <- gsub("(.*),.*", "\\1", el1) + syscall %like% paste0("[^_a-zA-Z0-9]any\\(", "(c\\()?", el1) +} +is_all <- function(el1) { + syscall <- paste0(trimws(deparse(sys.calls()[[1]])), collapse = " ") + el1 <- gsub("(.*),.*", "\\1", el1) + syscall %like% paste0("[^_a-zA-Z0-9]all\\(", "(c\\()?", el1) +} + + +find_ab_group <- function(ab_class) { + ab_class[ab_class == "carbapenem|cephalosporin|penicillin"] <- "betalactam" + ab_class <- gsub("[^a-zA-Z0-9]", ".*", ab_class) + ifelse(ab_class %in% c("aminoglycoside", + "betalactam", + "carbapenem", + "cephalosporin", + "fluoroquinolone", + "glycopeptide", + "macrolide", + "oxazolidinone", + "tetracycline"), + paste0(ab_class, "s"), + antibiotics %pm>% + subset(group %like% ab_class | + atc_group1 %like% ab_class | + atc_group2 %like% ab_class) %pm>% + pm_pull(group) %pm>% + unique() %pm>% + tolower() %pm>% + sort() %pm>% + paste(collapse = "/") + ) +} + +find_ab_names <- function(ab_group, n = 3) { + ab_group <- gsub("[^a-zA-Z|0-9]", ".*", ab_group) + + # try popular first, they have DDDs + drugs <- antibiotics[which((!is.na(antibiotics$iv_ddd) | !is.na(antibiotics$oral_ddd)) & + antibiotics$name %unlike% " " & + antibiotics$group %like% ab_group & + antibiotics$ab %unlike% "[0-9]$"), ]$name + if (length(drugs) < n) { + # now try it all + drugs <- antibiotics[which((antibiotics$group %like% ab_group | + antibiotics$atc_group1 %like% ab_group | + antibiotics$atc_group2 %like% ab_group) & + antibiotics$ab %unlike% "[0-9]$"), ]$name + } + vector_or(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE), + tolower = TRUE, + language = NULL), + quotes = FALSE) } diff --git a/R/deprecated.R b/R/deprecated.R index ba226b88..210f8bf3 100755 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -25,7 +25,8 @@ #' Deprecated Functions #' -#' These functions are so-called '[Deprecated]'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one). +#' These functions are so-called '[Deprecated]'. **They will be removed in a future release.** Using the functions will give a warning with the name of the function it has been replaced by (if there is one). +#' @details All antibiotic class selectors (such as [carbapenems()], [aminoglycosides()]) can now be used for filtering as well, making all their accompanying `filter_*()` functions redundant (such as [filter_carbapenems()], [filter_aminoglycosides()]). #' @inheritSection lifecycle Retired Lifecycle #' @inheritSection AMR Read more on Our Website! #' @keywords internal @@ -138,3 +139,364 @@ key_antibiotics_equal <- function(y, points_threshold = points_threshold, info = info) } + + +#' @name AMR-deprecated +#' @export +filter_ab_class <- function(x, + ab_class, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + + .call_depth <- list(...)$`.call_depth` + if (is.null(.call_depth)) { + .call_depth <- 0 + } + .x_name <- list(...)$`.x_name` + if (is.null(.x_name)) { + .x_name <- deparse(substitute(x)) + } + .fn <- list(...)$`.fn` + if (is.null(.fn)) { + .fn <- "filter_ab_class" + } + .fn_old <- .fn + # new way: using the ab selectors + .fn <- gsub("filter_", "", .fn, fixed = TRUE) + .fn <- gsub("^([1-5][a-z]+)_cephalosporins", "cephalosporins_\\1", .fn) + + if (missing(x) || is_null_or_grouped_tbl(x)) { + # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) + # is also fix for using a grouped df as input (a dot as first argument) + x <- get_current_data(arg_name = "x", call = -2 - .call_depth) + .x_name <- "your_data" + } + meet_criteria(x, allow_class = "data.frame", .call_depth = .call_depth) + meet_criteria(ab_class, allow_class = "character", has_length = 1, .call_depth = .call_depth) + if (!is.null(result)) { + # make result = "SI" works too: + result <- toupper(unlist(strsplit(result, ""))) + } + meet_criteria(result, allow_class = "character", has_length = c(1, 2, 3), is_in = c("S", "I", "R"), allow_NULL = TRUE, .call_depth = .call_depth) + meet_criteria(scope, allow_class = "character", has_length = 1, is_in = c("all", "any"), .call_depth = .call_depth) + meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1, .call_depth = .call_depth) + + if (is.null(result)) { + result <- c("S", "I", "R") + } + + # get e.g. carbapenems() from filter_carbapenems() + fn <- get(.fn, envir = asNamespace("AMR")) + if (scope == "any") { + scope_fn <- any + } else { + scope_fn <- all + } + + # be nice here, be VERY extensive about how the AB selectors have taken over this function + deprecated_fn <- paste0(.fn, "(", ifelse(.fn == "ab_class", paste0("\"", ab_class, "\""), ""), ")", + ifelse(length(result) > 1, + paste0(", c(", paste0("\"", result, "\"", collapse = ", "), ")"), + ifelse(is.null(result), + "", + paste0(" == \"", result, "\"")))) + if (.x_name == ".") { + .x_name <- "your_data" + } + warning_(paste0("`", .fn_old, "()` is deprecated. Use the antibiotic selector `", .fn, "()` instead.\n", + "In dplyr:\n", + " - ", .x_name, " %>% filter(", scope, "(", deprecated_fn, "))\n", + ifelse(length(result) > 1, + paste0(" - ", .x_name, " %>% filter(", scope, "(", + .fn, "(", ifelse(.fn == "ab_class", paste0("\"", ab_class, "\""), ""), ") == \"R\"))\n"), + ""), + "In base R:\n", + " - ", .x_name, "[", scope, "(", deprecated_fn, "), ]\n", + ifelse(length(result) > 1, + paste0(" - ", .x_name, "[", scope, "(", + .fn, "(", ifelse(.fn == "ab_class", paste0("\"", ab_class, "\""), ""), ") == \"R\"), ]\n"), + ""), + " - subset(", .x_name, ", ", scope, "(", deprecated_fn, "))", + ifelse(length(result) > 1, + paste0("\n - subset(", .x_name, ", ", scope, "(", + .fn, "(", ifelse(.fn == "ab_class", paste0("\"", ab_class, "\""), ""), ") == \"R\"))"), + "")), + call = FALSE) + + if (.fn == "ab_class") { + subset(x, scope_fn(fn(ab_class = ab_class), result)) + } else { + subset(x, scope_fn(fn(), result)) + } +} + +#' @name AMR-deprecated +#' @export +filter_aminoglycosides <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "aminoglycoside", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_aminoglycosides", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_betalactams <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "carbapenem|cephalosporin|penicillin", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_betalactams", + .x_name = deparse(substitute(x)), + ...) +} +#' @name AMR-deprecated +#' @export +filter_carbapenems <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "carbapenem", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_carbapenems", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_cephalosporins <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "cephalosporin", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_cephalosporins", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_1st_cephalosporins <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "cephalosporins (1st gen.)", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_1st_cephalosporins", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_2nd_cephalosporins <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "cephalosporins (2nd gen.)", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_2nd_cephalosporins", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_3rd_cephalosporins <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "cephalosporins (3rd gen.)", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_3rd_cephalosporins", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_4th_cephalosporins <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "cephalosporins (4th gen.)", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_4th_cephalosporins", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_5th_cephalosporins <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "cephalosporins (5th gen.)", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_5th_cephalosporins", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_fluoroquinolones <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "fluoroquinolone", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_fluoroquinolones", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_glycopeptides <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "glycopeptide", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_glycopeptides", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_macrolides <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "macrolide", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_macrolides", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_oxazolidinones <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "oxazolidinone", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_oxazolidinones", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_penicillins <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "penicillin", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_penicillins", + .x_name = deparse(substitute(x)), + ...) +} + +#' @name AMR-deprecated +#' @export +filter_tetracyclines <- function(x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ...) { + filter_ab_class(x = x, + ab_class = "tetracycline", + result = result, + scope = scope, + only_rsi_columns = only_rsi_columns, + .call_depth = 1, + .fn = "filter_tetracyclines", + .x_name = deparse(substitute(x)), + ...) +} diff --git a/R/filter_ab_class.R b/R/filter_ab_class.R deleted file mode 100644 index 7e9f5db8..00000000 --- a/R/filter_ab_class.R +++ /dev/null @@ -1,510 +0,0 @@ -# ==================================================================== # -# TITLE # -# Antimicrobial Resistance (AMR) Data Analysis for R # -# # -# SOURCE # -# https://github.com/msberends/AMR # -# # -# LICENCE # -# (c) 2018-2021 Berends MS, Luz CF et al. # -# Developed at the University of Groningen, the Netherlands, in # -# collaboration with non-profit organisations Certe Medical # -# Diagnostics & Advice, and University Medical Center Groningen. # -# # -# This R package is free software; you can freely use and distribute # -# it for both personal and commercial purposes under the terms of the # -# GNU General Public License version 2.0 (GNU GPL-2), as published by # -# the Free Software Foundation. # -# We created this package for both routine data analysis and academic # -# research and it was publicly released in the hope that it will be # -# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. # -# # -# Visit our website for the full manual and a complete tutorial about # -# how to conduct AMR data analysis: https://msberends.github.io/AMR/ # -# ==================================================================== # - -#' Filter Isolates on Result in Antimicrobial Class -#' -#' Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs. -#' @inheritSection lifecycle Stable Lifecycle -#' @param x a data set -#' @param ab_class an antimicrobial class, like `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value. -#' @param result an antibiotic result: S, I or R (or a combination of more of them) -#' @param scope the scope to check which variables to check, can be `"any"` (default) or `"all"` -#' @param only_rsi_columns a [logical] to indicate whether only columns must be included that were transformed to class `` (see [as.rsi()]) on beforehand (defaults to `FALSE`) -#' @param ... arguments passed on to [filter_ab_class()] -#' @details All columns of `x` will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a filter function like e.g. [filter_aminoglycosides()] will include column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. -#' -#' The group of betalactams consists of all carbapenems, cephalosporins and penicillins. -#' @rdname filter_ab_class -#' @seealso [antibiotic_class_selectors()] for the `select()` equivalent. -#' @export -#' @examples -#' x <- filter_carbapenems(example_isolates) -#' \donttest{ -#' # base R filter options (requires R >= 3.2) -#' example_isolates[filter_carbapenems(), ] -#' example_isolates[which(filter_carbapenems() & mo_is_gram_negative()), ] -#' -#' if (require("dplyr")) { -#' -#' # filter on isolates that have any result for any aminoglycoside -#' example_isolates %>% filter_aminoglycosides() -#' example_isolates %>% filter_ab_class("aminoglycoside") -#' -#' # this is essentially the same as (but without determination of column names): -#' example_isolates %>% -#' filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")), -#' .vars_predicate = any_vars(. %in% c("S", "I", "R"))) -#' -#' -#' # filter on isolates that show resistance to ANY aminoglycoside -#' example_isolates %>% filter_aminoglycosides("R", "any") -#' -#' # filter on isolates that show resistance to ALL aminoglycosides -#' example_isolates %>% filter_aminoglycosides("R", "all") -#' -#' # filter on isolates that show resistance to -#' # any aminoglycoside and any fluoroquinolone -#' example_isolates %>% -#' filter_aminoglycosides("R") %>% -#' filter_fluoroquinolones("R") -#' -#' # filter on isolates that show resistance to -#' # all aminoglycosides and all fluoroquinolones -#' example_isolates %>% -#' filter_aminoglycosides("R", "all") %>% -#' filter_fluoroquinolones("R", "all") -#' -#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal: -#' # (though the row names on the first are more correct) -#' example_isolates %>% filter_carbapenems("R", "all") -#' example_isolates %>% filter(across(carbapenems(), ~. == "R")) -#' example_isolates %>% filter(across(carbapenems(), function(x) x == "R")) -#' example_isolates %>% filter(filter_carbapenems("R", "all")) -#' } -#' } -filter_ab_class <- function(x, - ab_class, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - .call_depth <- list(...)$`.call_depth` - if (is.null(.call_depth)) { - .call_depth <- 0 - } - .fn <- list(...)$`.fn` - if (is.null(.fn)) { - .fn <- "filter_ab_class" - } - - return_only_row_indices <- FALSE - if (missing(x) || is_null_or_grouped_tbl(x)) { - # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) - # is also fix for using a grouped df as input (a dot as first argument) - x <- get_current_data(arg_name = "x", call = -2 - .call_depth) - return_only_row_indices <- TRUE - } - meet_criteria(x, allow_class = "data.frame", .call_depth = .call_depth) - meet_criteria(ab_class, allow_class = "character", has_length = 1, .call_depth = .call_depth) - if (!is.null(result)) { - result <- toupper(result) - } - meet_criteria(result, allow_class = "character", has_length = c(1, 2, 3), is_in = c("S", "I", "R"), allow_NULL = TRUE, .call_depth = .call_depth) - meet_criteria(scope, allow_class = "character", has_length = 1, is_in = c("all", "any"), .call_depth = .call_depth) - meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1, .call_depth = .call_depth) - - check_dataset_integrity() - - # save to return later - x.bak <- x - x <- as.data.frame(x, stringsAsFactors = FALSE) - - if (is.null(result)) { - result <- c("S", "I", "R") - } - # make result = "SI" works too: - result <- unlist(strsplit(result, "")) - - # get all columns in data with names that resemble antibiotics - ab_in_data <- get_column_abx(x, info = FALSE, only_rsi_columns = only_rsi_columns, sort = FALSE) - - # improve speed here so it will only run once when e.g. in one select call - if (!identical(pkg_env$filter_ab_selector, unique_call_id())) { - ab_in_data <- get_column_abx(x, info = FALSE, only_rsi_columns = only_rsi_columns, sort = FALSE) - pkg_env$filter_ab_selector <- unique_call_id() - pkg_env$filter_ab_selector_cols <- ab_in_data - } else { - ab_in_data <- pkg_env$filter_ab_selector_cols - } - - if (length(ab_in_data) == 0) { - message_("No columns with antibiotic test results found (see ?as.rsi), data left unchanged.") - return(x.bak) - } - # get reference data - ab_class.bak <- ab_class - ab_class <- gsub("[^a-zA-Z|0-9]+", ".*", ab_class) - ab_class <- gsub("(ph|f)", "(ph|f)", ab_class) - ab_class <- gsub("(t|th)", "(t|th)", ab_class) - ab_reference <- subset(antibiotics, - group %like% ab_class | - atc_group1 %like% ab_class | - atc_group2 %like% ab_class) - if (nrow(ab_reference) == 0) { - message_("Unknown antimicrobial class '", ab_class.bak, "', data left unchanged.") - return(x.bak) - } - ab_group <- find_ab_group(ab_class.bak) - # get the columns with a group names in the chosen ab class - agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab] - if (length(agents) == 0) { - message_("No antimicrobial agents of class '", ab_group, - "' found (such as ", find_ab_names(ab_class, 2), - ")", - ifelse(only_rsi_columns == TRUE, " with class ,", ","), - " data left unchanged.") - return(x.bak) - } - - if (scope == "any") { - scope_txt <- " or " - scope_fn <- any - } else { - scope_txt <- " and " - scope_fn <- all - } - if (length(agents) > 1) { - operator <- " are" - scope <- paste("values in", scope, "of columns ") - } else { - operator <- " is" - scope <- "value in column " - } - if (length(result) > 1) { - operator <- paste(operator, "either") - } - - # sort columns on official name - agents <- agents[order(ab_name(names(agents), language = NULL))] - - agents_formatted <- paste0("'", font_bold(agents, collapse = NULL), "'") - agents_names <- ab_name(names(agents), tolower = TRUE, language = NULL) - 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_("Applying `", .fn, "()`: ", scope, - vector_or(agents_formatted, quotes = FALSE, last_sep = scope_txt), - operator, " ", vector_or(result, quotes = TRUE)) - x_transposed <- as.list(as.data.frame(t(x[, agents, drop = FALSE]), stringsAsFactors = FALSE)) - filtered <- vapply(FUN.VALUE = logical(1), x_transposed, function(y) scope_fn(y %in% result, na.rm = TRUE)) - - if (return_only_row_indices == TRUE) { - filtered - } else { - # this returns the original data with the filtering, also preserving attributes (such as dplyr groups) - x.bak[which(filtered), , drop = FALSE] - } -} - -#' @rdname filter_ab_class -#' @export -filter_aminoglycosides <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "aminoglycoside", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_aminoglycosides", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_betalactams <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "carbapenem|cephalosporin|penicillin", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_betalactams", - ...) -} -#' @rdname filter_ab_class -#' @export -filter_carbapenems <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "carbapenem", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_carbapenems", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_cephalosporins <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "cephalosporin", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_cephalosporins", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_1st_cephalosporins <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "cephalosporins (1st gen.)", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_1st_cephalosporins", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_2nd_cephalosporins <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "cephalosporins (2nd gen.)", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_2nd_cephalosporins", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_3rd_cephalosporins <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "cephalosporins (3rd gen.)", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_3rd_cephalosporins", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_4th_cephalosporins <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "cephalosporins (4th gen.)", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_4th_cephalosporins", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_5th_cephalosporins <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "cephalosporins (5th gen.)", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_5th_cephalosporins", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_fluoroquinolones <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "fluoroquinolone", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_fluoroquinolones", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_glycopeptides <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "glycopeptide", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_glycopeptides", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_macrolides <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "macrolide", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_macrolides", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_oxazolidinones <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "oxazolidinone", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_oxazolidinones", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_penicillins <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "penicillin", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_penicillins", - ...) -} - -#' @rdname filter_ab_class -#' @export -filter_tetracyclines <- function(x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ...) { - filter_ab_class(x = x, - ab_class = "tetracycline", - result = result, - scope = scope, - only_rsi_columns = only_rsi_columns, - .call_depth = 1, - .fn = "filter_tetracyclines", - ...) -} - -find_ab_group <- function(ab_class) { - ab_class[ab_class == "carbapenem|cephalosporin|penicillin"] <- "betalactam" - ab_class <- gsub("[^a-zA-Z0-9]", ".*", ab_class) - ifelse(ab_class %in% c("aminoglycoside", - "betalactam", - "carbapenem", - "cephalosporin", - "fluoroquinolone", - "glycopeptide", - "macrolide", - "oxazolidinone", - "tetracycline"), - paste0(ab_class, "s"), - antibiotics %pm>% - subset(group %like% ab_class | - atc_group1 %like% ab_class | - atc_group2 %like% ab_class) %pm>% - pm_pull(group) %pm>% - unique() %pm>% - tolower() %pm>% - sort() %pm>% - paste(collapse = "/") - ) -} - -find_ab_names <- function(ab_group, n = 3) { - ab_group <- gsub("[^a-zA-Z|0-9]", ".*", ab_group) - - # try popular first, they have DDDs - drugs <- antibiotics[which((!is.na(antibiotics$iv_ddd) | !is.na(antibiotics$oral_ddd)) & - antibiotics$name %unlike% " " & - antibiotics$group %like% ab_group & - antibiotics$ab %unlike% "[0-9]$"), ]$name - if (length(drugs) < n) { - # now try it all - drugs <- antibiotics[which((antibiotics$group %like% ab_group | - antibiotics$atc_group1 %like% ab_group | - antibiotics$atc_group2 %like% ab_group) & - antibiotics$ab %unlike% "[0-9]$"), ]$name - } - vector_or(ab_name(sample(drugs, size = min(n, length(drugs)), replace = FALSE), - tolower = TRUE, - language = NULL), - quotes = FALSE) -} diff --git a/_pkgdown.yml b/_pkgdown.yml index 61bdb2cc..22de77d9 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -149,7 +149,7 @@ reference: desc: > Use these function for the analysis part. You can use `susceptibility()` or `resistance()` on any antibiotic column. Be sure to first select the isolates that are appropiate for analysis, by using `first_isolate()` or `is_new_episode()`. - You can also filter your data on certain resistance in certain antibiotic classes (`filter_ab_class()`), or determine multi-drug resistant microorganisms (MDRO, `mdro()`). + You can also filter your data on certain resistance in certain antibiotic classes (`carbapenems()`, `aminoglycosides()`), or determine multi-drug resistant microorganisms (MDRO, `mdro()`). contents: - "`proportion`" - "`count`" @@ -162,7 +162,6 @@ reference: - "`ggplot_rsi`" - "`bug_drug_combinations`" - "`antibiotic_class_selectors`" - - "`filter_ab_class`" - "`resistance_predict`" - "`guess_ab_col`" diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 1818c5ea..0a40c9e7 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/data-raw/tinytest_1.2.4.patched.tar.gz b/data-raw/tinytest_1.2.4.patched.tar.gz index c1964685..6fac8488 100644 Binary files a/data-raw/tinytest_1.2.4.patched.tar.gz and b/data-raw/tinytest_1.2.4.patched.tar.gz differ diff --git a/docs/404.html b/docs/404.html index 1363f01f..7cc6f01e 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 9adf2a4d..2e885d74 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048 diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index c2db7e9e..bb9eeac5 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048 @@ -192,7 +192,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 6913194a..7beae55c 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048 diff --git a/docs/index.html b/docs/index.html index 9e95c72a..9ceb7368 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048 diff --git a/docs/news/index.html b/docs/news/index.html index a64ab95f..5645c6ae 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048 @@ -236,13 +236,38 @@ Source: NEWS.md -
-

- Unreleased AMR 1.6.0.9047

-
+
+

+ Unreleased AMR 1.6.0.9048

+

-Last updated: 18 May 2021 +Last updated: 19 May 2021

+
+

+Breaking change

+ +

New

@@ -262,7 +287,7 @@
  • The documentation of the first_isolate() and key_antimicrobials() functions has been completely rewritten.
  • -
  • Function betalactams() as additional antbiotic column selector and function filter_betalactams() as additional antbiotic column filter. The group of betalactams consists of all carbapenems, cephalosporins and penicillins.
  • +
  • Function betalactams() as additional antbiotic column selector and function filter_betalactams() as additional antbiotic column filter. The group of betalactams consists of all carbapenems, cephalosporins and penicillins.
  • A ggplot() method for resistance_predict()
  • @@ -287,7 +312,7 @@
  • Now checks if pattern is a valid regular expression

  • Added %unlike% and %unlike_case% (as negations of the existing %like% and %like_case%). This greatly improves readability:

    -
    +
     
     if (!grepl("EUCAST", guideline)) ...
     # same:
    @@ -307,17 +332,17 @@
     
  • Updated skimr::skim() usage for MIC values to also include 25th and 75th percentiles
  • Fix for plotting missing MIC/disk diffusion values
  • Updated join functions to always use dplyr join functions if the dplyr package is installed - now also preserving grouped variables
  • -
  • Updates for filtering on antibiotic classes (e.g., using filter_carbapenems()): +
  • Updates for filtering on antibiotic classes (e.g., using filter_carbapenems()):
    • Support for dplyr groups

    • Support for base R row filtering:

      -
      +
       
       dim(example_isolates)
       #> [1] 2000   49
       
      -example_isolates[filter_carbapenems(), ]
      +example_isolates[filter_carbapenems(), ]
       #> ℹ Applying `filter_carbapenems()`: values in any of columns 'IPM' (imipenem)
       #>   or 'MEM' (meropenem) are either "R", "S" or "I"
       #> [1] 962  49
      @@ -357,7 +382,7 @@

      Added argument only_rsi_columns for some functions, which defaults to FALSE, to indicate if the functions must only be applied to columns that are of class <rsi> (i.e., transformed with as.rsi()). This increases speed since automatic determination of antibiotic columns is not needed anymore. Affected functions are:

    • -

      Functions oxazolidinones() (an antibiotic selector function) and filter_oxazolidinones() (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid

      -
      +

      Functions oxazolidinones() (an antibiotic selector function) and filter_oxazolidinones() (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid

      +
       
       library(dplyr)
       x <- example_isolates %>% select(date, hospital_id, oxazolidinones())
       #> Selecting oxazolidinones: column 'LNZ' (linezolid)
       
      -x <- example_isolates %>% filter_oxazolidinones()
      +x <- example_isolates %>% filter_oxazolidinones()
       #> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"
    • Support for custom MDRO guidelines, using the new custom_mdro_guideline() function, please see mdro() for additional info

    • ggplot() generics for classes <mic> and <disk>

    • Function mo_is_yeast(), which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:

      -
      +
       
       mo_kingdom(c("Aspergillus", "Candida"))
       #> [1] "Fungi" "Fungi"
      @@ -391,7 +416,7 @@
       example_isolates[which(mo_is_yeast()), ]   # base R
       example_isolates %>% filter(mo_is_yeast()) # dplyr

      The mo_type() function has also been updated to reflect this change:

      -
      +
       
       mo_type(c("Aspergillus", "Candida"))
       # [1] "Fungi"  "Yeasts"
      @@ -401,7 +426,7 @@
       
    • Added Pretomanid (PMD, J04AK08) to the antibiotics data set

    • MIC values (see as.mic()) can now be used in any mathematical processing, such as usage inside functions min(), max(), range(), and with binary operators (+, -, etc.). This allows for easy distribution analysis and fast filtering on MIC values:

      -
      +
       
       x <- random_mic(10)
       x
      @@ -484,7 +509,7 @@
       
      -
      +
       
       # to select first isolates that are Gram-negative 
       # and view results of cephalosporins and aminoglycosides:
      @@ -550,7 +575,7 @@
       
    • For antibiotic selection functions (such as cephalosporins(), aminoglycosides()) to select columns based on a certain antibiotic group, the dependency on the tidyselect package was removed, meaning that they can now also be used without the need to have this package installed and now also work in base R function calls (they rely on R 3.2 or later):

      -
      +
       
       # above example in base R:
       example_isolates[which(first_isolate() & mo_is_gram_negative()),
      @@ -600,7 +625,7 @@
       
    • Data set intrinsic_resistant. This data set contains all bug-drug combinations where the ‘bug’ is intrinsic resistant to the ‘drug’ according to the latest EUCAST insights. It contains just two columns: microorganism and antibiotic.

      Curious about which enterococci are actually intrinsic resistant to vancomycin?

      -
      +
       
       library(AMR)
       library(dplyr)
      @@ -623,7 +648,7 @@
       
      • Support for using dplyr’s across() to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.

        -
        +
         
         # until dplyr 1.0.0
         your_data %>% mutate_if(is.mic, as.rsi)
        @@ -641,7 +666,7 @@
         
      • Added intelligent data cleaning to as.disk(), so numbers can also be extracted from text and decimal numbers will always be rounded up:

        -
        +
         
         as.disk(c("disk zone: 23.4 mm", 23.4))
         #> Class <disk>
        @@ -701,7 +726,7 @@
         
      • Function ab_from_text() to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses as.ab() internally

      • Tidyverse selection helpers for antibiotic classes, that help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. They can be used in any function that allows selection helpers, like dplyr::select() and tidyr::pivot_longer():

        -
        +
         
         library(dplyr)
         
        @@ -711,8 +736,8 @@
         #> Selecting carbapenems: `IPM` (imipenem), `MEM` (meropenem)
      • Added mo_domain() as an alias to mo_kingdom()

      • -
      • Added function filter_penicillins() to filter isolates on a specific result in any column with a name in the antimicrobial ‘penicillins’ class (more specific: ATC subgroup Beta-lactam antibacterials, penicillins)

      • -
      • Added official antimicrobial names to all filter_ab_class() functions, such as filter_aminoglycosides()

      • +
      • Added function filter_penicillins() to filter isolates on a specific result in any column with a name in the antimicrobial ‘penicillins’ class (more specific: ATC subgroup Beta-lactam antibacterials, penicillins)

      • +
      • Added official antimicrobial names to all filter_ab_class() functions, such as filter_aminoglycosides()

      • Added antibiotics code “FOX1” for cefoxitin screening (abbreviation “cfsc”) to the antibiotics data set

      • Added Monuril as trade name for fosfomycin

      • Added argument conserve_capped_values to as.rsi() for interpreting MIC values - it makes sure that values starting with “<” (but not “<=”) will always return “S” and values starting with “>” (but not “>=”) will always return “R”. The default behaviour of as.rsi() has not changed, so you need to specifically do as.rsi(..., conserve_capped_values = TRUE).

      • @@ -759,7 +784,7 @@
      • Changed the summary for class <rsi>, to highlight the %SI vs. %R

      • Improved error handling, giving more useful info when functions return an error

      • Any progress bar will now only show in interactive mode (i.e. not in R Markdown)

      • -
      • Speed improvement for mdro() and filter_ab_class()

      • +
      • Speed improvement for mdro() and filter_ab_class()

      • New option arrows_textangled for ggplot_pca() to indicate whether the text at the end of the arrows should be angled (defaults to TRUE, as it was in previous versions)

      • Added parenteral DDD to benzylpenicillin

      • Fixed a bug where as.mic() could not handle dots without a leading zero (like "<=.25)

      • @@ -887,7 +912,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
      • Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline

      • Interpretation from MIC values (and disk zones) to R/SI can now be used with mutate_at() of the dplyr package:

        -
        +
         
         yourdata %>% 
           mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = "E. coli")
        @@ -915,7 +940,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
         
        • Support for LOINC codes in the antibiotics data set. Use ab_loinc() to retrieve LOINC codes, or use a LOINC code for input in any ab_* function:

          -
          +
           
           ab_loinc("ampicillin")
           #> [1] "21066-6" "3355-5"  "33562-0" "33919-2" "43883-8" "43884-6" "87604-5"
          @@ -926,7 +951,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
           
        • Support for SNOMED CT codes in the microorganisms data set. Use mo_snomed() to retrieve SNOMED codes, or use a SNOMED code for input in any mo_* function:

          -
          +
           
           mo_snomed("S. aureus")
           #> [1] 115329001   3092008 113961008
          @@ -990,11 +1015,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
           
          • If you were dependent on the old Enterobacteriaceae family e.g. by using in your code:

            -
            +
             
             if (mo_family(somebugs) == "Enterobacteriaceae") ...

            then please adjust this to:

            -
            +
             
             if (mo_order(somebugs) == "Enterobacterales") ...
          • @@ -1008,7 +1033,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
            • Functions susceptibility() and resistance() as aliases of proportion_SI() and proportion_R(), respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.

              -
              +
               
               library(dplyr)
               example_isolates %>%
              @@ -1037,7 +1062,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
               
            • More intelligent way of coping with some consonants like “l” and “r”

            • Added a score (a certainty percentage) to mo_uncertainties(), that is calculated using the Levenshtein distance:

              -
              +
               
               as.mo(c("Stafylococcus aureus",
                       "staphylokok aureuz"))
              @@ -1095,14 +1120,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
               
              • Determination of first isolates now excludes all ‘unknown’ microorganisms at default, i.e. microbial code "UNKNOWN". They can be included with the new argument include_unknown:

                -
                +
                 
                 first_isolate(..., include_unknown = TRUE)

                For WHONET users, this means that all records/isolates with organism code "con" (contamination) will be excluded at default, since as.mo("con") = "UNKNOWN". The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.

              • For code consistency, classes ab and mo will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in NA:

                -
                +
                 
                 # how it works in base R:
                 x <- factor("A")
                @@ -1127,7 +1152,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
                • Function bug_drug_combinations() to quickly get a data.frame with the results of all bug-drug combinations in a data set. The column containing microorganism codes is guessed automatically and its input is transformed with mo_shortname() at default:

                  -
                  +
                   
                   x <- bug_drug_combinations(example_isolates)
                   #> NOTE: Using column `mo` as input for `col_mo`.
                  @@ -1150,13 +1175,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   #> 4 Gram-negative AMX 227  0 405   632
                   #> NOTE: Use 'format()' on this result to get a publicable/printable format.

                  You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R format() function:

                  -
                  +
                   
                   format(x, combine_IR = FALSE)
                • Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for portion_* functions or count_* functions. This can be used to determine the empiric susceptibility of a combination therapy. A new argument only_all_tested (which defaults to FALSE) replaces the old also_single_tested and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the portion and count help pages), where the %SI is being determined:

                  -
                  +
                   
                   # --------------------------------------------------------------------
                   #                     only_all_tested = FALSE  only_all_tested = TRUE
                  @@ -1178,7 +1203,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • tibble printing support for classes rsi, mic, disk, ab mo. When using tibbles containing antimicrobial columns, values S will print in green, values I will print in yellow and values R will print in red. Microbial IDs (class mo) will emphasise on the genus and species, not on the kingdom.

                  -
                  +
                   
                   # (run this on your own console, as this page does not support colour printing)
                   library(dplyr)
                  @@ -1229,7 +1254,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • The name of RIF is now Rifampicin instead of Rifampin
                • The antibiotics data set is now sorted by name and all cephalosporins now have their generation between brackets
                • Speed improvement for guess_ab_col() which is now 30 times faster for antibiotic abbreviations
                • -
                • Improved filter_ab_class() to be more reliable and to support 5th generation cephalosporins
                • +
                • Improved filter_ab_class() to be more reliable and to support 5th generation cephalosporins
                • Function availability() now uses portion_R() instead of portion_IR(), to comply with EUCAST insights
                • Functions age() and age_groups() now have a na.rm argument to remove empty values
                • Renamed function p.symbol() to p_symbol() (the former is now deprecated and will be removed in a future version)
                • @@ -1260,7 +1285,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                  • Function rsi_df() to transform a data.frame to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions count_df() and portion_df() to immediately show resistance percentages and number of available isolates:

                    -
                    +
                     
                     septic_patients %>%
                       select(AMX, CIP) %>%
                    @@ -1287,7 +1312,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                  • UPEC (Uropathogenic E. coli)

                  All these lead to the microbial ID of E. coli:

                  -
                  +
                   
                   as.mo("UPEC")
                   # B_ESCHR_COL
                  @@ -1391,7 +1416,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • when all values are unique it now shows a message instead of a warning

                • support for boxplots:

                  -
                  +
                   
                   septic_patients %>% 
                     freq(age) %>% 
                  @@ -1484,30 +1509,30 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:

                  - -

                  The antibiotics data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the antibiotics data set. For example:

                  +

                  The antibiotics data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the antibiotics data set. For example:

                  +
                  +
                  +septic_patients %>% filter_glycopeptides(result = "R")
                   # Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R
                  -septic_patients %>% filter_glycopeptides(result = "R", scope = "all")
                  +septic_patients %>% filter_glycopeptides(result = "R", scope = "all")
                   # Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R
                • All ab_* functions are deprecated and replaced by atc_* functions:

                  -
                  +
                   
                   ab_property -> atc_property()
                   ab_name -> atc_name()
                  @@ -1528,7 +1553,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • New function age_groups() to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic AMR data analysis per age group.

                • New function ggplot_rsi_predict() as well as the base R plot() function can now be used for resistance prediction calculated with resistance_predict():

                  -
                  +
                   
                   x <- resistance_predict(septic_patients, col_ab = "amox")
                   plot(x)
                  @@ -1536,13 +1561,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • Functions filter_first_isolate() and filter_first_weighted_isolate() to shorten and fasten filtering on data sets with antimicrobial results, e.g.:

                  -
                  +
                   
                   septic_patients %>% filter_first_isolate(...)
                   # or
                   filter_first_isolate(septic_patients, ...)

                  is equal to:

                  -
                  +
                   
                   septic_patients %>%
                     mutate(only_firsts = first_isolate(septic_patients, ...)) %>%
                  @@ -1575,7 +1600,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                  • Now handles incorrect spelling, like i instead of y and f instead of ph:

                    -
                    +
                     
                     # mo_fullname() uses as.mo() internally
                     
                    @@ -1587,7 +1612,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                  • Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default allow_uncertain = TRUE is equal to uncertainty level 2. Run ?as.mo for more info about these levels.

                    -
                    +
                     
                     # equal:
                     as.mo(..., allow_uncertain = TRUE)
                    @@ -1602,7 +1627,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                  • All microbial IDs that found are now saved to a local file ~/.Rhistory_mo. Use the new function clean_mo_history() to delete this file, which resets the algorithms.

                  • Incoercible results will now be considered ‘unknown’, MO code UNKNOWN. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:

                    -
                    +
                     
                     mo_genus("qwerty", language = "es")
                     # Warning: 
                    @@ -1652,7 +1677,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                    • Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:

                      -
                      +
                       
                       # Determine genus of microorganisms (mo) in `septic_patients` data set:
                       # OLD WAY
                      @@ -1735,7 +1760,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       
                    • Fewer than 3 characters as input for as.mo will return NA

                    • Function as.mo (and all mo_* wrappers) now supports genus abbreviations with “species” attached

                      -
                      +
                       
                       as.mo("E. species")        # B_ESCHR
                       mo_fullname("E. spp.")     # "Escherichia species"
                      @@ -1752,7 +1777,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       
                      • Support for grouping variables, test with:

                        -
                        +
                         
                         septic_patients %>% 
                           group_by(hospital_id) %>% 
                        @@ -1760,7 +1785,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                         
                      • Support for (un)selecting columns:

                        -
                        +
                         
                         septic_patients %>% 
                           freq(hospital_id) %>% 
                        @@ -1839,7 +1864,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                         

                      They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:

                      -
                      +
                       
                       mo_gramstain("E. coli")
                       # [1] "Gram negative"
                      @@ -1850,7 +1875,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       mo_fullname("S. group A", language = "pt") # Portuguese
                       # [1] "Streptococcus grupo A"

                      Furthermore, former taxonomic names will give a note about the current taxonomic name:

                      -
                      +
                       
                       mo_gramstain("Esc blattae")
                       # Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)
                      @@ -1865,7 +1890,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       
                    • Function is.rsi.eligible to check for columns that have valid antimicrobial results, but do not have the rsi class yet. Transform the columns of your raw data with: data %>% mutate_if(is.rsi.eligible, as.rsi)

                    • Functions as.mo and is.mo as replacements for as.bactid and is.bactid (since the microoganisms data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The as.mo function determines microbial IDs using intelligent rules:

                      -
                      +
                       
                       as.mo("E. coli")
                       # [1] B_ESCHR_COL
                      @@ -1874,7 +1899,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       as.mo("S group A")
                       # [1] B_STRPTC_GRA

                      And with great speed too - on a quite regular Linux server from 2007 it takes us less than 0.02 seconds to transform 25,000 items:

                      -
                      +
                       
                       thousands_of_E_colis <- rep("E. coli", 25000)
                       microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s")
                      @@ -1908,7 +1933,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       
                    • Added three antimicrobial agents to the antibiotics data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)

                    • Added 163 trade names to the antibiotics data set, it now contains 298 different trade names in total, e.g.:

                      -
                      +
                       
                       ab_official("Bactroban")
                       # [1] "Mupirocin"
                      @@ -1925,7 +1950,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       
                    • Added arguments minimum and as_percent to portion_df

                    • Support for quasiquotation in the functions series count_* and portions_*, and n_rsi. This allows to check for more than 2 vectors or columns.

                      -
                      +
                       
                       septic_patients %>% select(amox, cipr) %>% count_IR()
                       # which is the same as:
                      @@ -1945,12 +1970,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       
                    • Added longest en shortest character length in the frequency table (freq) header of class character

                    • Support for types (classes) list and matrix for freq

                      -
                      +
                       
                       my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2))
                       freq(my_matrix)

                      For lists, subsetting is possible:

                      -
                      +
                       
                       my_list = list(age = septic_patients$age, gender = septic_patients$gender)
                       my_list %>% freq(age)
                      diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
                      index 5425fb28..0e909f4f 100644
                      --- a/docs/pkgdown.yml
                      +++ b/docs/pkgdown.yml
                      @@ -12,7 +12,7 @@ articles:
                         datasets: datasets.html
                         resistance_predict: resistance_predict.html
                         welcome_to_AMR: welcome_to_AMR.html
                      -last_built: 2021-05-18T08:50Z
                      +last_built: 2021-05-19T20:49Z
                       urls:
                         reference: https://msberends.github.io/AMR//reference
                         article: https://msberends.github.io/AMR//articles
                      diff --git a/docs/reference/AMR-deprecated.html b/docs/reference/AMR-deprecated.html
                      index f45a38c1..dc8c8f56 100644
                      --- a/docs/reference/AMR-deprecated.html
                      +++ b/docs/reference/AMR-deprecated.html
                      @@ -82,7 +82,7 @@
                             
                             
                               AMR (for R)
                      -        1.6.0.9015
                      +        1.6.0.9048
                             
                           
                      @@ -239,7 +239,7 @@
                      -

                      These functions are so-called 'Deprecated'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).

                      +

                      These functions are so-called 'Deprecated'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).

                      p_symbol(p, emptychar = " ")
                      @@ -286,9 +286,141 @@
                         info = FALSE,
                         na.rm = TRUE,
                         ...
                      +)
                      +
                      +filter_ab_class(
                      +  x,
                      +  ab_class,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_aminoglycosides(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_betalactams(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_carbapenems(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_cephalosporins(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_1st_cephalosporins(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_2nd_cephalosporins(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_3rd_cephalosporins(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_4th_cephalosporins(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_5th_cephalosporins(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_fluoroquinolones(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_glycopeptides(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_macrolides(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_oxazolidinones(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_penicillins(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                      +)
                      +
                      +filter_tetracyclines(
                      +  x,
                      +  result = NULL,
                      +  scope = "any",
                      +  only_rsi_columns = FALSE,
                      +  ...
                       )
                      +

                      Details

                      + +

                      All antibiotic class selectors (such as carbapenems(), aminoglycosides()) can now be used for filtering as well, making all their accompanying filter_*() functions redundant (such as filter_carbapenems(), filter_aminoglycosides()).

                      Retired Lifecycle

                      diff --git a/docs/reference/antibiotic_class_selectors.html b/docs/reference/antibiotic_class_selectors.html index d10e08db..11df6fee 100644 --- a/docs/reference/antibiotic_class_selectors.html +++ b/docs/reference/antibiotic_class_selectors.html @@ -49,7 +49,7 @@ - @@ -83,7 +83,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048
                      @@ -240,7 +240,7 @@
                    • -

                      These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. +

                      These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.

                      @@ -293,7 +293,8 @@

                      -

                      All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the antibiotics data set. This means that a selector like e.g. aminoglycosides() will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.

                      +

                      These functions can be used in data set calls for selecting columns and filtering rows, see Examples. They support base R, but work more convenient in dplyr functions such as select(), filter() and summarise().

                      +

                      All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) in the antibiotics data set. This means that a selector like e.g. aminoglycosides() will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.

                      The group of betalactams consists of all carbapenems, cephalosporins and penicillins.

                      Stable Lifecycle

                      @@ -312,19 +313,36 @@ The lifecycle of this function is stableOn our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR data analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

                      -

                      See also

                      - -

                      filter_ab_class() for the filter() equivalent.

                      Examples

                      # `example_isolates` is a data set available in the AMR package.
                       # See ?example_isolates.
                       
                      -# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
                      +# Base R ------------------------------------------------------------------
                      +
                      +# select columns 'IPM' (imipenem) and 'MEM' (meropenem)
                       example_isolates[, carbapenems()]
                      -# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
                      +
                      +# select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
                       example_isolates[, c("mo", aminoglycosides())]
                       
                      +# filter using any() or all()
                      +example_isolates[any(carbapenems() == "R"), ]
                      +subset(example_isolates, any(carbapenems() == "R"))
                      +
                      +# filter on any or all results in the carbapenem columns (i.e., IPM, MEM):
                      +example_isolates[any(carbapenems()), ]
                      +example_isolates[all(carbapenems()), ]
                      +
                      +# filter with multiple antibiotic selectors using c()
                      +example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]
                      +
                      +# filter + select in one go: get penicillins in carbapenems-resistant strains
                      +example_isolates[any(carbapenems() == "R"), penicillins()]
                      +
                      +
                      +# dplyr -------------------------------------------------------------------
                      +
                       if (require("dplyr")) {
                       
                         # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
                      @@ -335,6 +353,20 @@ The lifecycle of this function is stableexample_isolates %>% 
                           select(mo, aminoglycosides())
                           
                      + # any() and all() work in dplyr's filter() too:
                      + example_isolates %>% 
                      +    filter(any(aminoglycosides() == "R"),
                      +           all(cephalosporins_2nd() == "R"))
                      +    
                      + # also works with c():
                      + example_isolates %>% 
                      +    filter(any(c(carbapenems(), aminoglycosides()) == "R"))
                      +    
                      + # not setting any/all will automatically apply all():
                      + example_isolates %>% 
                      +    filter(aminoglycosides() == "R")
                      + #> i Assuming a filter on all 4 aminoglycosides.
                      +    
                         # this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
                         example_isolates %>% 
                           select(mo, ab_class("mycobact"))
                      @@ -353,10 +385,11 @@ The lifecycle of this function is stableselect(penicillins())         # only the 'J01CA01' column will be selected
                           
                           
                      -  # with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
                      +  # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal:
                         # (though the row names on the first are more correct)
                      -  example_isolates %>% filter_carbapenems("R", "all")
                      -  example_isolates %>% filter(across(carbapenems(), ~. == "R"))
                      +  example_isolates[carbapenems() == "R", ]
                      +  example_isolates %>% filter(carbapenems() == "R")
                      +  example_isolates %>% filter(across(carbapenems(), ~.x == "R"))
                       }
                       
                      diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index acae8db0..50addaa8 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied AMR (for R) - 1.6.0.9021 + 1.6.0.9048
                    • @@ -363,8 +363,8 @@ Leclercq et al. EUCAST expert rules in antimicrobial susceptibility test

                      To define antibiotics column names, leave as it is to determine it automatically with guess_ab_col() or input a text (case-insensitive), or use NULL to skip a column (e.g. TIC = NULL to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning.

                      -

                      The following antibiotics are used for the functions eucast_rules() and mdro(). These are shown below in the format 'name (antimicrobial ID, ATC code)', sorted alphabetically:

                      -

                      Amikacin (AMK, J01GB06), amoxicillin (AMX, J01CA04), amoxicillin/clavulanic acid (AMC, J01CR02), ampicillin (AMP, J01CA01), ampicillin/sulbactam (SAM, J01CR01), apalcillin (APL, no ATC code), aspoxicillin (APX, no ATC code), avibactam (AVB, no ATC code), avoparcin (AVO, no ATC code), azidocillin (AZD, J01CE04), azithromycin (AZM, J01FA10), azlocillin (AZL, J01CA09), aztreonam (ATM, J01DF01), bacampicillin (BAM, J01CA06), benzylpenicillin (PEN, J01CE01), cadazolid (CDZ, J01DD09), carbenicillin (CRB, J01CA03), carindacillin (CRN, J01CA05), cefacetrile (CAC, J01DB10), cefaclor (CEC, J01DC04), cefadroxil (CFR, J01DB05), cefaloridine (RID, J01DB02), cefamandole (MAN, J01DC03), cefatrizine (CTZ, J01DB07), cefazedone (CZD, J01DB06), cefazolin (CZO, J01DB04), cefcapene (CCP, no ATC code), cefcapene pivoxil (CCX, no ATC code), cefdinir (CDR, J01DD15), cefditoren (DIT, J01DD16), cefditoren pivoxil (DIX, no ATC code), cefepime (FEP, J01DE01), cefetamet (CAT, J01DD10), cefetamet pivoxil (CPI, no ATC code), cefixime (CFM, J01DD08), cefmenoxime (CMX, J01DD05), cefmetazole (CMZ, J01DC09), cefodizime (DIZ, J01DD09), cefonicid (CID, J01DC06), cefoperazone (CFP, J01DD12), cefoperazone/sulbactam (CSL, J01DD62), ceforanide (CND, J01DC11), cefotaxime (CTX, J01DD01), cefotaxime/clavulanic acid (CTC, no ATC code), cefotaxime/sulbactam (CTS, no ATC code), cefotetan (CTT, J01DC05), cefotiam (CTF, J01DC07), cefotiam hexetil (CHE, no ATC code), cefovecin (FOV, no ATC code), cefoxitin (FOX, J01DC01), cefoxitin screening (FOX1, no ATC code), cefpimizole (CFZ, no ATC code), cefpiramide (CPM, J01DD11), cefpirome (CPO, J01DE02), cefpodoxime (CPD, J01DD13), cefpodoxime proxetil (CPX, no ATC code), cefpodoxime/clavulanic acid (CDC, no ATC code), cefprozil (CPR, J01DC10), cefroxadine (CRD, J01DB11), cefsulodin (CFS, J01DD03), ceftaroline (CPT, J01DI02), ceftazidime (CAZ, J01DD02), ceftazidime/avibactam (CZA, J01DD52), ceftazidime/clavulanic acid (CCV, J01DD52), cefteram (CEM, no ATC code), cefteram pivoxil (CPL, no ATC code), ceftezole (CTL, J01DB12), ceftibuten (CTB, J01DD14), ceftiofur (TIO, no ATC code), ceftizoxime (CZX, J01DD07), ceftizoxime alapivoxil (CZP, no ATC code), ceftobiprole (BPR, J01DI01), ceftobiprole medocaril (CFM1, J01DI01), ceftolozane/enzyme inhibitor (CEI, J01DI54), ceftriaxone (CRO, J01DD04), cefuroxime (CXM, J01DC02), cephalexin (LEX, J01DB01), cephalothin (CEP, J01DB03), cephapirin (HAP, J01DB08), cephradine (CED, J01DB09), chloramphenicol (CHL, J01BA01), ciclacillin (CIC, no ATC code), ciprofloxacin (CIP, J01MA02), clarithromycin (CLR, J01FA09), clindamycin (CLI, J01FF01), clometocillin (CLM, J01CE07), cloxacillin (CLO, J01CF02), colistin (COL, J01XB01), cycloserine (CYC, J04AB01), dalbavancin (DAL, J01XA04), daptomycin (DAP, J01XX09), dibekacin (DKB, J01GB09), dicloxacillin (DIC, J01CF01), dirithromycin (DIR, J01FA13), doripenem (DOR, J01DH04), doxycycline (DOX, J01AA02), enoxacin (ENX, J01MA04), epicillin (EPC, J01CA07), ertapenem (ETP, J01DH03), erythromycin (ERY, J01FA01), fleroxacin (FLE, J01MA08), flucloxacillin (FLC, J01CF05), flurithromycin (FLR1, J01FA14), fosfomycin (FOS, J01XX01), fusidic acid (FUS, J01XC01), gatifloxacin (GAT, J01MA16), gemifloxacin (GEM, J01MA15), gentamicin (GEN, J01GB03), grepafloxacin (GRX, J01MA11), hetacillin (HET, J01CA18), imipenem (IPM, J01DH51), isepamicin (ISE, J01GB11), josamycin (JOS, J01FA07), kanamycin (KAN, J01GB04), latamoxef (LTM, J01DD06), lenampicillin (LEN, no ATC code), levofloxacin (LVX, J01MA12), lincomycin (LIN, J01FF02), linezolid (LNZ, J01XX08), lomefloxacin (LOM, J01MA07), loracarbef (LOR, J01DC08), mecillinam (Amdinocillin) (MEC, J01CA11), meropenem (MEM, J01DH02), meropenem/vaborbactam (MEV, J01DH52), metampicillin (MTM, J01CA14), methicillin (MET, J01CF03), mezlocillin (MEZ, J01CA10), midecamycin (MID, J01FA03), minocycline (MNO, J01AA08), miocamycin (MCM, J01FA11), moxifloxacin (MFX, J01MA14), nacubactam (NAC, no ATC code), nafcillin (NAF, no ATC code), nalidixic acid (NAL, J01MB02), neomycin (NEO, J01GB05), netilmicin (NET, J01GB07), nitrofurantoin (NIT, J01XE01), norfloxacin (NOR, J01MA06), norvancomycin (NVA, no ATC code), novobiocin (NOV, QJ01XX95), ofloxacin (OFX, J01MA01), oleandomycin (OLE, J01FA05), oritavancin (ORI, J01XA05), oxacillin (OXA, J01CF04), pazufloxacin (PAZ, J01MA18), pefloxacin (PEF, J01MA03), penamecillin (PNM, J01CE06), phenethicillin (PHE, J01CE05), phenoxymethylpenicillin (PHN, J01CE02), piperacillin (PIP, J01CA12), piperacillin/tazobactam (TZP, J01CR05), piridicillin (PRC, no ATC code), pirlimycin (PRL, no ATC code), pivampicillin (PVM, J01CA02), pivmecillinam (PME, J01CA08), polymyxin B (PLB, J01XB02), pristinamycin (PRI, J01FG01), propicillin (PRP, J01CE03), prulifloxacin (PRU, J01MA17), quinupristin/dalfopristin (QDA, J01FG02), ramoplanin (RAM, no ATC code), ribostamycin (RST, J01GB10), rifampicin (RIF, J04AB02), rokitamycin (ROK, J01FA12), roxithromycin (RXT, J01FA06), rufloxacin (RFL, J01MA10), sarmoxicillin (SRX, no ATC code), sisomicin (SIS, J01GB08), sparfloxacin (SPX, J01MA09), spiramycin (SPI, J01FA02), streptoduocin (STR, J01GA02), streptomycin (STR1, J01GA01), sulbactam (SUL, J01CG01), sulbenicillin (SBC, J01CA16), sulfadiazine (SDI, J01EC02), sulfadiazine/trimethoprim (SLT1, J01EE02), sulfadimethoxine (SUD, J01ED01), sulfadimidine (SDM, J01EB03), sulfadimidine/trimethoprim (SLT2, J01EE05), sulfafurazole (SLF, J01EB05), sulfaisodimidine (SLF1, J01EB01), sulfalene (SLF2, J01ED02), sulfamazone (SZO, J01ED09), sulfamerazine (SLF3, J01ED07), sulfamerazine/trimethoprim (SLT3, J01EE07), sulfamethizole (SLF4, J01EB02), sulfamethoxazole (SMX, J01EC01), sulfamethoxypyridazine (SLF5, J01ED05), sulfametomidine (SLF6, J01ED03), sulfametoxydiazine (SLF7, J01ED04), sulfametrole/trimethoprim (SLT4, J01EE03), sulfamoxole (SLF8, J01EC03), sulfamoxole/trimethoprim (SLT5, J01EE04), sulfanilamide (SLF9, J01EB06), sulfaperin (SLF10, J01ED06), sulfaphenazole (SLF11, J01ED08), sulfapyridine (SLF12, J01EB04), sulfathiazole (SUT, J01EB07), sulfathiourea (SLF13, J01EB08), sultamicillin (SLT6, J01CR04), talampicillin (TAL, J01CA15), tazobactam (TAZ, J01CG02), tedizolid (TZD, J01XX11), teicoplanin (TEC, J01XA02), teicoplanin-macromethod (TCM, no ATC code), telavancin (TLV, J01XA03), telithromycin (TLT, J01FA15), temafloxacin (TMX, J01MA05), temocillin (TEM, J01CA17), tetracycline (TCY, J01AA07), thiacetazone (THA, no ATC code), ticarcillin (TIC, J01CA13), ticarcillin/clavulanic acid (TCC, J01CR03), tigecycline (TGC, J01AA12), tobramycin (TOB, J01GB01), trimethoprim (TMP, J01EA01), trimethoprim/sulfamethoxazole (SXT, J01EE01), troleandomycin (TRL, J01FA08), trovafloxacin (TVA, J01MA13), vancomycin (VAN, J01XA01)

                      +

                      The following antibiotics are eligible for the functions eucast_rules() and mdro(). These are shown below in the format 'name (antimicrobial ID, ATC code)', sorted alphabetically:

                      +

                      Amikacin (AMK, J01MA02), amoxicillin (AMX, J01MA04), amoxicillin/clavulanic acid (AMC, J01MA08), ampicillin (AMP, J01MA16), ampicillin/sulbactam (SAM, J01MA15), azidocillin (AZD, J01MA11), azithromycin (AZM, J01MA12), azlocillin (AZL, J01MA07), aztreonam (ATM, J01MA14), bacampicillin (BAM, J01MA06), benzathine benzylpenicillin (BNB, J01MA01), benzathine phenoxymethylpenicillin (BNP, J01MA18), benzylpenicillin (PEN, J01MA03), cadazolid (CDZ, J01MA17), carbenicillin (CRB, J01MA10), carindacillin (CRN, J01MA09), cefacetrile (CAC, J01MA05), cefaclor (CEC, J01MA13), cefadroxil (CFR, J01CA01), cefaloridine (RID, J01CA04), cefamandole (MAN, J01CA12), cefatrizine (CTZ, J01CR05), cefazedone (CZD, J01CA13), cefazolin (CZO, J01AA02), cefdinir (CDR, J01FA10), cefditoren (DIT, J01FA09), cefepime (FEP, J01CR02), cefetamet (CAT, J01AA08), cefixime (CFM, J01FA06), cefmenoxime (CMX, J01CF04), cefmetazole (CMZ, J01CF05), cefodizime (DIZ, J01CR01), cefonicid (CID, J01CE04), cefoperazone (CFP, J01CA09), cefoperazone/sulbactam (CSL, J01DF01), ceforanide (CND, J01CA06), cefotaxime (CTX, J01CE08), cefotetan (CTT, J01CE10), cefotiam (CTF, J01CE01), cefoxitin (FOX, J01CA03), cefpiramide (CPM, J01CA05), cefpirome (CPO, J01CE07), cefpodoxime (CPD, J01CF02), cefprozil (CPR, J01CF01), cefroxadine (CRD, J01CA07), cefsulodin (CFS, J01CA18), ceftaroline (CPT, J01CA11), ceftazidime (CAZ, J01CA14), ceftazidime/avibactam (CZA, J01CF03), ceftazidime/clavulanic acid (CCV, J01CA10), ceftezole (CTL, J01CE06), ceftibuten (CTB, J01CE05), ceftizoxime (CZX, J01CE02), ceftobiprole (BPR, J01CA02), ceftobiprole medocaril (CFM1, J01CA08), ceftolozane/enzyme inhibitor (CEI, J01CE09), ceftriaxone (CRO, J01CE03), cefuroxime (CXM, J01CG01), cephalexin (LEX, J01CA16), cephalothin (CEP, J01CR04), cephapirin (HAP, J01CA15), cephradine (CED, J01CG02), chloramphenicol (CHL, J01CA17), ciprofloxacin (CIP, J01CR03), clarithromycin (CLR, J01DD09), clindamycin (CLI, J01DB10), clometocillin (CLM, J01DC04), cloxacillin (CLO, J01DB05), colistin (COL, J01DB02), cycloserine (CYC, J01DC03), dalbavancin (DAL, J01DB07), daptomycin (DAP, J01DB06), dibekacin (DKB, J01DB04), dicloxacillin (DIC, J01DD15), dirithromycin (DIR, J01DD16), doripenem (DOR, J01DE01), doxycycline (DOX, J01DD10), enoxacin (ENX, J01DD08), epicillin (EPC, J01DD05), ertapenem (ETP, J01DC09), erythromycin (ERY, J01DD09), fleroxacin (FLE, J01DC06), flucloxacillin (FLC, J01DD12), flurithromycin (FLR1, J01DD62), fosfomycin (FOS, J01DC11), fusidic acid (FUS, J01DD01), gatifloxacin (GAT, J01DC05), gemifloxacin (GEM, J01DC07), gentamicin (GEN, J01DC01), grepafloxacin (GRX, J01DD11), hetacillin (HET, J01DE02), imipenem (IPM, J01DD13), isepamicin (ISE, J01DC10), josamycin (JOS, J01DB11), kanamycin (KAN, J01DD03), latamoxef (LTM, J01DI02), levofloxacin (LVX, J01DD02), lincomycin (LIN, J01DD52), linezolid (LNZ, J01DD52), lomefloxacin (LOM, J01DB12), loracarbef (LOR, J01DD14), mecillinam (Amdinocillin) (MEC, J01DD07), meropenem (MEM, J01DI01), meropenem/vaborbactam (MEV, J01DI01), metampicillin (MTM, J01DI54), methicillin (MET, J01DD04), mezlocillin (MEZ, J01DC02), midecamycin (MID, J01DB01), minocycline (MNO, J01DB03), miocamycin (MCM, J01DB08), moxifloxacin (MFX, J01DB09), nalidixic acid (NAL, J01DD06), neomycin (NEO, J01DC08), netilmicin (NET, J01DH04), nitrofurantoin (NIT, J01DH03), norfloxacin (NOR, J01DH51), novobiocin (NOV, J01DH02), ofloxacin (OFX, J01DH52), oleandomycin (OLE, J01XA02), oritavancin (ORI, J01XA01), oxacillin (OXA, J01XC01), pazufloxacin (PAZ, J01FA13), pefloxacin (PEF, J01FA01), penamecillin (PNM, J01FA14), phenethicillin (PHE, J01FA07), phenoxymethylpenicillin (PHN, J01FA03), piperacillin (PIP, J01FA11), piperacillin/tazobactam (TZP, J01FA05), pivampicillin (PVM, J01FA12), pivmecillinam (PME, J01FA02), polymyxin B (PLB, J01FA15), pristinamycin (PRI, J01FA08), procaine benzylpenicillin (PRB, J01FF02), propicillin (PRP, J01FG01), prulifloxacin (PRU, J01FG02), quinupristin/dalfopristin (QDA, J04AB02), ribostamycin (RST, J01XX09), rifampicin (RIF, J01XX08), rokitamycin (ROK, J01AA07), roxithromycin (RXT, J01XB01), rufloxacin (RFL, J01XB02), sisomicin (SIS, J01XE01), sparfloxacin (SPX, J01AA12), spiramycin (SPI, J01EA01), streptoduocin (STR, J01XX01), streptomycin (STR1, J01BA01), sulbactam (SUL, J01GB06), sulbenicillin (SBC, J01GB09), sulfadiazine (SDI, J01GB03), sulfadiazine/trimethoprim (SLT1, J01GB11), sulfadimethoxine (SUD, J01GB04), sulfadimidine (SDM, J01GB05), sulfadimidine/trimethoprim (SLT2, J01GB07), sulfafurazole (SLF, J01GB10), sulfaisodimidine (SLF1, J01GB08), sulfalene (SLF2, J01GA02), sulfamazone (SZO, J01GA01), sulfamerazine (SLF3, J01GB01), sulfamerazine/trimethoprim (SLT3, J01EE01), sulfamethizole (SLF4, J01MB02), sulfamethoxazole (SMX, QJ01XX95), sulfamethoxypyridazine (SLF5, J01FF01), sulfametomidine (SLF6, J01XA04), sulfametoxydiazine (SLF7, J01XA05), sulfametrole/trimethoprim (SLT4, J01XA03), sulfamoxole (SLF8, J04AB01), sulfamoxole/trimethoprim (SLT5, J01XX11), sulfanilamide (SLF9, J01EC02), sulfaperin (SLF10, J01ED01), sulfaphenazole (SLF11, J01EB03), sulfapyridine (SLF12, J01EB05), sulfathiazole (SUT, J01EB01), sulfathiourea (SLF13, J01ED02), sultamicillin (SLT6, J01ED09), talampicillin (TAL, J01ED07), tazobactam (TAZ, J01EB02), tedizolid (TZD, J01EC01), teicoplanin (TEC, J01ED05), telavancin (TLV, J01ED03), telithromycin (TLT, J01ED04), temafloxacin (TMX, J01EC03), temocillin (TEM, J01EB06), tetracycline (TCY, J01ED06), ticarcillin (TIC, J01ED08), ticarcillin/clavulanic acid (TCC, J01EB04), tigecycline (TGC, J01EB07), tobramycin (TOB, J01EB08), trimethoprim (TMP, J01EE02), trimethoprim/sulfamethoxazole (SXT, J01EE05), troleandomycin (TRL, J01EE07), trovafloxacin (TVA, J01EE03), vancomycin (VAN, J01EE04)

                      Stable Lifecycle

                      diff --git a/docs/reference/index.html b/docs/reference/index.html index 22d64988..8040ea33 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048
                      @@ -461,7 +461,7 @@

                      Analysing data: antimicrobial resistance

                      -

                      Use these function for the analysis part. You can use susceptibility() or resistance() on any antibiotic column. Be sure to first select the isolates that are appropiate for analysis, by using first_isolate() or is_new_episode(). You can also filter your data on certain resistance in certain antibiotic classes (filter_ab_class()), or determine multi-drug resistant microorganisms (MDRO, mdro()).

                      +

                      Use these function for the analysis part. You can use susceptibility() or resistance() on any antibiotic column. Be sure to first select the isolates that are appropiate for analysis, by using first_isolate() or is_new_episode(). You can also filter your data on certain resistance in certain antibiotic classes (filter_ab_class()), or determine multi-drug resistant microorganisms (MDRO, mdro()).

                      @@ -532,9 +532,9 @@ -

                      filter_ab_class() filter_aminoglycosides() filter_betalactams() filter_carbapenems() filter_cephalosporins() filter_1st_cephalosporins() filter_2nd_cephalosporins() filter_3rd_cephalosporins() filter_4th_cephalosporins() filter_5th_cephalosporins() filter_fluoroquinolones() filter_glycopeptides() filter_macrolides() filter_oxazolidinones() filter_penicillins() filter_tetracyclines()

                      +

                      p_symbol() filter_first_weighted_isolate() key_antibiotics() key_antibiotics_equal() filter_ab_class() filter_aminoglycosides() filter_betalactams() filter_carbapenems() filter_cephalosporins() filter_1st_cephalosporins() filter_2nd_cephalosporins() filter_3rd_cephalosporins() filter_4th_cephalosporins() filter_5th_cephalosporins() filter_fluoroquinolones() filter_glycopeptides() filter_macrolides() filter_oxazolidinones() filter_penicillins() filter_tetracyclines()

                      -

                      Filter Isolates on Result in Antimicrobial Class

                      +

                      Deprecated Functions

                      @@ -673,7 +673,7 @@ -

                      p_symbol() filter_first_weighted_isolate() key_antibiotics() key_antibiotics_equal()

                      +

                      p_symbol() filter_first_weighted_isolate() key_antibiotics() key_antibiotics_equal() filter_ab_class() filter_aminoglycosides() filter_betalactams() filter_carbapenems() filter_cephalosporins() filter_1st_cephalosporins() filter_2nd_cephalosporins() filter_3rd_cephalosporins() filter_4th_cephalosporins() filter_5th_cephalosporins() filter_fluoroquinolones() filter_glycopeptides() filter_macrolides() filter_oxazolidinones() filter_penicillins() filter_tetracyclines()

                      Deprecated Functions

                      diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index 5c7e45e0..defa2cd8 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -82,7 +82,7 @@ AMR (for R) - 1.6.0.9044 + 1.6.0.9048
                    • @@ -402,8 +402,8 @@ The lifecycle of this function is stableTo define antibiotics column names, leave as it is to determine it automatically with guess_ab_col() or input a text (case-insensitive), or use NULL to skip a column (e.g. TIC = NULL to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning.

                      -

                      The following antibiotics are used for the functions eucast_rules() and mdro(). These are shown below in the format 'name (antimicrobial ID, ATC code)', sorted alphabetically:

                      -

                      Amikacin (AMK, J01GB06), amoxicillin (AMX, J01CA04), amoxicillin/clavulanic acid (AMC, J01CR02), ampicillin (AMP, J01CA01), ampicillin/sulbactam (SAM, J01CR01), apalcillin (APL, no ATC code), aspoxicillin (APX, no ATC code), avibactam (AVB, no ATC code), avoparcin (AVO, no ATC code), azidocillin (AZD, J01CE04), azithromycin (AZM, J01FA10), azlocillin (AZL, J01CA09), aztreonam (ATM, J01DF01), bacampicillin (BAM, J01CA06), benzylpenicillin (PEN, J01CE01), cadazolid (CDZ, J01DD09), carbenicillin (CRB, J01CA03), carindacillin (CRN, J01CA05), cefacetrile (CAC, J01DB10), cefaclor (CEC, J01DC04), cefadroxil (CFR, J01DB05), cefaloridine (RID, J01DB02), cefamandole (MAN, J01DC03), cefatrizine (CTZ, J01DB07), cefazedone (CZD, J01DB06), cefazolin (CZO, J01DB04), cefcapene (CCP, no ATC code), cefcapene pivoxil (CCX, no ATC code), cefdinir (CDR, J01DD15), cefditoren (DIT, J01DD16), cefditoren pivoxil (DIX, no ATC code), cefepime (FEP, J01DE01), cefetamet (CAT, J01DD10), cefetamet pivoxil (CPI, no ATC code), cefixime (CFM, J01DD08), cefmenoxime (CMX, J01DD05), cefmetazole (CMZ, J01DC09), cefodizime (DIZ, J01DD09), cefonicid (CID, J01DC06), cefoperazone (CFP, J01DD12), cefoperazone/sulbactam (CSL, J01DD62), ceforanide (CND, J01DC11), cefotaxime (CTX, J01DD01), cefotaxime/clavulanic acid (CTC, no ATC code), cefotaxime/sulbactam (CTS, no ATC code), cefotetan (CTT, J01DC05), cefotiam (CTF, J01DC07), cefotiam hexetil (CHE, no ATC code), cefovecin (FOV, no ATC code), cefoxitin (FOX, J01DC01), cefoxitin screening (FOX1, no ATC code), cefpimizole (CFZ, no ATC code), cefpiramide (CPM, J01DD11), cefpirome (CPO, J01DE02), cefpodoxime (CPD, J01DD13), cefpodoxime proxetil (CPX, no ATC code), cefpodoxime/clavulanic acid (CDC, no ATC code), cefprozil (CPR, J01DC10), cefroxadine (CRD, J01DB11), cefsulodin (CFS, J01DD03), ceftaroline (CPT, J01DI02), ceftazidime (CAZ, J01DD02), ceftazidime/avibactam (CZA, J01DD52), ceftazidime/clavulanic acid (CCV, J01DD52), cefteram (CEM, no ATC code), cefteram pivoxil (CPL, no ATC code), ceftezole (CTL, J01DB12), ceftibuten (CTB, J01DD14), ceftiofur (TIO, no ATC code), ceftizoxime (CZX, J01DD07), ceftizoxime alapivoxil (CZP, no ATC code), ceftobiprole (BPR, J01DI01), ceftobiprole medocaril (CFM1, J01DI01), ceftolozane/enzyme inhibitor (CEI, J01DI54), ceftriaxone (CRO, J01DD04), cefuroxime (CXM, J01DC02), cephalexin (LEX, J01DB01), cephalothin (CEP, J01DB03), cephapirin (HAP, J01DB08), cephradine (CED, J01DB09), chloramphenicol (CHL, J01BA01), ciclacillin (CIC, no ATC code), ciprofloxacin (CIP, J01MA02), clarithromycin (CLR, J01FA09), clindamycin (CLI, J01FF01), clometocillin (CLM, J01CE07), cloxacillin (CLO, J01CF02), colistin (COL, J01XB01), cycloserine (CYC, J04AB01), dalbavancin (DAL, J01XA04), daptomycin (DAP, J01XX09), dibekacin (DKB, J01GB09), dicloxacillin (DIC, J01CF01), dirithromycin (DIR, J01FA13), doripenem (DOR, J01DH04), doxycycline (DOX, J01AA02), enoxacin (ENX, J01MA04), epicillin (EPC, J01CA07), ertapenem (ETP, J01DH03), erythromycin (ERY, J01FA01), fleroxacin (FLE, J01MA08), flucloxacillin (FLC, J01CF05), flurithromycin (FLR1, J01FA14), fosfomycin (FOS, J01XX01), fusidic acid (FUS, J01XC01), gatifloxacin (GAT, J01MA16), gemifloxacin (GEM, J01MA15), gentamicin (GEN, J01GB03), grepafloxacin (GRX, J01MA11), hetacillin (HET, J01CA18), imipenem (IPM, J01DH51), isepamicin (ISE, J01GB11), josamycin (JOS, J01FA07), kanamycin (KAN, J01GB04), latamoxef (LTM, J01DD06), lenampicillin (LEN, no ATC code), levofloxacin (LVX, J01MA12), lincomycin (LIN, J01FF02), linezolid (LNZ, J01XX08), lomefloxacin (LOM, J01MA07), loracarbef (LOR, J01DC08), mecillinam (Amdinocillin) (MEC, J01CA11), meropenem (MEM, J01DH02), meropenem/vaborbactam (MEV, J01DH52), metampicillin (MTM, J01CA14), methicillin (MET, J01CF03), mezlocillin (MEZ, J01CA10), midecamycin (MID, J01FA03), minocycline (MNO, J01AA08), miocamycin (MCM, J01FA11), moxifloxacin (MFX, J01MA14), nacubactam (NAC, no ATC code), nafcillin (NAF, no ATC code), nalidixic acid (NAL, J01MB02), neomycin (NEO, J01GB05), netilmicin (NET, J01GB07), nitrofurantoin (NIT, J01XE01), norfloxacin (NOR, J01MA06), norvancomycin (NVA, no ATC code), novobiocin (NOV, QJ01XX95), ofloxacin (OFX, J01MA01), oleandomycin (OLE, J01FA05), oritavancin (ORI, J01XA05), oxacillin (OXA, J01CF04), pazufloxacin (PAZ, J01MA18), pefloxacin (PEF, J01MA03), penamecillin (PNM, J01CE06), phenethicillin (PHE, J01CE05), phenoxymethylpenicillin (PHN, J01CE02), piperacillin (PIP, J01CA12), piperacillin/tazobactam (TZP, J01CR05), piridicillin (PRC, no ATC code), pirlimycin (PRL, no ATC code), pivampicillin (PVM, J01CA02), pivmecillinam (PME, J01CA08), polymyxin B (PLB, J01XB02), pristinamycin (PRI, J01FG01), propicillin (PRP, J01CE03), prulifloxacin (PRU, J01MA17), quinupristin/dalfopristin (QDA, J01FG02), ramoplanin (RAM, no ATC code), ribostamycin (RST, J01GB10), rifampicin (RIF, J04AB02), rokitamycin (ROK, J01FA12), roxithromycin (RXT, J01FA06), rufloxacin (RFL, J01MA10), sarmoxicillin (SRX, no ATC code), sisomicin (SIS, J01GB08), sparfloxacin (SPX, J01MA09), spiramycin (SPI, J01FA02), streptoduocin (STR, J01GA02), streptomycin (STR1, J01GA01), sulbactam (SUL, J01CG01), sulbenicillin (SBC, J01CA16), sulfadiazine (SDI, J01EC02), sulfadiazine/trimethoprim (SLT1, J01EE02), sulfadimethoxine (SUD, J01ED01), sulfadimidine (SDM, J01EB03), sulfadimidine/trimethoprim (SLT2, J01EE05), sulfafurazole (SLF, J01EB05), sulfaisodimidine (SLF1, J01EB01), sulfalene (SLF2, J01ED02), sulfamazone (SZO, J01ED09), sulfamerazine (SLF3, J01ED07), sulfamerazine/trimethoprim (SLT3, J01EE07), sulfamethizole (SLF4, J01EB02), sulfamethoxazole (SMX, J01EC01), sulfamethoxypyridazine (SLF5, J01ED05), sulfametomidine (SLF6, J01ED03), sulfametoxydiazine (SLF7, J01ED04), sulfametrole/trimethoprim (SLT4, J01EE03), sulfamoxole (SLF8, J01EC03), sulfamoxole/trimethoprim (SLT5, J01EE04), sulfanilamide (SLF9, J01EB06), sulfaperin (SLF10, J01ED06), sulfaphenazole (SLF11, J01ED08), sulfapyridine (SLF12, J01EB04), sulfathiazole (SUT, J01EB07), sulfathiourea (SLF13, J01EB08), sultamicillin (SLT6, J01CR04), talampicillin (TAL, J01CA15), tazobactam (TAZ, J01CG02), tedizolid (TZD, J01XX11), teicoplanin (TEC, J01XA02), teicoplanin-macromethod (TCM, no ATC code), telavancin (TLV, J01XA03), telithromycin (TLT, J01FA15), temafloxacin (TMX, J01MA05), temocillin (TEM, J01CA17), tetracycline (TCY, J01AA07), thiacetazone (THA, no ATC code), ticarcillin (TIC, J01CA13), ticarcillin/clavulanic acid (TCC, J01CR03), tigecycline (TGC, J01AA12), tobramycin (TOB, J01GB01), trimethoprim (TMP, J01EA01), trimethoprim/sulfamethoxazole (SXT, J01EE01), troleandomycin (TRL, J01FA08), trovafloxacin (TVA, J01MA13), vancomycin (VAN, J01XA01)

                      +

                      The following antibiotics are eligible for the functions eucast_rules() and mdro(). These are shown below in the format 'name (antimicrobial ID, ATC code)', sorted alphabetically:

                      +

                      Amikacin (AMK, J01MA02), amoxicillin (AMX, J01MA04), amoxicillin/clavulanic acid (AMC, J01MA08), ampicillin (AMP, J01MA16), ampicillin/sulbactam (SAM, J01MA15), azidocillin (AZD, J01MA11), azithromycin (AZM, J01MA12), azlocillin (AZL, J01MA07), aztreonam (ATM, J01MA14), bacampicillin (BAM, J01MA06), benzathine benzylpenicillin (BNB, J01MA01), benzathine phenoxymethylpenicillin (BNP, J01MA18), benzylpenicillin (PEN, J01MA03), cadazolid (CDZ, J01MA17), carbenicillin (CRB, J01MA10), carindacillin (CRN, J01MA09), cefacetrile (CAC, J01MA05), cefaclor (CEC, J01MA13), cefadroxil (CFR, J01CA01), cefaloridine (RID, J01CA04), cefamandole (MAN, J01CA12), cefatrizine (CTZ, J01CR05), cefazedone (CZD, J01CA13), cefazolin (CZO, J01AA02), cefdinir (CDR, J01FA10), cefditoren (DIT, J01FA09), cefepime (FEP, J01CR02), cefetamet (CAT, J01AA08), cefixime (CFM, J01FA06), cefmenoxime (CMX, J01CF04), cefmetazole (CMZ, J01CF05), cefodizime (DIZ, J01CR01), cefonicid (CID, J01CE04), cefoperazone (CFP, J01CA09), cefoperazone/sulbactam (CSL, J01DF01), ceforanide (CND, J01CA06), cefotaxime (CTX, J01CE08), cefotetan (CTT, J01CE10), cefotiam (CTF, J01CE01), cefoxitin (FOX, J01CA03), cefpiramide (CPM, J01CA05), cefpirome (CPO, J01CE07), cefpodoxime (CPD, J01CF02), cefprozil (CPR, J01CF01), cefroxadine (CRD, J01CA07), cefsulodin (CFS, J01CA18), ceftaroline (CPT, J01CA11), ceftazidime (CAZ, J01CA14), ceftazidime/avibactam (CZA, J01CF03), ceftazidime/clavulanic acid (CCV, J01CA10), ceftezole (CTL, J01CE06), ceftibuten (CTB, J01CE05), ceftizoxime (CZX, J01CE02), ceftobiprole (BPR, J01CA02), ceftobiprole medocaril (CFM1, J01CA08), ceftolozane/enzyme inhibitor (CEI, J01CE09), ceftriaxone (CRO, J01CE03), cefuroxime (CXM, J01CG01), cephalexin (LEX, J01CA16), cephalothin (CEP, J01CR04), cephapirin (HAP, J01CA15), cephradine (CED, J01CG02), chloramphenicol (CHL, J01CA17), ciprofloxacin (CIP, J01CR03), clarithromycin (CLR, J01DD09), clindamycin (CLI, J01DB10), clometocillin (CLM, J01DC04), cloxacillin (CLO, J01DB05), colistin (COL, J01DB02), cycloserine (CYC, J01DC03), dalbavancin (DAL, J01DB07), daptomycin (DAP, J01DB06), dibekacin (DKB, J01DB04), dicloxacillin (DIC, J01DD15), dirithromycin (DIR, J01DD16), doripenem (DOR, J01DE01), doxycycline (DOX, J01DD10), enoxacin (ENX, J01DD08), epicillin (EPC, J01DD05), ertapenem (ETP, J01DC09), erythromycin (ERY, J01DD09), fleroxacin (FLE, J01DC06), flucloxacillin (FLC, J01DD12), flurithromycin (FLR1, J01DD62), fosfomycin (FOS, J01DC11), fusidic acid (FUS, J01DD01), gatifloxacin (GAT, J01DC05), gemifloxacin (GEM, J01DC07), gentamicin (GEN, J01DC01), grepafloxacin (GRX, J01DD11), hetacillin (HET, J01DE02), imipenem (IPM, J01DD13), isepamicin (ISE, J01DC10), josamycin (JOS, J01DB11), kanamycin (KAN, J01DD03), latamoxef (LTM, J01DI02), levofloxacin (LVX, J01DD02), lincomycin (LIN, J01DD52), linezolid (LNZ, J01DD52), lomefloxacin (LOM, J01DB12), loracarbef (LOR, J01DD14), mecillinam (Amdinocillin) (MEC, J01DD07), meropenem (MEM, J01DI01), meropenem/vaborbactam (MEV, J01DI01), metampicillin (MTM, J01DI54), methicillin (MET, J01DD04), mezlocillin (MEZ, J01DC02), midecamycin (MID, J01DB01), minocycline (MNO, J01DB03), miocamycin (MCM, J01DB08), moxifloxacin (MFX, J01DB09), nalidixic acid (NAL, J01DD06), neomycin (NEO, J01DC08), netilmicin (NET, J01DH04), nitrofurantoin (NIT, J01DH03), norfloxacin (NOR, J01DH51), novobiocin (NOV, J01DH02), ofloxacin (OFX, J01DH52), oleandomycin (OLE, J01XA02), oritavancin (ORI, J01XA01), oxacillin (OXA, J01XC01), pazufloxacin (PAZ, J01FA13), pefloxacin (PEF, J01FA01), penamecillin (PNM, J01FA14), phenethicillin (PHE, J01FA07), phenoxymethylpenicillin (PHN, J01FA03), piperacillin (PIP, J01FA11), piperacillin/tazobactam (TZP, J01FA05), pivampicillin (PVM, J01FA12), pivmecillinam (PME, J01FA02), polymyxin B (PLB, J01FA15), pristinamycin (PRI, J01FA08), procaine benzylpenicillin (PRB, J01FF02), propicillin (PRP, J01FG01), prulifloxacin (PRU, J01FG02), quinupristin/dalfopristin (QDA, J04AB02), ribostamycin (RST, J01XX09), rifampicin (RIF, J01XX08), rokitamycin (ROK, J01AA07), roxithromycin (RXT, J01XB01), rufloxacin (RFL, J01XB02), sisomicin (SIS, J01XE01), sparfloxacin (SPX, J01AA12), spiramycin (SPI, J01EA01), streptoduocin (STR, J01XX01), streptomycin (STR1, J01BA01), sulbactam (SUL, J01GB06), sulbenicillin (SBC, J01GB09), sulfadiazine (SDI, J01GB03), sulfadiazine/trimethoprim (SLT1, J01GB11), sulfadimethoxine (SUD, J01GB04), sulfadimidine (SDM, J01GB05), sulfadimidine/trimethoprim (SLT2, J01GB07), sulfafurazole (SLF, J01GB10), sulfaisodimidine (SLF1, J01GB08), sulfalene (SLF2, J01GA02), sulfamazone (SZO, J01GA01), sulfamerazine (SLF3, J01GB01), sulfamerazine/trimethoprim (SLT3, J01EE01), sulfamethizole (SLF4, J01MB02), sulfamethoxazole (SMX, QJ01XX95), sulfamethoxypyridazine (SLF5, J01FF01), sulfametomidine (SLF6, J01XA04), sulfametoxydiazine (SLF7, J01XA05), sulfametrole/trimethoprim (SLT4, J01XA03), sulfamoxole (SLF8, J04AB01), sulfamoxole/trimethoprim (SLT5, J01XX11), sulfanilamide (SLF9, J01EC02), sulfaperin (SLF10, J01ED01), sulfaphenazole (SLF11, J01EB03), sulfapyridine (SLF12, J01EB05), sulfathiazole (SUT, J01EB01), sulfathiourea (SLF13, J01ED02), sultamicillin (SLT6, J01ED09), talampicillin (TAL, J01ED07), tazobactam (TAZ, J01EB02), tedizolid (TZD, J01EC01), teicoplanin (TEC, J01ED05), telavancin (TLV, J01ED03), telithromycin (TLT, J01ED04), temafloxacin (TMX, J01EC03), temocillin (TEM, J01EB06), tetracycline (TCY, J01ED06), ticarcillin (TIC, J01ED08), ticarcillin/clavulanic acid (TCC, J01EB04), tigecycline (TGC, J01EB07), tobramycin (TOB, J01EB08), trimethoprim (TMP, J01EE02), trimethoprim/sulfamethoxazole (SXT, J01EE05), troleandomycin (TRL, J01EE07), trovafloxacin (TVA, J01EE03), vancomycin (VAN, J01EE04)

                      Interpretation of R and S/I

                      diff --git a/docs/sitemap.xml b/docs/sitemap.xml index c41c3ac7..26ef4cd7 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -81,9 +81,6 @@ https://msberends.github.io/AMR//reference/example_isolates_unclean.html - - https://msberends.github.io/AMR//reference/filter_ab_class.html - https://msberends.github.io/AMR//reference/first_isolate.html diff --git a/docs/survey.html b/docs/survey.html index 664cfb24..93891e22 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9047 + 1.6.0.9048
                      diff --git a/inst/tinytest/test-_deprecated.R b/inst/tinytest/test-_deprecated.R index 80c01cce..32cc734f 100644 --- a/inst/tinytest/test-_deprecated.R +++ b/inst/tinytest/test-_deprecated.R @@ -37,3 +37,20 @@ expect_identical(suppressWarnings(key_antibiotics_equal("S", "S")), expect_warning(filter_first_weighted_isolate(example_isolates)) expect_identical(suppressWarnings(filter_first_weighted_isolate(example_isolates)), filter_first_isolate(example_isolates)) + +expect_warning(filter_ab_class(example_isolates, "mycobact")) +expect_warning(filter_aminoglycosides(example_isolates)) +expect_warning(filter_betalactams(example_isolates)) +expect_warning(filter_carbapenems(example_isolates)) +expect_warning(filter_cephalosporins(example_isolates)) +expect_warning(filter_1st_cephalosporins(example_isolates)) +expect_warning(filter_2nd_cephalosporins(example_isolates)) +expect_warning(filter_3rd_cephalosporins(example_isolates)) +expect_warning(filter_4th_cephalosporins(example_isolates)) +expect_warning(filter_5th_cephalosporins(example_isolates)) +expect_warning(filter_fluoroquinolones(example_isolates)) +expect_warning(filter_glycopeptides(example_isolates)) +expect_warning(filter_macrolides(example_isolates)) +expect_warning(filter_oxazolidinones(example_isolates)) +expect_warning(filter_penicillins(example_isolates)) +expect_warning(filter_tetracyclines(example_isolates)) diff --git a/inst/tinytest/test-ab_class_selectors.R b/inst/tinytest/test-ab_class_selectors.R index 56317651..dc2fda42 100644 --- a/inst/tinytest/test-ab_class_selectors.R +++ b/inst/tinytest/test-ab_class_selectors.R @@ -23,7 +23,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -if (current_R_older_than(3.2)) { +if (!AMR:::current_R_older_than(3.2)) { # antibiotic class selectors require at least R-3.2 expect_true(ncol(example_isolates[, aminoglycosides(), drop = FALSE]) < ncol(example_isolates)) expect_true(ncol(example_isolates[, betalactams(), drop = FALSE]) < ncol(example_isolates)) @@ -40,4 +40,24 @@ if (current_R_older_than(3.2)) { expect_true(ncol(example_isolates[, oxazolidinones(), drop = FALSE]) < ncol(example_isolates)) expect_true(ncol(example_isolates[, penicillins(), drop = FALSE]) < ncol(example_isolates)) expect_true(ncol(example_isolates[, tetracyclines(), drop = FALSE]) < ncol(example_isolates)) + + # Examples: + + # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB' + expect_equal(ncol(example_isolates[, c("mo", aminoglycosides())]), 5) + + # filter using any() or all() + expect_equal(nrow(example_isolates[any(carbapenems() == "R"), ]), 55) + expect_equal(nrow(subset(example_isolates, any(carbapenems() == "R"))), 55) + + # filter on any or all results in the carbapenem columns (i.e., IPM, MEM): + expect_equal(nrow(example_isolates[any(carbapenems()), ]), 962) + expect_equal(nrow(example_isolates[all(carbapenems()), ]), 756) + + # filter with multiple antibiotic selectors using c() + expect_equal(nrow(example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]), 26) + + # filter + select in one go: get penicillins in carbapenems-resistant strains + expect_equal(nrow(example_isolates[any(carbapenems() == "R"), penicillins()]), 55) + expect_equal(ncol(example_isolates[any(carbapenems() == "R"), penicillins()]), 7) } diff --git a/inst/tinytest/test-filter_ab_class.R b/inst/tinytest/test-filter_ab_class.R deleted file mode 100644 index 60d36f64..00000000 --- a/inst/tinytest/test-filter_ab_class.R +++ /dev/null @@ -1,49 +0,0 @@ -# ==================================================================== # -# TITLE # -# Antimicrobial Resistance (AMR) Data Analysis for R # -# # -# SOURCE # -# https://github.com/msberends/AMR # -# # -# LICENCE # -# (c) 2018-2021 Berends MS, Luz CF et al. # -# Developed at the University of Groningen, the Netherlands, in # -# collaboration with non-profit organisations Certe Medical # -# Diagnostics & Advice, and University Medical Center Groningen. # -# # -# This R package is free software; you can freely use and distribute # -# it for both personal and commercial purposes under the terms of the # -# GNU General Public License version 2.0 (GNU GPL-2), as published by # -# the Free Software Foundation. # -# We created this package for both routine data analysis and academic # -# research and it was publicly released in the hope that it will be # -# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. # -# # -# Visit our website for the full manual and a complete tutorial about # -# how to conduct AMR data analysis: https://msberends.github.io/AMR/ # -# ==================================================================== # - -if (pkg_is_available("dplyr")) { - expect_true(example_isolates %>% filter_ab_class("carbapenem") %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_aminoglycosides() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_betalactams() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_carbapenems() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_cephalosporins() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_1st_cephalosporins() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_2nd_cephalosporins() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_3rd_cephalosporins() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_4th_cephalosporins() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% mutate(ceftaroline = CTX) %>% filter_5th_cephalosporins() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_fluoroquinolones() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_glycopeptides() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_macrolides() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_oxazolidinones() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_penicillins() %>% nrow() < nrow(example_isolates)) - expect_true(example_isolates %>% filter_tetracyclines() %>% nrow() < nrow(example_isolates)) - - expect_true(example_isolates %>% filter_carbapenems("R", "all") %>% nrow() > 0) - - expect_error(example_isolates %>% filter_carbapenems(result = "test")) - expect_error(example_isolates %>% filter_carbapenems(scope = "test")) - expect_message(example_isolates %>% select(1:3) %>% filter_carbapenems()) -} diff --git a/man/AMR-deprecated.Rd b/man/AMR-deprecated.Rd index cb4f45cf..140b1de5 100644 --- a/man/AMR-deprecated.Rd +++ b/man/AMR-deprecated.Rd @@ -6,6 +6,22 @@ \alias{filter_first_weighted_isolate} \alias{key_antibiotics} \alias{key_antibiotics_equal} +\alias{filter_ab_class} +\alias{filter_aminoglycosides} +\alias{filter_betalactams} +\alias{filter_carbapenems} +\alias{filter_cephalosporins} +\alias{filter_1st_cephalosporins} +\alias{filter_2nd_cephalosporins} +\alias{filter_3rd_cephalosporins} +\alias{filter_4th_cephalosporins} +\alias{filter_5th_cephalosporins} +\alias{filter_fluoroquinolones} +\alias{filter_glycopeptides} +\alias{filter_macrolides} +\alias{filter_oxazolidinones} +\alias{filter_penicillins} +\alias{filter_tetracyclines} \title{Deprecated Functions} \usage{ p_symbol(p, emptychar = " ") @@ -53,9 +69,141 @@ key_antibiotics_equal( na.rm = TRUE, ... ) + +filter_ab_class( + x, + ab_class, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_aminoglycosides( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_betalactams( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_carbapenems( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_cephalosporins( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_1st_cephalosporins( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_2nd_cephalosporins( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_3rd_cephalosporins( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_4th_cephalosporins( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_5th_cephalosporins( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_fluoroquinolones( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_glycopeptides( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_macrolides( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_oxazolidinones( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_penicillins( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) + +filter_tetracyclines( + x, + result = NULL, + scope = "any", + only_rsi_columns = FALSE, + ... +) } \description{ -These functions are so-called '\link{Deprecated}'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one). +These functions are so-called '\link{Deprecated}'. \strong{They will be removed in a future release.} Using the functions will give a warning with the name of the function it has been replaced by (if there is one). +} +\details{ +All antibiotic class selectors (such as \code{\link[=carbapenems]{carbapenems()}}, \code{\link[=aminoglycosides]{aminoglycosides()}}) can now be used for filtering as well, making all their accompanying \verb{filter_*()} functions redundant (such as \code{\link[=filter_carbapenems]{filter_carbapenems()}}, \code{\link[=filter_aminoglycosides]{filter_aminoglycosides()}}). } \section{Retired Lifecycle}{ diff --git a/man/antibiotic_class_selectors.Rd b/man/antibiotic_class_selectors.Rd index 25cf0d12..066a5e70 100644 --- a/man/antibiotic_class_selectors.Rd +++ b/man/antibiotic_class_selectors.Rd @@ -58,12 +58,14 @@ tetracyclines(only_rsi_columns = FALSE) \item{only_rsi_columns}{a \link{logical} to indicate whether only columns of class \verb{} must be selected (defaults to \code{FALSE}), see \code{\link[=as.rsi]{as.rsi()}}} } \description{ -These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} +These functions help to filter and select columns with antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} } \details{ \strong{\Sexpr{ifelse(as.double(R.Version()$major) + (as.double(R.Version()$minor) / 10) < 3.2, paste0("NOTE: THESE FUNCTIONS DO NOT WORK ON YOUR CURRENT R VERSION. These functions require R version 3.2 or later - you have ", R.version.string, "."), "")}} -All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the \link{antibiotics} data set. This means that a selector like e.g. \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. +These functions can be used in data set calls for selecting columns and filtering rows, see \emph{Examples}. They support base R, but work more convenient in dplyr functions such as \code{\link[dplyr:select]{select()}}, \code{\link[dplyr:filter]{filter()}} and \code{\link[dplyr:summarise]{summarise()}}. + +All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) in the \link{antibiotics} data set. This means that a selector like e.g. \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. The group of betalactams consists of all carbapenems, cephalosporins and penicillins. } @@ -89,11 +91,31 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/ # `example_isolates` is a data set available in the AMR package. # See ?example_isolates. -# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): +# Base R ------------------------------------------------------------------ + +# select columns 'IPM' (imipenem) and 'MEM' (meropenem) example_isolates[, carbapenems()] -# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB': + +# select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB' example_isolates[, c("mo", aminoglycosides())] +# filter using any() or all() +example_isolates[any(carbapenems() == "R"), ] +subset(example_isolates, any(carbapenems() == "R")) + +# filter on any or all results in the carbapenem columns (i.e., IPM, MEM): +example_isolates[any(carbapenems()), ] +example_isolates[all(carbapenems()), ] + +# filter with multiple antibiotic selectors using c() +example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ] + +# filter + select in one go: get penicillins in carbapenems-resistant strains +example_isolates[any(carbapenems() == "R"), penicillins()] + + +# dplyr ------------------------------------------------------------------- + if (require("dplyr")) { # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): @@ -104,6 +126,20 @@ if (require("dplyr")) { example_isolates \%>\% select(mo, aminoglycosides()) + # any() and all() work in dplyr's filter() too: + example_isolates \%>\% + filter(any(aminoglycosides() == "R"), + all(cephalosporins_2nd() == "R")) + + # also works with c(): + example_isolates \%>\% + filter(any(c(carbapenems(), aminoglycosides()) == "R")) + + # not setting any/all will automatically apply all(): + example_isolates \%>\% + filter(aminoglycosides() == "R") + #> i Assuming a filter on all 4 aminoglycosides. + # this will select columns 'mo' and all antimycobacterial drugs ('RIF'): example_isolates \%>\% select(mo, ab_class("mycobact")) @@ -122,12 +158,10 @@ if (require("dplyr")) { select(penicillins()) # only the 'J01CA01' column will be selected - # with dplyr 1.0.0 and higher (that adds 'across()'), this is equal: + # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal: # (though the row names on the first are more correct) - example_isolates \%>\% filter_carbapenems("R", "all") - example_isolates \%>\% filter(across(carbapenems(), ~. == "R")) + example_isolates[carbapenems() == "R", ] + example_isolates \%>\% filter(carbapenems() == "R") + example_isolates \%>\% filter(across(carbapenems(), ~.x == "R")) } } -\seealso{ -\code{\link[=filter_ab_class]{filter_ab_class()}} for the \code{filter()} equivalent. -} diff --git a/man/filter_ab_class.Rd b/man/filter_ab_class.Rd deleted file mode 100644 index 27657a73..00000000 --- a/man/filter_ab_class.Rd +++ /dev/null @@ -1,228 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/filter_ab_class.R -\name{filter_ab_class} -\alias{filter_ab_class} -\alias{filter_aminoglycosides} -\alias{filter_betalactams} -\alias{filter_carbapenems} -\alias{filter_cephalosporins} -\alias{filter_1st_cephalosporins} -\alias{filter_2nd_cephalosporins} -\alias{filter_3rd_cephalosporins} -\alias{filter_4th_cephalosporins} -\alias{filter_5th_cephalosporins} -\alias{filter_fluoroquinolones} -\alias{filter_glycopeptides} -\alias{filter_macrolides} -\alias{filter_oxazolidinones} -\alias{filter_penicillins} -\alias{filter_tetracyclines} -\title{Filter Isolates on Result in Antimicrobial Class} -\usage{ -filter_ab_class( - x, - ab_class, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_aminoglycosides( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_betalactams( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_carbapenems( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_cephalosporins( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_1st_cephalosporins( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_2nd_cephalosporins( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_3rd_cephalosporins( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_4th_cephalosporins( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_5th_cephalosporins( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_fluoroquinolones( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_glycopeptides( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_macrolides( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_oxazolidinones( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_penicillins( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) - -filter_tetracyclines( - x, - result = NULL, - scope = "any", - only_rsi_columns = FALSE, - ... -) -} -\arguments{ -\item{x}{a data set} - -\item{ab_class}{an antimicrobial class, like \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.} - -\item{result}{an antibiotic result: S, I or R (or a combination of more of them)} - -\item{scope}{the scope to check which variables to check, can be \code{"any"} (default) or \code{"all"}} - -\item{only_rsi_columns}{a \link{logical} to indicate whether only columns must be included that were transformed to class \verb{} (see \code{\link[=as.rsi]{as.rsi()}}) on beforehand (defaults to \code{FALSE})} - -\item{...}{arguments passed on to \code{\link[=filter_ab_class]{filter_ab_class()}}} -} -\description{ -Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs. -} -\details{ -All columns of \code{x} will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a filter function like e.g. \code{\link[=filter_aminoglycosides]{filter_aminoglycosides()}} will include column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. - -The group of betalactams consists of all carbapenems, cephalosporins and penicillins. -} -\section{Stable Lifecycle}{ - -\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr} -The \link[=lifecycle]{lifecycle} of this function is \strong{stable}. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided. - -If the unlying code needs breaking changes, they will occur gradually. For example, a argument will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error. -} - -\examples{ -x <- filter_carbapenems(example_isolates) -\donttest{ -# base R filter options (requires R >= 3.2) -example_isolates[filter_carbapenems(), ] -example_isolates[which(filter_carbapenems() & mo_is_gram_negative()), ] - -if (require("dplyr")) { - - # filter on isolates that have any result for any aminoglycoside - example_isolates \%>\% filter_aminoglycosides() - example_isolates \%>\% filter_ab_class("aminoglycoside") - - # this is essentially the same as (but without determination of column names): - example_isolates \%>\% - filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")), - .vars_predicate = any_vars(. \%in\% c("S", "I", "R"))) - - - # filter on isolates that show resistance to ANY aminoglycoside - example_isolates \%>\% filter_aminoglycosides("R", "any") - - # filter on isolates that show resistance to ALL aminoglycosides - example_isolates \%>\% filter_aminoglycosides("R", "all") - - # filter on isolates that show resistance to - # any aminoglycoside and any fluoroquinolone - example_isolates \%>\% - filter_aminoglycosides("R") \%>\% - filter_fluoroquinolones("R") - - # filter on isolates that show resistance to - # all aminoglycosides and all fluoroquinolones - example_isolates \%>\% - filter_aminoglycosides("R", "all") \%>\% - filter_fluoroquinolones("R", "all") - - # with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal: - # (though the row names on the first are more correct) - example_isolates \%>\% filter_carbapenems("R", "all") - example_isolates \%>\% filter(across(carbapenems(), ~. == "R")) - example_isolates \%>\% filter(across(carbapenems(), function(x) x == "R")) - example_isolates \%>\% filter(filter_carbapenems("R", "all")) -} -} -} -\seealso{ -\code{\link[=antibiotic_class_selectors]{antibiotic_class_selectors()}} for the \code{select()} equivalent. -}