mirror of https://github.com/msberends/AMR.git
(v1.6.0.9048) ab selectors overhaul
This commit is contained in:
parent
6920c0be41
commit
2413efd5c1
|
@ -127,7 +127,7 @@ jobs:
|
||||||
tar -xf data-raw/AMR_latest.tar.gz
|
tar -xf data-raw/AMR_latest.tar.gz
|
||||||
rm -rf AMR/vignettes
|
rm -rf AMR/vignettes
|
||||||
Rscript -e "writeLines(readLines('AMR/DESCRIPTION')[!grepl('VignetteBuilder', readLines('AMR/DESCRIPTION'))], 'AMR/DESCRIPTION')"
|
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
|
shell: bash
|
||||||
|
|
||||||
- name: Run R CMD check
|
- name: Run R CMD check
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.6.0.9047
|
Version: 1.6.0.9048
|
||||||
Date: 2021-05-18
|
Date: 2021-05-19
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(role = c("aut", "cre"),
|
person(role = c("aut", "cre"),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Generated by roxygen2: do not edit by hand
|
# Generated by roxygen2: do not edit by hand
|
||||||
|
|
||||||
S3method("!",mic)
|
S3method("!",mic)
|
||||||
|
S3method("!=",ab_selector)
|
||||||
S3method("!=",mic)
|
S3method("!=",mic)
|
||||||
S3method("%%",mic)
|
S3method("%%",mic)
|
||||||
S3method("%/%",mic)
|
S3method("%/%",mic)
|
||||||
|
@ -11,6 +12,7 @@ S3method("-",mic)
|
||||||
S3method("/",mic)
|
S3method("/",mic)
|
||||||
S3method("<",mic)
|
S3method("<",mic)
|
||||||
S3method("<=",mic)
|
S3method("<=",mic)
|
||||||
|
S3method("==",ab_selector)
|
||||||
S3method("==",mic)
|
S3method("==",mic)
|
||||||
S3method(">",mic)
|
S3method(">",mic)
|
||||||
S3method(">=",mic)
|
S3method(">=",mic)
|
||||||
|
@ -37,7 +39,11 @@ S3method("|",mic)
|
||||||
S3method(abs,mic)
|
S3method(abs,mic)
|
||||||
S3method(acos,mic)
|
S3method(acos,mic)
|
||||||
S3method(acosh,mic)
|
S3method(acosh,mic)
|
||||||
|
S3method(all,ab_selector)
|
||||||
|
S3method(all,ab_selector_any_all)
|
||||||
S3method(all,mic)
|
S3method(all,mic)
|
||||||
|
S3method(any,ab_selector)
|
||||||
|
S3method(any,ab_selector_any_all)
|
||||||
S3method(any,mic)
|
S3method(any,mic)
|
||||||
S3method(as.data.frame,ab)
|
S3method(as.data.frame,ab)
|
||||||
S3method(as.data.frame,mo)
|
S3method(as.data.frame,mo)
|
||||||
|
@ -59,6 +65,7 @@ S3method(barplot,disk)
|
||||||
S3method(barplot,mic)
|
S3method(barplot,mic)
|
||||||
S3method(barplot,rsi)
|
S3method(barplot,rsi)
|
||||||
S3method(c,ab)
|
S3method(c,ab)
|
||||||
|
S3method(c,ab_selector)
|
||||||
S3method(c,custom_eucast_rules)
|
S3method(c,custom_eucast_rules)
|
||||||
S3method(c,custom_mdro_guideline)
|
S3method(c,custom_mdro_guideline)
|
||||||
S3method(c,disk)
|
S3method(c,disk)
|
||||||
|
|
23
NEWS.md
23
NEWS.md
|
@ -1,5 +1,24 @@
|
||||||
# `AMR` 1.6.0.9047
|
# `AMR` 1.6.0.9048
|
||||||
## <small>Last updated: 18 May 2021</small>
|
## <small>Last updated: 19 May 2021</small>
|
||||||
|
|
||||||
|
### 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
|
### New
|
||||||
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
||||||
|
|
|
@ -336,6 +336,9 @@ word_wrap <- function(...,
|
||||||
collapse = "\n"))
|
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\"
|
# we need to correct for already applied style, that adds text like "\033[31m\"
|
||||||
msg_stripped <- font_stripstyle(msg)
|
msg_stripped <- font_stripstyle(msg)
|
||||||
# where are the spaces now?
|
# where are the spaces now?
|
||||||
|
@ -352,6 +355,8 @@ word_wrap <- function(...,
|
||||||
# put it together
|
# put it together
|
||||||
msg <- unlist(strsplit(msg, " "))
|
msg <- unlist(strsplit(msg, " "))
|
||||||
msg[replace_spaces] <- paste0(msg[replace_spaces], "\n")
|
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 <- paste0(msg, collapse = " ")
|
||||||
msg <- gsub("\n ", "\n", msg, fixed = TRUE)
|
msg <- gsub("\n ", "\n", msg, fixed = TRUE)
|
||||||
|
|
||||||
|
@ -709,7 +714,7 @@ get_current_data <- function(arg_name, call) {
|
||||||
if (!is.null(cur_data_all)) {
|
if (!is.null(cur_data_all)) {
|
||||||
out <- tryCatch(cur_data_all(), error = function(e) NULL)
|
out <- tryCatch(cur_data_all(), error = function(e) NULL)
|
||||||
if (is.data.frame(out)) {
|
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()
|
# try a (base R) method, by going over the complete system call stack with sys.frames()
|
||||||
not_set <- TRUE
|
not_set <- TRUE
|
||||||
|
source <- "base_R"
|
||||||
frms <- lapply(sys.frames(), function(el) {
|
frms <- lapply(sys.frames(), function(el) {
|
||||||
if (not_set == TRUE && ".Generic" %in% names(el)) {
|
if (not_set == TRUE && ".Generic" %in% names(el)) {
|
||||||
if (tryCatch(".data" %in% names(el) && is.data.frame(el$`.data`), error = function(e) FALSE)) {
|
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()
|
# 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()]
|
# [but not when using dplyr::filter(), dplyr::mutate() or dplyr::summarise()]
|
||||||
not_set <<- FALSE
|
not_set <<- FALSE
|
||||||
|
source <<- "dplyr_selector"
|
||||||
el$`.data`
|
el$`.data`
|
||||||
} else if (tryCatch(any(c("x", "xx") %in% names(el)), error = function(e) FALSE)) {
|
} 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
|
# 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)
|
vars_df <- tryCatch(frms[[which(!vapply(FUN.VALUE = logical(1), frms, is.null))]], error = function(e) NULL)
|
||||||
if (is.data.frame(vars_df)) {
|
if (is.data.frame(vars_df)) {
|
||||||
return(vars_df)
|
return(structure(vars_df, type = source))
|
||||||
}
|
}
|
||||||
|
|
||||||
# nothing worked, so:
|
# nothing worked, so:
|
||||||
|
|
|
@ -25,17 +25,19 @@
|
||||||
|
|
||||||
#' Antibiotic Class Selectors
|
#' 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
|
#' @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 `<rsi>` must be selected (defaults to `FALSE`), see [as.rsi()]
|
#' @param only_rsi_columns a [logical] to indicate whether only columns of class `<rsi>` 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, "."), "")}}
|
#' @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.
|
#' The group of betalactams consists of all carbapenems, cephalosporins and penicillins.
|
||||||
#' @rdname antibiotic_class_selectors
|
#' @rdname antibiotic_class_selectors
|
||||||
#' @seealso [filter_ab_class()] for the `filter()` equivalent.
|
|
||||||
#' @name antibiotic_class_selectors
|
#' @name antibiotic_class_selectors
|
||||||
#' @export
|
#' @export
|
||||||
#' @inheritSection AMR Reference Data Publicly Available
|
#' @inheritSection AMR Reference Data Publicly Available
|
||||||
|
@ -44,11 +46,31 @@
|
||||||
#' # `example_isolates` is a data set available in the AMR package.
|
#' # `example_isolates` is a data set available in the AMR package.
|
||||||
#' # See ?example_isolates.
|
#' # See ?example_isolates.
|
||||||
#'
|
#'
|
||||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
#' # Base R ------------------------------------------------------------------
|
||||||
|
#'
|
||||||
|
#' # select columns 'IPM' (imipenem) and 'MEM' (meropenem)
|
||||||
#' example_isolates[, carbapenems()]
|
#' 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())]
|
#' 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")) {
|
#' if (require("dplyr")) {
|
||||||
#'
|
#'
|
||||||
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||||
|
@ -59,6 +81,20 @@
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' select(mo, aminoglycosides())
|
#' 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'):
|
#' # this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
|
||||||
#' example_isolates %>%
|
#' example_isolates %>%
|
||||||
#' select(mo, ab_class("mycobact"))
|
#' select(mo, ab_class("mycobact"))
|
||||||
|
@ -77,10 +113,11 @@
|
||||||
#' select(penicillins()) # only the 'J01CA01' column will be selected
|
#' 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)
|
#' # (though the row names on the first are more correct)
|
||||||
#' example_isolates %>% filter_carbapenems("R", "all")
|
#' example_isolates[carbapenems() == "R", ]
|
||||||
#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
|
#' example_isolates %>% filter(carbapenems() == "R")
|
||||||
|
#' example_isolates %>% filter(across(carbapenems(), ~.x == "R"))
|
||||||
#' }
|
#' }
|
||||||
ab_class <- function(ab_class,
|
ab_class <- function(ab_class,
|
||||||
only_rsi_columns = FALSE) {
|
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))
|
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_formatted[need_name] <- paste0(agents_formatted[need_name],
|
||||||
" (", agents_names[need_name], ")")
|
" (", agents_names[need_name], ")")
|
||||||
message_("Applying `", function_name, "()`: selecting ",
|
message_("For `", function_name, "(", ifelse(function_name == "ab_class", paste0("\"", ab_class, "\""), ""), ")` using ",
|
||||||
ifelse(length(agents) == 1, "column ", "columns "),
|
ifelse(length(agents) == 1, "column: ", "columns: "),
|
||||||
vector_and(agents_formatted, quotes = FALSE))
|
vector_and(agents_formatted, quotes = FALSE))
|
||||||
}
|
}
|
||||||
remember_thrown_message(function_name)
|
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)
|
||||||
}
|
}
|
||||||
|
|
364
R/deprecated.R
364
R/deprecated.R
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#' Deprecated Functions
|
#' 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 lifecycle Retired Lifecycle
|
||||||
#' @inheritSection AMR Read more on Our Website!
|
#' @inheritSection AMR Read more on Our Website!
|
||||||
#' @keywords internal
|
#' @keywords internal
|
||||||
|
@ -138,3 +139,364 @@ key_antibiotics_equal <- function(y,
|
||||||
points_threshold = points_threshold,
|
points_threshold = points_threshold,
|
||||||
info = info)
|
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)),
|
||||||
|
...)
|
||||||
|
}
|
||||||
|
|
|
@ -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 `<rsi>` (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 <rsi>,", ","),
|
|
||||||
" 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)
|
|
||||||
}
|
|
|
@ -149,7 +149,7 @@ reference:
|
||||||
desc: >
|
desc: >
|
||||||
Use these function for the analysis part. You can use `susceptibility()` or `resistance()` on any antibiotic column.
|
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()`.
|
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:
|
contents:
|
||||||
- "`proportion`"
|
- "`proportion`"
|
||||||
- "`count`"
|
- "`count`"
|
||||||
|
@ -162,7 +162,6 @@ reference:
|
||||||
- "`ggplot_rsi`"
|
- "`ggplot_rsi`"
|
||||||
- "`bug_drug_combinations`"
|
- "`bug_drug_combinations`"
|
||||||
- "`antibiotic_class_selectors`"
|
- "`antibiotic_class_selectors`"
|
||||||
- "`filter_ab_class`"
|
|
||||||
- "`resistance_predict`"
|
- "`resistance_predict`"
|
||||||
- "`guess_ab_col`"
|
- "`guess_ab_col`"
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -81,7 +81,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@
|
||||||
<div class="page-header toc-ignore">
|
<div class="page-header toc-ignore">
|
||||||
<h1 data-toc-skip>Data sets for download / own use</h1>
|
<h1 data-toc-skip>Data sets for download / own use</h1>
|
||||||
|
|
||||||
<h4 class="date">18 May 2021</h4>
|
<h4 class="date">19 May 2021</h4>
|
||||||
|
|
||||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
|
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
|
||||||
<div class="hidden name"><code>datasets.Rmd</code></div>
|
<div class="hidden name"><code>datasets.Rmd</code></div>
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -236,13 +236,38 @@
|
||||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="amr-1609047" class="section level1">
|
<div id="amr-1609048" class="section level1">
|
||||||
<h1 class="page-header" data-toc-text="1.6.0.9047">
|
<h1 class="page-header" data-toc-text="1.6.0.9048">
|
||||||
<a href="#amr-1609047" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9047</h1>
|
<a href="#amr-1609048" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9048</h1>
|
||||||
<div id="last-updated-18-may-2021" class="section level2">
|
<div id="last-updated-19-may-2021" class="section level2">
|
||||||
<h2 class="hasAnchor">
|
<h2 class="hasAnchor">
|
||||||
<a href="#last-updated-18-may-2021" class="anchor"></a><small>Last updated: 18 May 2021</small>
|
<a href="#last-updated-19-may-2021" class="anchor"></a><small>Last updated: 19 May 2021</small>
|
||||||
</h2>
|
</h2>
|
||||||
|
<div id="breaking-change" class="section level3">
|
||||||
|
<h3 class="hasAnchor">
|
||||||
|
<a href="#breaking-change" class="anchor"></a>Breaking change</h3>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>All antibiotic class selectors (such as <code><a href="../reference/antibiotic_class_selectors.html">carbapenems()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>) can now be used for filtering as well, making all their accompanying <code>filter_*()</code> functions redundant (such as <code><a href="../reference/AMR-deprecated.html">filter_carbapenems()</a></code>, <code><a href="../reference/AMR-deprecated.html">filter_aminoglycosides()</a></code>). These functions are now deprecated and will be removed in a next release.</p>
|
||||||
|
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
||||||
|
<code class="sourceCode R">
|
||||||
|
<span class="co"># select columns with results for carbapenems</span>
|
||||||
|
<span class="va">example_isolates</span><span class="op">[</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">]</span> <span class="co"># base R</span>
|
||||||
|
<span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span>
|
||||||
|
|
||||||
|
<span class="co"># filter rows for resistance in any carbapenem</span>
|
||||||
|
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/any.html">any</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span>, <span class="op">]</span> <span class="co"># base R</span>
|
||||||
|
<span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/any.html">any</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span>
|
||||||
|
<span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/across.html">if_any</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span>, <span class="op">~</span><span class="va">.x</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr (formal)</span>
|
||||||
|
|
||||||
|
<span class="co"># filter rows for resistance in all carbapenems</span>
|
||||||
|
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/all.html">all</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span>, <span class="op">]</span> <span class="co"># base R</span>
|
||||||
|
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span>, <span class="op">]</span>
|
||||||
|
<span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/all.html">all</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span>
|
||||||
|
<span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span></code></pre></div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div id="new" class="section level3">
|
<div id="new" class="section level3">
|
||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
<a href="#new" class="anchor"></a>New</h3>
|
<a href="#new" class="anchor"></a>New</h3>
|
||||||
|
@ -262,7 +287,7 @@
|
||||||
<li>The documentation of the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> and <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> functions has been completely rewritten.</li>
|
<li>The documentation of the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> and <code><a href="../reference/key_antimicrobials.html">key_antimicrobials()</a></code> functions has been completely rewritten.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>Function <code><a href="../reference/antibiotic_class_selectors.html">betalactams()</a></code> as additional antbiotic column selector and function <code><a href="../reference/filter_ab_class.html">filter_betalactams()</a></code> as additional antbiotic column filter. The group of betalactams consists of all carbapenems, cephalosporins and penicillins.</li>
|
<li>Function <code><a href="../reference/antibiotic_class_selectors.html">betalactams()</a></code> as additional antbiotic column selector and function <code><a href="../reference/AMR-deprecated.html">filter_betalactams()</a></code> as additional antbiotic column filter. The group of betalactams consists of all carbapenems, cephalosporins and penicillins.</li>
|
||||||
<li>A <code>ggplot()</code> method for <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>
|
<li>A <code>ggplot()</code> method for <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -287,7 +312,7 @@
|
||||||
<li><p>Now checks if <code>pattern</code> is a <em>valid</em> regular expression</p></li>
|
<li><p>Now checks if <code>pattern</code> is a <em>valid</em> regular expression</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Added <code><a href="../reference/like.html">%unlike%</a></code> and <code><a href="../reference/like.html">%unlike_case%</a></code> (as negations of the existing <code><a href="../reference/like.html">%like%</a></code> and <code><a href="../reference/like.html">%like_case%</a></code>). This greatly improves readability:</p>
|
<p>Added <code><a href="../reference/like.html">%unlike%</a></code> and <code><a href="../reference/like.html">%unlike_case%</a></code> (as negations of the existing <code><a href="../reference/like.html">%like%</a></code> and <code><a href="../reference/like.html">%like_case%</a></code>). This greatly improves readability:</p>
|
||||||
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grepl</a></span><span class="op">(</span><span class="st">"EUCAST"</span>, <span class="va">guideline</span><span class="op">)</span><span class="op">)</span> <span class="va">...</span>
|
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="fu"><a href="https://rdrr.io/r/base/grep.html">grepl</a></span><span class="op">(</span><span class="st">"EUCAST"</span>, <span class="va">guideline</span><span class="op">)</span><span class="op">)</span> <span class="va">...</span>
|
||||||
<span class="co"># same:</span>
|
<span class="co"># same:</span>
|
||||||
|
@ -307,17 +332,17 @@
|
||||||
<li>Updated <code><a href="https://docs.ropensci.org/skimr/reference/skim.html">skimr::skim()</a></code> usage for MIC values to also include 25th and 75th percentiles</li>
|
<li>Updated <code><a href="https://docs.ropensci.org/skimr/reference/skim.html">skimr::skim()</a></code> usage for MIC values to also include 25th and 75th percentiles</li>
|
||||||
<li>Fix for plotting missing MIC/disk diffusion values</li>
|
<li>Fix for plotting missing MIC/disk diffusion values</li>
|
||||||
<li>Updated join functions to always use <code>dplyr</code> join functions if the <code>dplyr</code> package is installed - now also preserving grouped variables</li>
|
<li>Updated join functions to always use <code>dplyr</code> join functions if the <code>dplyr</code> package is installed - now also preserving grouped variables</li>
|
||||||
<li>Updates for filtering on antibiotic classes (e.g., using <code><a href="../reference/filter_ab_class.html">filter_carbapenems()</a></code>):
|
<li>Updates for filtering on antibiotic classes (e.g., using <code><a href="../reference/AMR-deprecated.html">filter_carbapenems()</a></code>):
|
||||||
<ul>
|
<ul>
|
||||||
<li><p>Support for dplyr groups</p></li>
|
<li><p>Support for dplyr groups</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for base R row filtering:</p>
|
<p>Support for base R row filtering:</p>
|
||||||
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="https://rdrr.io/r/base/dim.html">dim</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
<span class="fu"><a href="https://rdrr.io/r/base/dim.html">dim</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
||||||
<span class="co">#> [1] 2000 49</span>
|
<span class="co">#> [1] 2000 49</span>
|
||||||
|
|
||||||
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="../reference/filter_ab_class.html">filter_carbapenems</a></span><span class="op">(</span><span class="op">)</span>, <span class="op">]</span>
|
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="../reference/AMR-deprecated.html">filter_carbapenems</a></span><span class="op">(</span><span class="op">)</span>, <span class="op">]</span>
|
||||||
<span class="co">#> ℹ Applying `filter_carbapenems()`: values in any of columns 'IPM' (imipenem)</span>
|
<span class="co">#> ℹ Applying `filter_carbapenems()`: values in any of columns 'IPM' (imipenem)</span>
|
||||||
<span class="co">#> or 'MEM' (meropenem) are either "R", "S" or "I"</span>
|
<span class="co">#> or 'MEM' (meropenem) are either "R", "S" or "I"</span>
|
||||||
<span class="co">#> [1] 962 49</span></code></pre></div>
|
<span class="co">#> [1] 962 49</span></code></pre></div>
|
||||||
|
@ -357,7 +382,7 @@
|
||||||
<p>Added argument <code>only_rsi_columns</code> for some functions, which defaults to <code>FALSE</code>, to indicate if the functions must only be applied to columns that are of class <code><rsi></code> (i.e., transformed with <code><a href="../reference/as.rsi.html">as.rsi()</a></code>). This increases speed since automatic determination of antibiotic columns is not needed anymore. Affected functions are:</p>
|
<p>Added argument <code>only_rsi_columns</code> for some functions, which defaults to <code>FALSE</code>, to indicate if the functions must only be applied to columns that are of class <code><rsi></code> (i.e., transformed with <code><a href="../reference/as.rsi.html">as.rsi()</a></code>). This increases speed since automatic determination of antibiotic columns is not needed anymore. Affected functions are:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>All antibiotic selector functions (<code><a href="../reference/antibiotic_class_selectors.html">ab_class()</a></code> and its wrappers, such as <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">carbapenems()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">penicillins()</a></code>)</li>
|
<li>All antibiotic selector functions (<code><a href="../reference/antibiotic_class_selectors.html">ab_class()</a></code> and its wrappers, such as <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">carbapenems()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">penicillins()</a></code>)</li>
|
||||||
<li>All antibiotic filter functions (<code><a href="../reference/filter_ab_class.html">filter_ab_class()</a></code> and its wrappers, such as <code><a href="../reference/filter_ab_class.html">filter_aminoglycosides()</a></code>, <code><a href="../reference/filter_ab_class.html">filter_carbapenems()</a></code>, <code><a href="../reference/filter_ab_class.html">filter_penicillins()</a></code>)</li>
|
<li>All antibiotic filter functions (<code><a href="../reference/AMR-deprecated.html">filter_ab_class()</a></code> and its wrappers, such as <code><a href="../reference/AMR-deprecated.html">filter_aminoglycosides()</a></code>, <code><a href="../reference/AMR-deprecated.html">filter_carbapenems()</a></code>, <code><a href="../reference/AMR-deprecated.html">filter_penicillins()</a></code>)</li>
|
||||||
<li><code><a href="../reference/eucast_rules.html">eucast_rules()</a></code></li>
|
<li><code><a href="../reference/eucast_rules.html">eucast_rules()</a></code></li>
|
||||||
<li>
|
<li>
|
||||||
<code><a href="../reference/mdro.html">mdro()</a></code> (including wrappers such as <code><a href="../reference/mdro.html">brmo()</a></code>, <code><a href="../reference/mdro.html">mrgn()</a></code> and <code><a href="../reference/mdro.html">eucast_exceptional_phenotypes()</a></code>)</li>
|
<code><a href="../reference/mdro.html">mdro()</a></code> (including wrappers such as <code><a href="../reference/mdro.html">brmo()</a></code>, <code><a href="../reference/mdro.html">mrgn()</a></code> and <code><a href="../reference/mdro.html">eucast_exceptional_phenotypes()</a></code>)</li>
|
||||||
|
@ -365,21 +390,21 @@
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>Functions <code><a href="../reference/antibiotic_class_selectors.html">oxazolidinones()</a></code> (an antibiotic selector function) and <code><a href="../reference/filter_ab_class.html">filter_oxazolidinones()</a></code> (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid</p>
|
<p>Functions <code><a href="../reference/antibiotic_class_selectors.html">oxazolidinones()</a></code> (an antibiotic selector function) and <code><a href="../reference/AMR-deprecated.html">filter_oxazolidinones()</a></code> (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid</p>
|
||||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||||
<span class="va">x</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">date</span>, <span class="va">hospital_id</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">oxazolidinones</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>
|
<span class="va">x</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">date</span>, <span class="va">hospital_id</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">oxazolidinones</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>
|
||||||
<span class="co">#> Selecting oxazolidinones: column 'LNZ' (linezolid)</span>
|
<span class="co">#> Selecting oxazolidinones: column 'LNZ' (linezolid)</span>
|
||||||
|
|
||||||
<span class="va">x</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/filter_ab_class.html">filter_oxazolidinones</a></span><span class="op">(</span><span class="op">)</span>
|
<span class="va">x</span> <span class="op"><-</span> <span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/AMR-deprecated.html">filter_oxazolidinones</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
<span class="co">#> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"</span></code></pre></div>
|
<span class="co">#> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"</span></code></pre></div>
|
||||||
</li>
|
</li>
|
||||||
<li><p>Support for custom MDRO guidelines, using the new <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function, please see <code><a href="../reference/mdro.html">mdro()</a></code> for additional info</p></li>
|
<li><p>Support for custom MDRO guidelines, using the new <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function, please see <code><a href="../reference/mdro.html">mdro()</a></code> for additional info</p></li>
|
||||||
<li><p><code>ggplot()</code> generics for classes <code><mic></code> and <code><disk></code></p></li>
|
<li><p><code>ggplot()</code> generics for classes <code><mic></code> and <code><disk></code></p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Function <code><a href="../reference/mo_property.html">mo_is_yeast()</a></code>, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:</p>
|
<p>Function <code><a href="../reference/mo_property.html">mo_is_yeast()</a></code>, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:</p>
|
||||||
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_kingdom</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Aspergillus"</span>, <span class="st">"Candida"</span><span class="op">)</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/mo_property.html">mo_kingdom</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Aspergillus"</span>, <span class="st">"Candida"</span><span class="op">)</span><span class="op">)</span>
|
||||||
<span class="co">#> [1] "Fungi" "Fungi"</span>
|
<span class="co">#> [1] "Fungi" "Fungi"</span>
|
||||||
|
@ -391,7 +416,7 @@
|
||||||
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html">which</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_is_yeast</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>, <span class="op">]</span> <span class="co"># base R</span>
|
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html">which</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_is_yeast</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>, <span class="op">]</span> <span class="co"># base R</span>
|
||||||
<span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_is_yeast</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span></code></pre></div>
|
<span class="va">example_isolates</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_is_yeast</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># dplyr</span></code></pre></div>
|
||||||
<p>The <code><a href="../reference/mo_property.html">mo_type()</a></code> function has also been updated to reflect this change:</p>
|
<p>The <code><a href="../reference/mo_property.html">mo_type()</a></code> function has also been updated to reflect this change:</p>
|
||||||
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_type</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Aspergillus"</span>, <span class="st">"Candida"</span><span class="op">)</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/mo_property.html">mo_type</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Aspergillus"</span>, <span class="st">"Candida"</span><span class="op">)</span><span class="op">)</span>
|
||||||
<span class="co"># [1] "Fungi" "Yeasts"</span>
|
<span class="co"># [1] "Fungi" "Yeasts"</span>
|
||||||
|
@ -401,7 +426,7 @@
|
||||||
<li><p>Added Pretomanid (PMD, J04AK08) to the <code>antibiotics</code> data set</p></li>
|
<li><p>Added Pretomanid (PMD, J04AK08) to the <code>antibiotics</code> data set</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>MIC values (see <code><a href="../reference/as.mic.html">as.mic()</a></code>) can now be used in any mathematical processing, such as usage inside functions <code><a href="https://rdrr.io/r/base/Extremes.html">min()</a></code>, <code><a href="https://rdrr.io/r/base/Extremes.html">max()</a></code>, <code><a href="https://rdrr.io/r/base/range.html">range()</a></code>, and with binary operators (<code><a href="https://rdrr.io/r/base/Arithmetic.html">+</a></code>, <code><a href="https://rdrr.io/r/base/Arithmetic.html">-</a></code>, etc.). This allows for easy distribution analysis and fast filtering on MIC values:</p>
|
<p>MIC values (see <code><a href="../reference/as.mic.html">as.mic()</a></code>) can now be used in any mathematical processing, such as usage inside functions <code><a href="https://rdrr.io/r/base/Extremes.html">min()</a></code>, <code><a href="https://rdrr.io/r/base/Extremes.html">max()</a></code>, <code><a href="https://rdrr.io/r/base/range.html">range()</a></code>, and with binary operators (<code><a href="https://rdrr.io/r/base/Arithmetic.html">+</a></code>, <code><a href="https://rdrr.io/r/base/Arithmetic.html">-</a></code>, etc.). This allows for easy distribution analysis and fast filtering on MIC values:</p>
|
||||||
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/random.html">random_mic</a></span><span class="op">(</span><span class="fl">10</span><span class="op">)</span>
|
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/random.html">random_mic</a></span><span class="op">(</span><span class="fl">10</span><span class="op">)</span>
|
||||||
<span class="va">x</span>
|
<span class="va">x</span>
|
||||||
|
@ -484,7 +509,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Functions <code><a href="../reference/get_episode.html">get_episode()</a></code> and <code><a href="../reference/get_episode.html">is_new_episode()</a></code> to determine (patient) episodes which are not necessarily based on microorganisms. The <code><a href="../reference/get_episode.html">get_episode()</a></code> function returns the index number of the episode per group, while the <code><a href="../reference/get_episode.html">is_new_episode()</a></code> function returns values <code>TRUE</code>/<code>FALSE</code> to indicate whether an item in a vector is the start of a new episode. They also support <code>dplyr</code>s grouping (i.e. using <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code>):</p>
|
<p>Functions <code><a href="../reference/get_episode.html">get_episode()</a></code> and <code><a href="../reference/get_episode.html">is_new_episode()</a></code> to determine (patient) episodes which are not necessarily based on microorganisms. The <code><a href="../reference/get_episode.html">get_episode()</a></code> function returns the index number of the episode per group, while the <code><a href="../reference/get_episode.html">is_new_episode()</a></code> function returns values <code>TRUE</code>/<code>FALSE</code> to indicate whether an item in a vector is the start of a new episode. They also support <code>dplyr</code>s grouping (i.e. using <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code>):</p>
|
||||||
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||||
|
@ -538,7 +563,7 @@
|
||||||
<code><a href="../reference/mdro.html">mdr_cmi2012()</a></code>,</li>
|
<code><a href="../reference/mdro.html">mdr_cmi2012()</a></code>,</li>
|
||||||
<li><code><a href="../reference/mdro.html">eucast_exceptional_phenotypes()</a></code></li>
|
<li><code><a href="../reference/mdro.html">eucast_exceptional_phenotypes()</a></code></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># to select first isolates that are Gram-negative </span>
|
<span class="co"># to select first isolates that are Gram-negative </span>
|
||||||
<span class="co"># and view results of cephalosporins and aminoglycosides:</span>
|
<span class="co"># and view results of cephalosporins and aminoglycosides:</span>
|
||||||
|
@ -550,7 +575,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>For antibiotic selection functions (such as <code><a href="../reference/antibiotic_class_selectors.html">cephalosporins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>) to select columns based on a certain antibiotic group, the dependency on the <code>tidyselect</code> 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):</p>
|
<p>For antibiotic selection functions (such as <code><a href="../reference/antibiotic_class_selectors.html">cephalosporins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">aminoglycosides()</a></code>) to select columns based on a certain antibiotic group, the dependency on the <code>tidyselect</code> 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):</p>
|
||||||
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># above example in base R:</span>
|
<span class="co"># above example in base R:</span>
|
||||||
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html">which</a></span><span class="op">(</span><span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="op">)</span> <span class="op">&</span> <span class="fu"><a href="../reference/mo_property.html">mo_is_gram_negative</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>,
|
<span class="va">example_isolates</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/which.html">which</a></span><span class="op">(</span><span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="op">)</span> <span class="op">&</span> <span class="fu"><a href="../reference/mo_property.html">mo_is_gram_negative</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>,
|
||||||
|
@ -600,7 +625,7 @@
|
||||||
<li>
|
<li>
|
||||||
<p>Data set <code>intrinsic_resistant</code>. 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: <code>microorganism</code> and <code>antibiotic</code>.</p>
|
<p>Data set <code>intrinsic_resistant</code>. 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: <code>microorganism</code> and <code>antibiotic</code>.</p>
|
||||||
<p>Curious about which enterococci are actually intrinsic resistant to vancomycin?</p>
|
<p>Curious about which enterococci are actually intrinsic resistant to vancomycin?</p>
|
||||||
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span>
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||||
|
@ -623,7 +648,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for using <code>dplyr</code>’s <code><a href="https://dplyr.tidyverse.org/reference/across.html">across()</a></code> to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.</p>
|
<p>Support for using <code>dplyr</code>’s <code><a href="https://dplyr.tidyverse.org/reference/across.html">across()</a></code> to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.</p>
|
||||||
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># until dplyr 1.0.0</span>
|
<span class="co"># until dplyr 1.0.0</span>
|
||||||
<span class="va">your_data</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_if</a></span><span class="op">(</span><span class="va">is.mic</span>, <span class="va">as.rsi</span><span class="op">)</span>
|
<span class="va">your_data</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_if</a></span><span class="op">(</span><span class="va">is.mic</span>, <span class="va">as.rsi</span><span class="op">)</span>
|
||||||
|
@ -641,7 +666,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>Added intelligent data cleaning to <code><a href="../reference/as.disk.html">as.disk()</a></code>, so numbers can also be extracted from text and decimal numbers will always be rounded up:</p>
|
<p>Added intelligent data cleaning to <code><a href="../reference/as.disk.html">as.disk()</a></code>, so numbers can also be extracted from text and decimal numbers will always be rounded up:</p>
|
||||||
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/as.disk.html">as.disk</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"disk zone: 23.4 mm"</span>, <span class="fl">23.4</span><span class="op">)</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/as.disk.html">as.disk</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"disk zone: 23.4 mm"</span>, <span class="fl">23.4</span><span class="op">)</span><span class="op">)</span>
|
||||||
<span class="co">#> Class <disk></span>
|
<span class="co">#> Class <disk></span>
|
||||||
|
@ -701,7 +726,7 @@
|
||||||
<li><p>Function <code><a href="../reference/ab_from_text.html">ab_from_text()</a></code> 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 <code><a href="../reference/as.ab.html">as.ab()</a></code> internally</p></li>
|
<li><p>Function <code><a href="../reference/ab_from_text.html">ab_from_text()</a></code> 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 <code><a href="../reference/as.ab.html">as.ab()</a></code> internally</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p><a href="https://tidyselect.r-lib.org/reference/language.html">Tidyverse selection helpers</a> 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 <code><a href="https://dplyr.tidyverse.org/reference/select.html">dplyr::select()</a></code> and <code><a href="https://tidyr.tidyverse.org/reference/pivot_longer.html">tidyr::pivot_longer()</a></code>:</p>
|
<p><a href="https://tidyselect.r-lib.org/reference/language.html">Tidyverse selection helpers</a> 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 <code><a href="https://dplyr.tidyverse.org/reference/select.html">dplyr::select()</a></code> and <code><a href="https://tidyr.tidyverse.org/reference/pivot_longer.html">tidyr::pivot_longer()</a></code>:</p>
|
||||||
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||||
|
|
||||||
|
@ -711,8 +736,8 @@
|
||||||
<span class="co">#> Selecting carbapenems: `IPM` (imipenem), `MEM` (meropenem)</span></code></pre></div>
|
<span class="co">#> Selecting carbapenems: `IPM` (imipenem), `MEM` (meropenem)</span></code></pre></div>
|
||||||
</li>
|
</li>
|
||||||
<li><p>Added <code><a href="../reference/mo_property.html">mo_domain()</a></code> as an alias to <code><a href="../reference/mo_property.html">mo_kingdom()</a></code></p></li>
|
<li><p>Added <code><a href="../reference/mo_property.html">mo_domain()</a></code> as an alias to <code><a href="../reference/mo_property.html">mo_kingdom()</a></code></p></li>
|
||||||
<li><p>Added function <code><a href="../reference/filter_ab_class.html">filter_penicillins()</a></code> to filter isolates on a specific result in any column with a name in the antimicrobial ‘penicillins’ class (more specific: ATC subgroup <em>Beta-lactam antibacterials, penicillins</em>)</p></li>
|
<li><p>Added function <code><a href="../reference/AMR-deprecated.html">filter_penicillins()</a></code> to filter isolates on a specific result in any column with a name in the antimicrobial ‘penicillins’ class (more specific: ATC subgroup <em>Beta-lactam antibacterials, penicillins</em>)</p></li>
|
||||||
<li><p>Added official antimicrobial names to all <code><a href="../reference/filter_ab_class.html">filter_ab_class()</a></code> functions, such as <code><a href="../reference/filter_ab_class.html">filter_aminoglycosides()</a></code></p></li>
|
<li><p>Added official antimicrobial names to all <code><a href="../reference/AMR-deprecated.html">filter_ab_class()</a></code> functions, such as <code><a href="../reference/AMR-deprecated.html">filter_aminoglycosides()</a></code></p></li>
|
||||||
<li><p>Added antibiotics code “FOX1” for cefoxitin screening (abbreviation “cfsc”) to the <code>antibiotics</code> data set</p></li>
|
<li><p>Added antibiotics code “FOX1” for cefoxitin screening (abbreviation “cfsc”) to the <code>antibiotics</code> data set</p></li>
|
||||||
<li><p>Added Monuril as trade name for fosfomycin</p></li>
|
<li><p>Added Monuril as trade name for fosfomycin</p></li>
|
||||||
<li><p>Added argument <code>conserve_capped_values</code> to <code><a href="../reference/as.rsi.html">as.rsi()</a></code> 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 <code><a href="../reference/as.rsi.html">as.rsi()</a></code> has not changed, so you need to specifically do <code><a href="../reference/as.rsi.html">as.rsi(..., conserve_capped_values = TRUE)</a></code>.</p></li>
|
<li><p>Added argument <code>conserve_capped_values</code> to <code><a href="../reference/as.rsi.html">as.rsi()</a></code> 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 <code><a href="../reference/as.rsi.html">as.rsi()</a></code> has not changed, so you need to specifically do <code><a href="../reference/as.rsi.html">as.rsi(..., conserve_capped_values = TRUE)</a></code>.</p></li>
|
||||||
|
@ -759,7 +784,7 @@
|
||||||
<li><p>Changed the summary for class <code><rsi></code>, to highlight the %SI vs. %R</p></li>
|
<li><p>Changed the summary for class <code><rsi></code>, to highlight the %SI vs. %R</p></li>
|
||||||
<li><p>Improved error handling, giving more useful info when functions return an error</p></li>
|
<li><p>Improved error handling, giving more useful info when functions return an error</p></li>
|
||||||
<li><p>Any progress bar will now only show in interactive mode (i.e. not in R Markdown)</p></li>
|
<li><p>Any progress bar will now only show in interactive mode (i.e. not in R Markdown)</p></li>
|
||||||
<li><p>Speed improvement for <code><a href="../reference/mdro.html">mdro()</a></code> and <code><a href="../reference/filter_ab_class.html">filter_ab_class()</a></code></p></li>
|
<li><p>Speed improvement for <code><a href="../reference/mdro.html">mdro()</a></code> and <code><a href="../reference/AMR-deprecated.html">filter_ab_class()</a></code></p></li>
|
||||||
<li><p>New option <code>arrows_textangled</code> for <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> to indicate whether the text at the end of the arrows should be angled (defaults to <code>TRUE</code>, as it was in previous versions)</p></li>
|
<li><p>New option <code>arrows_textangled</code> for <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> to indicate whether the text at the end of the arrows should be angled (defaults to <code>TRUE</code>, as it was in previous versions)</p></li>
|
||||||
<li><p>Added parenteral DDD to benzylpenicillin</p></li>
|
<li><p>Added parenteral DDD to benzylpenicillin</p></li>
|
||||||
<li><p>Fixed a bug where <code><a href="../reference/as.mic.html">as.mic()</a></code> could not handle dots without a leading zero (like <code>"<=.25</code>)</p></li>
|
<li><p>Fixed a bug where <code><a href="../reference/as.mic.html">as.mic()</a></code> could not handle dots without a leading zero (like <code>"<=.25</code>)</p></li>
|
||||||
|
@ -887,7 +912,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline</p></li>
|
<li><p>Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Interpretation from MIC values (and disk zones) to R/SI can now be used with <code><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at()</a></code> of the <code>dplyr</code> package:</p>
|
<p>Interpretation from MIC values (and disk zones) to R/SI can now be used with <code><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at()</a></code> of the <code>dplyr</code> package:</p>
|
||||||
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">yourdata</span> <span class="op">%>%</span>
|
<span class="va">yourdata</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">antibiotic1</span><span class="op">:</span><span class="va">antibiotic25</span><span class="op">)</span>, <span class="va">as.rsi</span>, mo <span class="op">=</span> <span class="st">"E. coli"</span><span class="op">)</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span><span class="op">(</span><span class="va">antibiotic1</span><span class="op">:</span><span class="va">antibiotic25</span><span class="op">)</span>, <span class="va">as.rsi</span>, mo <span class="op">=</span> <span class="st">"E. coli"</span><span class="op">)</span>
|
||||||
|
@ -915,7 +940,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for LOINC codes in the <code>antibiotics</code> data set. Use <code><a href="../reference/ab_property.html">ab_loinc()</a></code> to retrieve LOINC codes, or use a LOINC code for input in any <code>ab_*</code> function:</p>
|
<p>Support for LOINC codes in the <code>antibiotics</code> data set. Use <code><a href="../reference/ab_property.html">ab_loinc()</a></code> to retrieve LOINC codes, or use a LOINC code for input in any <code>ab_*</code> function:</p>
|
||||||
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/ab_property.html">ab_loinc</a></span><span class="op">(</span><span class="st">"ampicillin"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/ab_property.html">ab_loinc</a></span><span class="op">(</span><span class="st">"ampicillin"</span><span class="op">)</span>
|
||||||
<span class="co">#> [1] "21066-6" "3355-5" "33562-0" "33919-2" "43883-8" "43884-6" "87604-5"</span>
|
<span class="co">#> [1] "21066-6" "3355-5" "33562-0" "33919-2" "43883-8" "43884-6" "87604-5"</span>
|
||||||
|
@ -926,7 +951,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for SNOMED CT codes in the <code>microorganisms</code> data set. Use <code><a href="../reference/mo_property.html">mo_snomed()</a></code> to retrieve SNOMED codes, or use a SNOMED code for input in any <code>mo_*</code> function:</p>
|
<p>Support for SNOMED CT codes in the <code>microorganisms</code> data set. Use <code><a href="../reference/mo_property.html">mo_snomed()</a></code> to retrieve SNOMED codes, or use a SNOMED code for input in any <code>mo_*</code> function:</p>
|
||||||
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_snomed</a></span><span class="op">(</span><span class="st">"S. aureus"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/mo_property.html">mo_snomed</a></span><span class="op">(</span><span class="st">"S. aureus"</span><span class="op">)</span>
|
||||||
<span class="co">#> [1] 115329001 3092008 113961008</span>
|
<span class="co">#> [1] 115329001 3092008 113961008</span>
|
||||||
|
@ -990,11 +1015,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>If you were dependent on the old Enterobacteriaceae family e.g. by using in your code:</p>
|
<p>If you were dependent on the old Enterobacteriaceae family e.g. by using in your code:</p>
|
||||||
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_family</a></span><span class="op">(</span><span class="va">somebugs</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Enterobacteriaceae"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
|
<span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_family</a></span><span class="op">(</span><span class="va">somebugs</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Enterobacteriaceae"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
|
||||||
<p>then please adjust this to:</p>
|
<p>then please adjust this to:</p>
|
||||||
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">somebugs</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Enterobacterales"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
|
<span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_order</a></span><span class="op">(</span><span class="va">somebugs</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Enterobacterales"</span><span class="op">)</span> <span class="va">...</span></code></pre></div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -1008,7 +1033,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Functions <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> as aliases of <code><a href="../reference/proportion.html">proportion_SI()</a></code> and <code><a href="../reference/proportion.html">proportion_R()</a></code>, respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.</p>
|
<p>Functions <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> as aliases of <code><a href="../reference/proportion.html">proportion_SI()</a></code> and <code><a href="../reference/proportion.html">proportion_R()</a></code>, respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.</p>
|
||||||
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||||
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
<span class="va">example_isolates</span> <span class="op">%>%</span>
|
||||||
|
@ -1037,7 +1062,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>More intelligent way of coping with some consonants like “l” and “r”</p></li>
|
<li><p>More intelligent way of coping with some consonants like “l” and “r”</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Added a score (a certainty percentage) to <code><a href="../reference/as.mo.html">mo_uncertainties()</a></code>, that is calculated using the <a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a>:</p>
|
<p>Added a score (a certainty percentage) to <code><a href="../reference/as.mo.html">mo_uncertainties()</a></code>, that is calculated using the <a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a>:</p>
|
||||||
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Stafylococcus aureus"</span>,
|
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"Stafylococcus aureus"</span>,
|
||||||
<span class="st">"staphylokok aureuz"</span><span class="op">)</span><span class="op">)</span>
|
<span class="st">"staphylokok aureuz"</span><span class="op">)</span><span class="op">)</span>
|
||||||
|
@ -1095,14 +1120,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Determination of first isolates now <strong>excludes</strong> all ‘unknown’ microorganisms at default, i.e. microbial code <code>"UNKNOWN"</code>. They can be included with the new argument <code>include_unknown</code>:</p>
|
<p>Determination of first isolates now <strong>excludes</strong> all ‘unknown’ microorganisms at default, i.e. microbial code <code>"UNKNOWN"</code>. They can be included with the new argument <code>include_unknown</code>:</p>
|
||||||
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="va">...</span>, include_unknown <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="va">...</span>, include_unknown <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></code></pre></div>
|
||||||
<p>For WHONET users, this means that all records/isolates with organism code <code>"con"</code> (<em>contamination</em>) will be excluded at default, since <code>as.mo("con") = "UNKNOWN"</code>. The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.</p>
|
<p>For WHONET users, this means that all records/isolates with organism code <code>"con"</code> (<em>contamination</em>) will be excluded at default, since <code>as.mo("con") = "UNKNOWN"</code>. The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>For code consistency, classes <code>ab</code> and <code>mo</code> will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in <code>NA</code>:</p>
|
<p>For code consistency, classes <code>ab</code> and <code>mo</code> will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in <code>NA</code>:</p>
|
||||||
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># how it works in base R:</span>
|
<span class="co"># how it works in base R:</span>
|
||||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="st">"A"</span><span class="op">)</span>
|
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span><span class="st">"A"</span><span class="op">)</span>
|
||||||
|
@ -1127,7 +1152,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Function <code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> to quickly get a <code>data.frame</code> 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 <code><a href="../reference/mo_property.html">mo_shortname()</a></code> at default:</p>
|
<p>Function <code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> to quickly get a <code>data.frame</code> 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 <code><a href="../reference/mo_property.html">mo_shortname()</a></code> at default:</p>
|
||||||
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/bug_drug_combinations.html">bug_drug_combinations</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/bug_drug_combinations.html">bug_drug_combinations</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">)</span>
|
||||||
<span class="co">#> NOTE: Using column `mo` as input for `col_mo`.</span>
|
<span class="co">#> NOTE: Using column `mo` as input for `col_mo`.</span>
|
||||||
|
@ -1150,13 +1175,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<span class="co">#> 4 Gram-negative AMX 227 0 405 632</span>
|
<span class="co">#> 4 Gram-negative AMX 227 0 405 632</span>
|
||||||
<span class="co">#> NOTE: Use 'format()' on this result to get a publicable/printable format.</span></code></pre></div>
|
<span class="co">#> NOTE: Use 'format()' on this result to get a publicable/printable format.</span></code></pre></div>
|
||||||
<p>You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R <code><a href="https://rdrr.io/r/base/format.html">format()</a></code> function:</p>
|
<p>You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R <code><a href="https://rdrr.io/r/base/format.html">format()</a></code> function:</p>
|
||||||
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="https://rdrr.io/r/base/format.html">format</a></span><span class="op">(</span><span class="va">x</span>, combine_IR <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="https://rdrr.io/r/base/format.html">format</a></span><span class="op">(</span><span class="va">x</span>, combine_IR <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibility of a combination therapy. A new argument <code>only_all_tested</code> (<strong>which defaults to <code>FALSE</code></strong>) replaces the old <code>also_single_tested</code> 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 <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
|
<p>Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibility of a combination therapy. A new argument <code>only_all_tested</code> (<strong>which defaults to <code>FALSE</code></strong>) replaces the old <code>also_single_tested</code> 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 <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
|
||||||
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># --------------------------------------------------------------------</span>
|
<span class="co"># --------------------------------------------------------------------</span>
|
||||||
<span class="co"># only_all_tested = FALSE only_all_tested = TRUE</span>
|
<span class="co"># only_all_tested = FALSE only_all_tested = TRUE</span>
|
||||||
|
@ -1178,7 +1203,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p><code>tibble</code> printing support for classes <code>rsi</code>, <code>mic</code>, <code>disk</code>, <code>ab</code> <code>mo</code>. When using <code>tibble</code>s containing antimicrobial columns, values <code>S</code> will print in green, values <code>I</code> will print in yellow and values <code>R</code> will print in red. Microbial IDs (class <code>mo</code>) will emphasise on the genus and species, not on the kingdom.</p>
|
<p><code>tibble</code> printing support for classes <code>rsi</code>, <code>mic</code>, <code>disk</code>, <code>ab</code> <code>mo</code>. When using <code>tibble</code>s containing antimicrobial columns, values <code>S</code> will print in green, values <code>I</code> will print in yellow and values <code>R</code> will print in red. Microbial IDs (class <code>mo</code>) will emphasise on the genus and species, not on the kingdom.</p>
|
||||||
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># (run this on your own console, as this page does not support colour printing)</span>
|
<span class="co"># (run this on your own console, as this page does not support colour printing)</span>
|
||||||
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
<span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org">dplyr</a></span><span class="op">)</span>
|
||||||
|
@ -1229,7 +1254,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li>The <code>name</code> of <code>RIF</code> is now Rifampicin instead of Rifampin</li>
|
<li>The <code>name</code> of <code>RIF</code> is now Rifampicin instead of Rifampin</li>
|
||||||
<li>The <code>antibiotics</code> data set is now sorted by name and all cephalosporins now have their generation between brackets</li>
|
<li>The <code>antibiotics</code> data set is now sorted by name and all cephalosporins now have their generation between brackets</li>
|
||||||
<li>Speed improvement for <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code> which is now 30 times faster for antibiotic abbreviations</li>
|
<li>Speed improvement for <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code> which is now 30 times faster for antibiotic abbreviations</li>
|
||||||
<li>Improved <code><a href="../reference/filter_ab_class.html">filter_ab_class()</a></code> to be more reliable and to support 5th generation cephalosporins</li>
|
<li>Improved <code><a href="../reference/AMR-deprecated.html">filter_ab_class()</a></code> to be more reliable and to support 5th generation cephalosporins</li>
|
||||||
<li>Function <code><a href="../reference/availability.html">availability()</a></code> now uses <code>portion_R()</code> instead of <code>portion_IR()</code>, to comply with EUCAST insights</li>
|
<li>Function <code><a href="../reference/availability.html">availability()</a></code> now uses <code>portion_R()</code> instead of <code>portion_IR()</code>, to comply with EUCAST insights</li>
|
||||||
<li>Functions <code><a href="../reference/age.html">age()</a></code> and <code><a href="../reference/age_groups.html">age_groups()</a></code> now have a <code>na.rm</code> argument to remove empty values</li>
|
<li>Functions <code><a href="../reference/age.html">age()</a></code> and <code><a href="../reference/age_groups.html">age_groups()</a></code> now have a <code>na.rm</code> argument to remove empty values</li>
|
||||||
<li>Renamed function <code>p.symbol()</code> to <code><a href="../reference/AMR-deprecated.html">p_symbol()</a></code> (the former is now deprecated and will be removed in a future version)</li>
|
<li>Renamed function <code>p.symbol()</code> to <code><a href="../reference/AMR-deprecated.html">p_symbol()</a></code> (the former is now deprecated and will be removed in a future version)</li>
|
||||||
|
@ -1260,7 +1285,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Function <code><a href="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> 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 <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> to immediately show resistance percentages and number of available isolates:</p>
|
<p>Function <code><a href="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> 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 <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> to immediately show resistance percentages and number of available isolates:</p>
|
||||||
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">AMX</span>, <span class="va">CIP</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">AMX</span>, <span class="va">CIP</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
|
@ -1287,7 +1312,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li>UPEC (Uropathogenic <em>E. coli</em>)</li>
|
<li>UPEC (Uropathogenic <em>E. coli</em>)</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>All these lead to the microbial ID of <em>E. coli</em>:</p>
|
<p>All these lead to the microbial ID of <em>E. coli</em>:</p>
|
||||||
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"UPEC"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"UPEC"</span><span class="op">)</span>
|
||||||
<span class="co"># B_ESCHR_COL</span>
|
<span class="co"># B_ESCHR_COL</span>
|
||||||
|
@ -1391,7 +1416,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>when all values are unique it now shows a message instead of a warning</p></li>
|
<li><p>when all values are unique it now shows a message instead of a warning</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>support for boxplots:</p>
|
<p>support for boxplots:</p>
|
||||||
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||||
<span class="fu">freq</span><span class="op">(</span><span class="va">age</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu">freq</span><span class="op">(</span><span class="va">age</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
|
@ -1484,30 +1509,30 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:</p>
|
<p>New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:</p>
|
||||||
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
|
|
||||||
<code class="sourceCode R">
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_carbapenems</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_1st_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_2nd_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_3rd_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_4th_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_fluoroquinolones</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_glycopeptides</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_macrolides</a></span><span class="op">(</span><span class="op">)</span>
|
|
||||||
<span class="fu"><a href="../reference/filter_ab_class.html">filter_tetracyclines</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
|
|
||||||
<p>The <code>antibiotics</code> 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 <code>antibiotics</code> data set. For example:</p>
|
|
||||||
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/filter_ab_class.html">filter_glycopeptides</a></span><span class="op">(</span>result <span class="op">=</span> <span class="st">"R"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_carbapenems</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_1st_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_2nd_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_3rd_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_4th_cephalosporins</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_fluoroquinolones</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_glycopeptides</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_macrolides</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
|
<span class="fu"><a href="../reference/AMR-deprecated.html">filter_tetracyclines</a></span><span class="op">(</span><span class="op">)</span></code></pre></div>
|
||||||
|
<p>The <code>antibiotics</code> 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 <code>antibiotics</code> data set. For example:</p>
|
||||||
|
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
|
||||||
|
<code class="sourceCode R">
|
||||||
|
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/AMR-deprecated.html">filter_glycopeptides</a></span><span class="op">(</span>result <span class="op">=</span> <span class="st">"R"</span><span class="op">)</span>
|
||||||
<span class="co"># Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R</span>
|
<span class="co"># Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R</span>
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/filter_ab_class.html">filter_glycopeptides</a></span><span class="op">(</span>result <span class="op">=</span> <span class="st">"R"</span>, scope <span class="op">=</span> <span class="st">"all"</span><span class="op">)</span>
|
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/AMR-deprecated.html">filter_glycopeptides</a></span><span class="op">(</span>result <span class="op">=</span> <span class="st">"R"</span>, scope <span class="op">=</span> <span class="st">"all"</span><span class="op">)</span>
|
||||||
<span class="co"># Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R</span></code></pre></div>
|
<span class="co"># Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R</span></code></pre></div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>All <code>ab_*</code> functions are deprecated and replaced by <code>atc_*</code> functions:</p>
|
<p>All <code>ab_*</code> functions are deprecated and replaced by <code>atc_*</code> functions:</p>
|
||||||
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">ab_property</span> <span class="op">-></span> <span class="fu">atc_property</span><span class="op">(</span><span class="op">)</span>
|
<span class="va">ab_property</span> <span class="op">-></span> <span class="fu">atc_property</span><span class="op">(</span><span class="op">)</span>
|
||||||
<span class="va">ab_name</span> <span class="op">-></span> <span class="fu">atc_name</span><span class="op">(</span><span class="op">)</span>
|
<span class="va">ab_name</span> <span class="op">-></span> <span class="fu">atc_name</span><span class="op">(</span><span class="op">)</span>
|
||||||
|
@ -1528,7 +1553,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>New function <code><a href="../reference/age_groups.html">age_groups()</a></code> to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic AMR data analysis per age group.</p></li>
|
<li><p>New function <code><a href="../reference/age_groups.html">age_groups()</a></code> to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic AMR data analysis per age group.</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>New function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> as well as the base R <code><a href="../reference/plot.html">plot()</a></code> function can now be used for resistance prediction calculated with <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>:</p>
|
<p>New function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> as well as the base R <code><a href="../reference/plot.html">plot()</a></code> function can now be used for resistance prediction calculated with <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>:</p>
|
||||||
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span><span class="va">septic_patients</span>, col_ab <span class="op">=</span> <span class="st">"amox"</span><span class="op">)</span>
|
<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span><span class="va">septic_patients</span>, col_ab <span class="op">=</span> <span class="st">"amox"</span><span class="op">)</span>
|
||||||
<span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>
|
||||||
|
@ -1536,13 +1561,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>Functions <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code><a href="../reference/AMR-deprecated.html">filter_first_weighted_isolate()</a></code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.:</p>
|
<p>Functions <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code><a href="../reference/AMR-deprecated.html">filter_first_weighted_isolate()</a></code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.:</p>
|
||||||
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="va">...</span><span class="op">)</span>
|
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="va">...</span><span class="op">)</span>
|
||||||
<span class="co"># or</span>
|
<span class="co"># or</span>
|
||||||
<span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="va">...</span><span class="op">)</span></code></pre></div>
|
<span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="va">...</span><span class="op">)</span></code></pre></div>
|
||||||
<p>is equal to:</p>
|
<p>is equal to:</p>
|
||||||
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>only_firsts <span class="op">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="va">...</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>only_firsts <span class="op">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="va">...</span><span class="op">)</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
|
@ -1575,7 +1600,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Now handles incorrect spelling, like <code>i</code> instead of <code>y</code> and <code>f</code> instead of <code>ph</code>:</p>
|
<p>Now handles incorrect spelling, like <code>i</code> instead of <code>y</code> and <code>f</code> instead of <code>ph</code>:</p>
|
||||||
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># mo_fullname() uses as.mo() internally</span>
|
<span class="co"># mo_fullname() uses as.mo() internally</span>
|
||||||
|
|
||||||
|
@ -1587,7 +1612,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default <code>allow_uncertain = TRUE</code> is equal to uncertainty level 2. Run <code><a href="../reference/as.mo.html">?as.mo</a></code> for more info about these levels.</p>
|
<p>Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default <code>allow_uncertain = TRUE</code> is equal to uncertainty level 2. Run <code><a href="../reference/as.mo.html">?as.mo</a></code> for more info about these levels.</p>
|
||||||
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># equal:</span>
|
<span class="co"># equal:</span>
|
||||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">...</span>, allow_uncertain <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">...</span>, allow_uncertain <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>
|
||||||
|
@ -1602,7 +1627,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>All microbial IDs that found are now saved to a local file <code>~/.Rhistory_mo</code>. Use the new function <code>clean_mo_history()</code> to delete this file, which resets the algorithms.</p></li>
|
<li><p>All microbial IDs that found are now saved to a local file <code>~/.Rhistory_mo</code>. Use the new function <code>clean_mo_history()</code> to delete this file, which resets the algorithms.</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Incoercible results will now be considered ‘unknown’, MO code <code>UNKNOWN</code>. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:</p>
|
<p>Incoercible results will now be considered ‘unknown’, MO code <code>UNKNOWN</code>. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:</p>
|
||||||
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"qwerty"</span>, language <span class="op">=</span> <span class="st">"es"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"qwerty"</span>, language <span class="op">=</span> <span class="st">"es"</span><span class="op">)</span>
|
||||||
<span class="co"># Warning: </span>
|
<span class="co"># Warning: </span>
|
||||||
|
@ -1652,7 +1677,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:</p>
|
<p>Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:</p>
|
||||||
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="co"># Determine genus of microorganisms (mo) in `septic_patients` data set:</span>
|
<span class="co"># Determine genus of microorganisms (mo) in `septic_patients` data set:</span>
|
||||||
<span class="co"># OLD WAY</span>
|
<span class="co"># OLD WAY</span>
|
||||||
|
@ -1735,7 +1760,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>Fewer than 3 characters as input for <code>as.mo</code> will return NA</p></li>
|
<li><p>Fewer than 3 characters as input for <code>as.mo</code> will return NA</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Function <code>as.mo</code> (and all <code>mo_*</code> wrappers) now supports genus abbreviations with “species” attached</p>
|
<p>Function <code>as.mo</code> (and all <code>mo_*</code> wrappers) now supports genus abbreviations with “species” attached</p>
|
||||||
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"E. species"</span><span class="op">)</span> <span class="co"># B_ESCHR</span>
|
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"E. species"</span><span class="op">)</span> <span class="co"># B_ESCHR</span>
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="st">"E. spp."</span><span class="op">)</span> <span class="co"># "Escherichia species"</span>
|
<span class="fu"><a href="../reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="st">"E. spp."</span><span class="op">)</span> <span class="co"># "Escherichia species"</span>
|
||||||
|
@ -1752,7 +1777,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for grouping variables, test with:</p>
|
<p>Support for grouping variables, test with:</p>
|
||||||
<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||||
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">hospital_id</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">hospital_id</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
|
@ -1760,7 +1785,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for (un)selecting columns:</p>
|
<p>Support for (un)selecting columns:</p>
|
||||||
<div class="sourceCode" id="cb42"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
<span class="va">septic_patients</span> <span class="op">%>%</span>
|
||||||
<span class="fu">freq</span><span class="op">(</span><span class="va">hospital_id</span><span class="op">)</span> <span class="op">%>%</span>
|
<span class="fu">freq</span><span class="op">(</span><span class="va">hospital_id</span><span class="op">)</span> <span class="op">%>%</span>
|
||||||
|
@ -1839,7 +1864,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:</p>
|
<p>They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:</p>
|
||||||
<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="st">"E. coli"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="st">"E. coli"</span><span class="op">)</span>
|
||||||
<span class="co"># [1] "Gram negative"</span>
|
<span class="co"># [1] "Gram negative"</span>
|
||||||
|
@ -1850,7 +1875,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="st">"S. group A"</span>, language <span class="op">=</span> <span class="st">"pt"</span><span class="op">)</span> <span class="co"># Portuguese</span>
|
<span class="fu"><a href="../reference/mo_property.html">mo_fullname</a></span><span class="op">(</span><span class="st">"S. group A"</span>, language <span class="op">=</span> <span class="st">"pt"</span><span class="op">)</span> <span class="co"># Portuguese</span>
|
||||||
<span class="co"># [1] "Streptococcus grupo A"</span></code></pre></div>
|
<span class="co"># [1] "Streptococcus grupo A"</span></code></pre></div>
|
||||||
<p>Furthermore, former taxonomic names will give a note about the current taxonomic name:</p>
|
<p>Furthermore, former taxonomic names will give a note about the current taxonomic name:</p>
|
||||||
<div class="sourceCode" id="cb44"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="st">"Esc blattae"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="st">"Esc blattae"</span><span class="op">)</span>
|
||||||
<span class="co"># Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)</span>
|
<span class="co"># Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)</span>
|
||||||
|
@ -1865,7 +1890,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>Function <code>is.rsi.eligible</code> to check for columns that have valid antimicrobial results, but do not have the <code>rsi</code> class yet. Transform the columns of your raw data with: <code>data %>% mutate_if(is.rsi.eligible, as.rsi)</code></p></li>
|
<li><p>Function <code>is.rsi.eligible</code> to check for columns that have valid antimicrobial results, but do not have the <code>rsi</code> class yet. Transform the columns of your raw data with: <code>data %>% mutate_if(is.rsi.eligible, as.rsi)</code></p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Functions <code>as.mo</code> and <code>is.mo</code> as replacements for <code>as.bactid</code> and <code>is.bactid</code> (since the <code>microoganisms</code> data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The <code>as.mo</code> function determines microbial IDs using intelligent rules:</p>
|
<p>Functions <code>as.mo</code> and <code>is.mo</code> as replacements for <code>as.bactid</code> and <code>is.bactid</code> (since the <code>microoganisms</code> data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The <code>as.mo</code> function determines microbial IDs using intelligent rules:</p>
|
||||||
<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"E. coli"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"E. coli"</span><span class="op">)</span>
|
||||||
<span class="co"># [1] B_ESCHR_COL</span>
|
<span class="co"># [1] B_ESCHR_COL</span>
|
||||||
|
@ -1874,7 +1899,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"S group A"</span><span class="op">)</span>
|
<span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"S group A"</span><span class="op">)</span>
|
||||||
<span class="co"># [1] B_STRPTC_GRA</span></code></pre></div>
|
<span class="co"># [1] B_STRPTC_GRA</span></code></pre></div>
|
||||||
<p>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:</p>
|
<p>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:</p>
|
||||||
<div class="sourceCode" id="cb46"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">thousands_of_E_colis</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html">rep</a></span><span class="op">(</span><span class="st">"E. coli"</span>, <span class="fl">25000</span><span class="op">)</span>
|
<span class="va">thousands_of_E_colis</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/rep.html">rep</a></span><span class="op">(</span><span class="st">"E. coli"</span>, <span class="fl">25000</span><span class="op">)</span>
|
||||||
<span class="fu">microbenchmark</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span><span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">thousands_of_E_colis</span><span class="op">)</span>, unit <span class="op">=</span> <span class="st">"s"</span><span class="op">)</span>
|
<span class="fu">microbenchmark</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span><span class="op">(</span><span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">thousands_of_E_colis</span><span class="op">)</span>, unit <span class="op">=</span> <span class="st">"s"</span><span class="op">)</span>
|
||||||
|
@ -1908,7 +1933,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>Added three antimicrobial agents to the <code>antibiotics</code> data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)</p></li>
|
<li><p>Added three antimicrobial agents to the <code>antibiotics</code> data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)</p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Added 163 trade names to the <code>antibiotics</code> data set, it now contains 298 different trade names in total, e.g.:</p>
|
<p>Added 163 trade names to the <code>antibiotics</code> data set, it now contains 298 different trade names in total, e.g.:</p>
|
||||||
<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb48"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="fu">ab_official</span><span class="op">(</span><span class="st">"Bactroban"</span><span class="op">)</span>
|
<span class="fu">ab_official</span><span class="op">(</span><span class="st">"Bactroban"</span><span class="op">)</span>
|
||||||
<span class="co"># [1] "Mupirocin"</span>
|
<span class="co"># [1] "Mupirocin"</span>
|
||||||
|
@ -1925,7 +1950,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>Added arguments <code>minimum</code> and <code>as_percent</code> to <code>portion_df</code></p></li>
|
<li><p>Added arguments <code>minimum</code> and <code>as_percent</code> to <code>portion_df</code></p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for quasiquotation in the functions series <code>count_*</code> and <code>portions_*</code>, and <code>n_rsi</code>. This allows to check for more than 2 vectors or columns.</p>
|
<p>Support for quasiquotation in the functions series <code>count_*</code> and <code>portions_*</code>, and <code>n_rsi</code>. This allows to check for more than 2 vectors or columns.</p>
|
||||||
<div class="sourceCode" id="cb48"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb49"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">amox</span>, <span class="va">cipr</span><span class="op">)</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/count.html">count_IR</a></span><span class="op">(</span><span class="op">)</span>
|
<span class="va">septic_patients</span> <span class="op">%>%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">amox</span>, <span class="va">cipr</span><span class="op">)</span> <span class="op">%>%</span> <span class="fu"><a href="../reference/count.html">count_IR</a></span><span class="op">(</span><span class="op">)</span>
|
||||||
<span class="co"># which is the same as:</span>
|
<span class="co"># which is the same as:</span>
|
||||||
|
@ -1945,12 +1970,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
|
||||||
<li><p>Added longest en shortest character length in the frequency table (<code>freq</code>) header of class <code>character</code></p></li>
|
<li><p>Added longest en shortest character length in the frequency table (<code>freq</code>) header of class <code>character</code></p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Support for types (classes) list and matrix for <code>freq</code></p>
|
<p>Support for types (classes) list and matrix for <code>freq</code></p>
|
||||||
<div class="sourceCode" id="cb49"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb50"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">my_matrix</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/with.html">with</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="va">age</span>, <span class="va">gender</span><span class="op">)</span>, ncol <span class="op">=</span> <span class="fl">2</span><span class="op">)</span><span class="op">)</span>
|
<span class="va">my_matrix</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/with.html">with</a></span><span class="op">(</span><span class="va">septic_patients</span>, <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="va">age</span>, <span class="va">gender</span><span class="op">)</span>, ncol <span class="op">=</span> <span class="fl">2</span><span class="op">)</span><span class="op">)</span>
|
||||||
<span class="fu">freq</span><span class="op">(</span><span class="va">my_matrix</span><span class="op">)</span></code></pre></div>
|
<span class="fu">freq</span><span class="op">(</span><span class="va">my_matrix</span><span class="op">)</span></code></pre></div>
|
||||||
<p>For lists, subsetting is possible:</p>
|
<p>For lists, subsetting is possible:</p>
|
||||||
<div class="sourceCode" id="cb50"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb51"><pre class="downlit sourceCode r">
|
||||||
<code class="sourceCode R">
|
<code class="sourceCode R">
|
||||||
<span class="va">my_list</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>age <span class="op">=</span> <span class="va">septic_patients</span><span class="op">$</span><span class="va">age</span>, gender <span class="op">=</span> <span class="va">septic_patients</span><span class="op">$</span><span class="va">gender</span><span class="op">)</span>
|
<span class="va">my_list</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span><span class="op">(</span>age <span class="op">=</span> <span class="va">septic_patients</span><span class="op">$</span><span class="va">age</span>, gender <span class="op">=</span> <span class="va">septic_patients</span><span class="op">$</span><span class="va">gender</span><span class="op">)</span>
|
||||||
<span class="va">my_list</span> <span class="op">%>%</span> <span class="fu">freq</span><span class="op">(</span><span class="va">age</span><span class="op">)</span>
|
<span class="va">my_list</span> <span class="op">%>%</span> <span class="fu">freq</span><span class="op">(</span><span class="va">age</span><span class="op">)</span>
|
||||||
|
|
|
@ -12,7 +12,7 @@ articles:
|
||||||
datasets: datasets.html
|
datasets: datasets.html
|
||||||
resistance_predict: resistance_predict.html
|
resistance_predict: resistance_predict.html
|
||||||
welcome_to_AMR: welcome_to_AMR.html
|
welcome_to_AMR: welcome_to_AMR.html
|
||||||
last_built: 2021-05-18T08:50Z
|
last_built: 2021-05-19T20:49Z
|
||||||
urls:
|
urls:
|
||||||
reference: https://msberends.github.io/AMR//reference
|
reference: https://msberends.github.io/AMR//reference
|
||||||
article: https://msberends.github.io/AMR//articles
|
article: https://msberends.github.io/AMR//articles
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9015</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ref-description">
|
<div class="ref-description">
|
||||||
<p>These functions are so-called '<a href='https://rdrr.io/r/base/Deprecated.html'>Deprecated</a>'. 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>
|
<p>These functions are so-called '<a href='https://rdrr.io/r/base/Deprecated.html'>Deprecated</a>'. <strong>They will be removed in a future release.</strong> Using the functions will give a warning with the name of the function it has been replaced by (if there is one).</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<pre class="usage"><span class='fu'>p_symbol</span><span class='op'>(</span><span class='va'>p</span>, emptychar <span class='op'>=</span> <span class='st'>" "</span><span class='op'>)</span>
|
<pre class="usage"><span class='fu'>p_symbol</span><span class='op'>(</span><span class='va'>p</span>, emptychar <span class='op'>=</span> <span class='st'>" "</span><span class='op'>)</span>
|
||||||
|
@ -286,9 +286,141 @@
|
||||||
info <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
info <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
na.rm <span class='op'>=</span> <span class='cn'>TRUE</span>,
|
na.rm <span class='op'>=</span> <span class='cn'>TRUE</span>,
|
||||||
<span class='va'>...</span>
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_ab_class</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
<span class='va'>ab_class</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_aminoglycosides</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_betalactams</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_carbapenems</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_cephalosporins</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_1st_cephalosporins</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_2nd_cephalosporins</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_3rd_cephalosporins</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_4th_cephalosporins</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_5th_cephalosporins</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_fluoroquinolones</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_glycopeptides</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_macrolides</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_oxazolidinones</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_penicillins</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
|
<span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='fu'>filter_tetracyclines</span><span class='op'>(</span>
|
||||||
|
<span class='va'>x</span>,
|
||||||
|
result <span class='op'>=</span> <span class='cn'>NULL</span>,
|
||||||
|
scope <span class='op'>=</span> <span class='st'>"any"</span>,
|
||||||
|
only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>,
|
||||||
|
<span class='va'>...</span>
|
||||||
<span class='op'>)</span></pre>
|
<span class='op'>)</span></pre>
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
||||||
|
|
||||||
|
<p>All antibiotic class selectors (such as <code><a href='antibiotic_class_selectors.html'>carbapenems()</a></code>, <code><a href='antibiotic_class_selectors.html'>aminoglycosides()</a></code>) can now be used for filtering as well, making all their accompanying <code>filter_*()</code> functions redundant (such as <code>filter_carbapenems()</code>, <code>filter_aminoglycosides()</code>).</p>
|
||||||
<h2 class="hasAnchor" id="retired-lifecycle"><a class="anchor" href="#retired-lifecycle"></a>Retired Lifecycle</h2>
|
<h2 class="hasAnchor" id="retired-lifecycle"><a class="anchor" href="#retired-lifecycle"></a>Retired Lifecycle</h2>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
<script src="../extra.js"></script>
|
<script src="../extra.js"></script>
|
||||||
|
|
||||||
<meta property="og:title" content="Antibiotic Class Selectors — antibiotic_class_selectors" />
|
<meta property="og:title" content="Antibiotic Class Selectors — antibiotic_class_selectors" />
|
||||||
<meta property="og:description" content="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.
|
<meta property="og:description" content="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.
|
||||||
" />
|
" />
|
||||||
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
|
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ref-description">
|
<div class="ref-description">
|
||||||
<p>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>
|
<p>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>
|
||||||
</strong></p>
|
</strong></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -293,7 +293,8 @@
|
||||||
|
|
||||||
<p><strong>
|
<p><strong>
|
||||||
</strong></p>
|
</strong></p>
|
||||||
<p>All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the <a href='antibiotics.html'>antibiotics</a> data set. This means that a selector like e.g. <code>aminoglycosides()</code> will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.</p>
|
<p>These functions can be used in data set calls for selecting columns and filtering rows, see <em>Examples</em>. They support base R, but work more convenient in dplyr functions such as <code><a href='https://dplyr.tidyverse.org/reference/select.html'>select()</a></code>, <code><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter()</a></code> and <code><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise()</a></code>.</p>
|
||||||
|
<p>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 <a href='antibiotics.html'>antibiotics</a> data set. This means that a selector like e.g. <code>aminoglycosides()</code> will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.</p>
|
||||||
<p>The group of betalactams consists of all carbapenems, cephalosporins and penicillins.</p>
|
<p>The group of betalactams consists of all carbapenems, cephalosporins and penicillins.</p>
|
||||||
<h2 class="hasAnchor" id="stable-lifecycle"><a class="anchor" href="#stable-lifecycle"></a>Stable Lifecycle</h2>
|
<h2 class="hasAnchor" id="stable-lifecycle"><a class="anchor" href="#stable-lifecycle"></a>Stable Lifecycle</h2>
|
||||||
|
|
||||||
|
@ -312,19 +313,36 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
|
||||||
|
|
||||||
|
|
||||||
<p>On our website <a href='https://msberends.github.io/AMR/'>https://msberends.github.io/AMR/</a> you can find <a href='https://msberends.github.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR data analysis, the <a href='https://msberends.github.io/AMR/reference/'>complete documentation of all functions</a> and <a href='https://msberends.github.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>. As we would like to better understand the backgrounds and needs of our users, please <a href='https://msberends.github.io/AMR/survey.html'>participate in our survey</a>!</p>
|
<p>On our website <a href='https://msberends.github.io/AMR/'>https://msberends.github.io/AMR/</a> you can find <a href='https://msberends.github.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR data analysis, the <a href='https://msberends.github.io/AMR/reference/'>complete documentation of all functions</a> and <a href='https://msberends.github.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>. As we would like to better understand the backgrounds and needs of our users, please <a href='https://msberends.github.io/AMR/survey.html'>participate in our survey</a>!</p>
|
||||||
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
|
|
||||||
|
|
||||||
<div class='dont-index'><p><code><a href='filter_ab_class.html'>filter_ab_class()</a></code> for the <code><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter()</a></code> equivalent.</p></div>
|
|
||||||
|
|
||||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||||
<pre class="examples"><span class='co'># `example_isolates` is a data set available in the AMR package.</span>
|
<pre class="examples"><span class='co'># `example_isolates` is a data set available in the AMR package.</span>
|
||||||
<span class='co'># See ?example_isolates.</span>
|
<span class='co'># See ?example_isolates.</span>
|
||||||
|
|
||||||
<span class='co'># this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):</span>
|
<span class='co'># Base R ------------------------------------------------------------------</span>
|
||||||
|
|
||||||
|
<span class='co'># select columns 'IPM' (imipenem) and 'MEM' (meropenem)</span>
|
||||||
<span class='va'>example_isolates</span><span class='op'>[</span>, <span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>]</span>
|
<span class='va'>example_isolates</span><span class='op'>[</span>, <span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>]</span>
|
||||||
<span class='co'># this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':</span>
|
|
||||||
|
<span class='co'># select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'</span>
|
||||||
<span class='va'>example_isolates</span><span class='op'>[</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"mo"</span>, <span class='fu'>aminoglycosides</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='op'>]</span>
|
<span class='va'>example_isolates</span><span class='op'>[</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"mo"</span>, <span class='fu'>aminoglycosides</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='op'>]</span>
|
||||||
|
|
||||||
|
<span class='co'># filter using any() or all()</span>
|
||||||
|
<span class='va'>example_isolates</span><span class='op'>[</span><span class='fu'><a href='https://rdrr.io/r/base/any.html'>any</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span>, <span class='op'>]</span>
|
||||||
|
<span class='fu'><a href='https://rdrr.io/r/base/subset.html'>subset</a></span><span class='op'>(</span><span class='va'>example_isolates</span>, <span class='fu'><a href='https://rdrr.io/r/base/any.html'>any</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span><span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='co'># filter on any or all results in the carbapenem columns (i.e., IPM, MEM):</span>
|
||||||
|
<span class='va'>example_isolates</span><span class='op'>[</span><span class='fu'><a href='https://rdrr.io/r/base/any.html'>any</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span>, <span class='op'>]</span>
|
||||||
|
<span class='va'>example_isolates</span><span class='op'>[</span><span class='fu'><a href='https://rdrr.io/r/base/all.html'>all</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span>, <span class='op'>]</span>
|
||||||
|
|
||||||
|
<span class='co'># filter with multiple antibiotic selectors using c()</span>
|
||||||
|
<span class='va'>example_isolates</span><span class='op'>[</span><span class='fu'><a href='https://rdrr.io/r/base/all.html'>all</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span>, <span class='fu'>aminoglycosides</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span>, <span class='op'>]</span>
|
||||||
|
|
||||||
|
<span class='co'># filter + select in one go: get penicillins in carbapenems-resistant strains</span>
|
||||||
|
<span class='va'>example_isolates</span><span class='op'>[</span><span class='fu'><a href='https://rdrr.io/r/base/any.html'>any</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span>, <span class='fu'>penicillins</span><span class='op'>(</span><span class='op'>)</span><span class='op'>]</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='co'># dplyr -------------------------------------------------------------------</span>
|
||||||
|
|
||||||
<span class='kw'>if</span> <span class='op'>(</span><span class='kw'><a href='https://rdrr.io/r/base/library.html'>require</a></span><span class='op'>(</span><span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span><span class='op'>)</span><span class='op'>)</span> <span class='op'>{</span>
|
<span class='kw'>if</span> <span class='op'>(</span><span class='kw'><a href='https://rdrr.io/r/base/library.html'>require</a></span><span class='op'>(</span><span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span><span class='op'>)</span><span class='op'>)</span> <span class='op'>{</span>
|
||||||
|
|
||||||
<span class='co'># this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):</span>
|
<span class='co'># this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):</span>
|
||||||
|
@ -335,6 +353,20 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
|
||||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>mo</span>, <span class='fu'>aminoglycosides</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span>
|
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>mo</span>, <span class='fu'>aminoglycosides</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='co'># any() and all() work in dplyr's filter() too:</span>
|
||||||
|
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||||
|
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/any.html'>any</a></span><span class='op'>(</span><span class='fu'>aminoglycosides</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span>,
|
||||||
|
<span class='fu'><a href='https://rdrr.io/r/base/all.html'>all</a></span><span class='op'>(</span><span class='fu'>cephalosporins_2nd</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span><span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='co'># also works with c():</span>
|
||||||
|
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||||
|
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/any.html'>any</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span>, <span class='fu'>aminoglycosides</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span><span class='op'>)</span>
|
||||||
|
|
||||||
|
<span class='co'># not setting any/all will automatically apply all():</span>
|
||||||
|
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||||
|
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='fu'>aminoglycosides</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span>
|
||||||
|
<span class='co'>#> i Assuming a filter on all 4 aminoglycosides.</span>
|
||||||
|
|
||||||
<span class='co'># this will select columns 'mo' and all antimycobacterial drugs ('RIF'):</span>
|
<span class='co'># this will select columns 'mo' and all antimycobacterial drugs ('RIF'):</span>
|
||||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
<span class='va'>example_isolates</span> <span class='op'>%>%</span>
|
||||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>mo</span>, <span class='fu'>ab_class</span><span class='op'>(</span><span class='st'>"mycobact"</span><span class='op'>)</span><span class='op'>)</span>
|
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='va'>mo</span>, <span class='fu'>ab_class</span><span class='op'>(</span><span class='st'>"mycobact"</span><span class='op'>)</span><span class='op'>)</span>
|
||||||
|
@ -353,10 +385,11 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
|
||||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='fu'>penicillins</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span> <span class='co'># only the 'J01CA01' column will be selected</span>
|
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span><span class='op'>(</span><span class='fu'>penicillins</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span> <span class='co'># only the 'J01CA01' column will be selected</span>
|
||||||
|
|
||||||
|
|
||||||
<span class='co'># with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:</span>
|
<span class='co'># with dplyr 1.0.0 and higher (that adds 'across()'), this is all equal:</span>
|
||||||
<span class='co'># (though the row names on the first are more correct)</span>
|
<span class='co'># (though the row names on the first are more correct)</span>
|
||||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span> <span class='fu'><a href='filter_ab_class.html'>filter_carbapenems</a></span><span class='op'>(</span><span class='st'>"R"</span>, <span class='st'>"all"</span><span class='op'>)</span>
|
<span class='va'>example_isolates</span><span class='op'>[</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span>, <span class='op'>]</span>
|
||||||
<span class='va'>example_isolates</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span>, <span class='op'>~</span><span class='va'>.</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span><span class='op'>)</span>
|
<span class='va'>example_isolates</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span>
|
||||||
|
<span class='va'>example_isolates</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span><span class='op'>(</span><span class='fu'>carbapenems</span><span class='op'>(</span><span class='op'>)</span>, <span class='op'>~</span><span class='va'>.x</span> <span class='op'>==</span> <span class='st'>"R"</span><span class='op'>)</span><span class='op'>)</span>
|
||||||
<span class='op'>}</span>
|
<span class='op'>}</span>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -81,7 +81,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">
|
<th colspan="2">
|
||||||
<h2 id="section-analysing-data-antimicrobial-resistance" class="hasAnchor"><a href="#section-analysing-data-antimicrobial-resistance" class="anchor"></a>Analysing data: antimicrobial resistance</h2>
|
<h2 id="section-analysing-data-antimicrobial-resistance" class="hasAnchor"><a href="#section-analysing-data-antimicrobial-resistance" class="anchor"></a>Analysing data: antimicrobial resistance</h2>
|
||||||
<p class="section-desc"><p>Use these function for the analysis part. You can use <code><a href="../reference/proportion.html">susceptibility()</a></code> or <code><a href="../reference/proportion.html">resistance()</a></code> on any antibiotic column. Be sure to first select the isolates that are appropiate for analysis, by using <code><a href="../reference/first_isolate.html">first_isolate()</a></code> or <code><a href="../reference/get_episode.html">is_new_episode()</a></code>. You can also filter your data on certain resistance in certain antibiotic classes (<code><a href="../reference/filter_ab_class.html">filter_ab_class()</a></code>), or determine multi-drug resistant microorganisms (MDRO, <code><a href="../reference/mdro.html">mdro()</a></code>).</p></p>
|
<p class="section-desc"><p>Use these function for the analysis part. You can use <code><a href="../reference/proportion.html">susceptibility()</a></code> or <code><a href="../reference/proportion.html">resistance()</a></code> on any antibiotic column. Be sure to first select the isolates that are appropiate for analysis, by using <code><a href="../reference/first_isolate.html">first_isolate()</a></code> or <code><a href="../reference/get_episode.html">is_new_episode()</a></code>. You can also filter your data on certain resistance in certain antibiotic classes (<code><a href="../reference/AMR-deprecated.html">filter_ab_class()</a></code>), or determine multi-drug resistant microorganisms (MDRO, <code><a href="../reference/mdro.html">mdro()</a></code>).</p></p>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -532,9 +532,9 @@
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<p><code><a href="filter_ab_class.html">filter_ab_class()</a></code> <code><a href="filter_ab_class.html">filter_aminoglycosides()</a></code> <code><a href="filter_ab_class.html">filter_betalactams()</a></code> <code><a href="filter_ab_class.html">filter_carbapenems()</a></code> <code><a href="filter_ab_class.html">filter_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_1st_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_2nd_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_3rd_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_4th_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_5th_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_fluoroquinolones()</a></code> <code><a href="filter_ab_class.html">filter_glycopeptides()</a></code> <code><a href="filter_ab_class.html">filter_macrolides()</a></code> <code><a href="filter_ab_class.html">filter_oxazolidinones()</a></code> <code><a href="filter_ab_class.html">filter_penicillins()</a></code> <code><a href="filter_ab_class.html">filter_tetracyclines()</a></code> </p>
|
<p><code><a href="AMR-deprecated.html">p_symbol()</a></code> <code><a href="AMR-deprecated.html">filter_first_weighted_isolate()</a></code> <code><a href="AMR-deprecated.html">key_antibiotics()</a></code> <code><a href="AMR-deprecated.html">key_antibiotics_equal()</a></code> <code><a href="AMR-deprecated.html">filter_ab_class()</a></code> <code><a href="AMR-deprecated.html">filter_aminoglycosides()</a></code> <code><a href="AMR-deprecated.html">filter_betalactams()</a></code> <code><a href="AMR-deprecated.html">filter_carbapenems()</a></code> <code><a href="AMR-deprecated.html">filter_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_1st_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_2nd_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_3rd_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_4th_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_5th_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_fluoroquinolones()</a></code> <code><a href="AMR-deprecated.html">filter_glycopeptides()</a></code> <code><a href="AMR-deprecated.html">filter_macrolides()</a></code> <code><a href="AMR-deprecated.html">filter_oxazolidinones()</a></code> <code><a href="AMR-deprecated.html">filter_penicillins()</a></code> <code><a href="AMR-deprecated.html">filter_tetracyclines()</a></code> </p>
|
||||||
</td>
|
</td>
|
||||||
<td><p>Filter Isolates on Result in Antimicrobial Class</p></td>
|
<td><p>Deprecated Functions</p></td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
@ -673,7 +673,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<p><code><a href="AMR-deprecated.html">p_symbol()</a></code> <code><a href="AMR-deprecated.html">filter_first_weighted_isolate()</a></code> <code><a href="AMR-deprecated.html">key_antibiotics()</a></code> <code><a href="AMR-deprecated.html">key_antibiotics_equal()</a></code> </p>
|
<p><code><a href="AMR-deprecated.html">p_symbol()</a></code> <code><a href="AMR-deprecated.html">filter_first_weighted_isolate()</a></code> <code><a href="AMR-deprecated.html">key_antibiotics()</a></code> <code><a href="AMR-deprecated.html">key_antibiotics_equal()</a></code> <code><a href="AMR-deprecated.html">filter_ab_class()</a></code> <code><a href="AMR-deprecated.html">filter_aminoglycosides()</a></code> <code><a href="AMR-deprecated.html">filter_betalactams()</a></code> <code><a href="AMR-deprecated.html">filter_carbapenems()</a></code> <code><a href="AMR-deprecated.html">filter_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_1st_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_2nd_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_3rd_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_4th_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_5th_cephalosporins()</a></code> <code><a href="AMR-deprecated.html">filter_fluoroquinolones()</a></code> <code><a href="AMR-deprecated.html">filter_glycopeptides()</a></code> <code><a href="AMR-deprecated.html">filter_macrolides()</a></code> <code><a href="AMR-deprecated.html">filter_oxazolidinones()</a></code> <code><a href="AMR-deprecated.html">filter_penicillins()</a></code> <code><a href="AMR-deprecated.html">filter_tetracyclines()</a></code> </p>
|
||||||
</td>
|
</td>
|
||||||
<td><p>Deprecated Functions</p></td>
|
<td><p>Deprecated Functions</p></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -81,9 +81,6 @@
|
||||||
<url>
|
<url>
|
||||||
<loc>https://msberends.github.io/AMR//reference/example_isolates_unclean.html</loc>
|
<loc>https://msberends.github.io/AMR//reference/example_isolates_unclean.html</loc>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
|
||||||
<loc>https://msberends.github.io/AMR//reference/filter_ab_class.html</loc>
|
|
||||||
</url>
|
|
||||||
<url>
|
<url>
|
||||||
<loc>https://msberends.github.io/AMR//reference/first_isolate.html</loc>
|
<loc>https://msberends.github.io/AMR//reference/first_isolate.html</loc>
|
||||||
</url>
|
</url>
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9047</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9048</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -37,3 +37,20 @@ expect_identical(suppressWarnings(key_antibiotics_equal("S", "S")),
|
||||||
expect_warning(filter_first_weighted_isolate(example_isolates))
|
expect_warning(filter_first_weighted_isolate(example_isolates))
|
||||||
expect_identical(suppressWarnings(filter_first_weighted_isolate(example_isolates)),
|
expect_identical(suppressWarnings(filter_first_weighted_isolate(example_isolates)),
|
||||||
filter_first_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))
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
# 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
|
# 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[, aminoglycosides(), drop = FALSE]) < ncol(example_isolates))
|
||||||
expect_true(ncol(example_isolates[, betalactams(), 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[, oxazolidinones(), drop = FALSE]) < ncol(example_isolates))
|
||||||
expect_true(ncol(example_isolates[, penicillins(), 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))
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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())
|
|
||||||
}
|
|
|
@ -6,6 +6,22 @@
|
||||||
\alias{filter_first_weighted_isolate}
|
\alias{filter_first_weighted_isolate}
|
||||||
\alias{key_antibiotics}
|
\alias{key_antibiotics}
|
||||||
\alias{key_antibiotics_equal}
|
\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}
|
\title{Deprecated Functions}
|
||||||
\usage{
|
\usage{
|
||||||
p_symbol(p, emptychar = " ")
|
p_symbol(p, emptychar = " ")
|
||||||
|
@ -53,9 +69,141 @@ key_antibiotics_equal(
|
||||||
na.rm = TRUE,
|
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{
|
\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}{
|
\section{Retired Lifecycle}{
|
||||||
|
|
||||||
|
|
|
@ -58,12 +58,14 @@ tetracyclines(only_rsi_columns = FALSE)
|
||||||
\item{only_rsi_columns}{a \link{logical} to indicate whether only columns of class \verb{<rsi>} must be selected (defaults to \code{FALSE}), see \code{\link[=as.rsi]{as.rsi()}}}
|
\item{only_rsi_columns}{a \link{logical} to indicate whether only columns of class \verb{<rsi>} must be selected (defaults to \code{FALSE}), see \code{\link[=as.rsi]{as.rsi()}}}
|
||||||
}
|
}
|
||||||
\description{
|
\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{
|
\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, "."), "")}}
|
\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.
|
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.
|
# `example_isolates` is a data set available in the AMR package.
|
||||||
# See ?example_isolates.
|
# See ?example_isolates.
|
||||||
|
|
||||||
# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
# Base R ------------------------------------------------------------------
|
||||||
|
|
||||||
|
# select columns 'IPM' (imipenem) and 'MEM' (meropenem)
|
||||||
example_isolates[, carbapenems()]
|
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())]
|
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")) {
|
if (require("dplyr")) {
|
||||||
|
|
||||||
# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
||||||
|
@ -104,6 +126,20 @@ if (require("dplyr")) {
|
||||||
example_isolates \%>\%
|
example_isolates \%>\%
|
||||||
select(mo, aminoglycosides())
|
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'):
|
# this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
|
||||||
example_isolates \%>\%
|
example_isolates \%>\%
|
||||||
select(mo, ab_class("mycobact"))
|
select(mo, ab_class("mycobact"))
|
||||||
|
@ -122,12 +158,10 @@ if (require("dplyr")) {
|
||||||
select(penicillins()) # only the 'J01CA01' column will be selected
|
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)
|
# (though the row names on the first are more correct)
|
||||||
example_isolates \%>\% filter_carbapenems("R", "all")
|
example_isolates[carbapenems() == "R", ]
|
||||||
example_isolates \%>\% filter(across(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.
|
|
||||||
}
|
|
||||||
|
|
|
@ -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{<rsi>} (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.
|
|
||||||
}
|
|
Loading…
Reference in New Issue