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

(v0.8.0.9008) new verbose mode for MDROs

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-11-03 22:24:42 +01:00
parent 09c4b04cd0
commit 29e448883d
42 changed files with 338 additions and 343 deletions

View File

@ -23,7 +23,11 @@ install_if_needed <- function(pkg, repos, quiet) {
package_path <- find.package(pkg, quiet = quiet) package_path <- find.package(pkg, quiet = quiet)
if (length(package_path) == 0) { if (length(package_path) == 0) {
message("NOTE: pkg ", pkg, " missing, installing...") message("NOTE: pkg ", pkg, " missing, installing...")
install.packages(pkg, repos = repos, quiet = quiet) if (pkg == "cleaner") {
devtools::install_github("msberends/cleaner")
} else {
install.packages(pkg, repos = repos, quiet = quiet)
}
} }
} }
@ -41,6 +45,7 @@ gl_update_pkg_all <- function(repos = "https://cran.rstudio.com",
if (install_lintr == TRUE) { if (install_lintr == TRUE) {
install_if_needed(pkg = "lintr", repos = repos, quiet = quiet) install_if_needed(pkg = "lintr", repos = repos, quiet = quiet)
} }
install_if_needed(pkg = "cleaner", repos = repos, quiet = quiet)
devtools::install_dev_deps(repos = repos, quiet = quiet, upgrade = TRUE) devtools::install_dev_deps(repos = repos, quiet = quiet, upgrade = TRUE)

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 0.8.0.9007 Version: 0.8.0.9008
Date: 2019-10-30 Date: 2019-11-03
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(
person(role = c("aut", "cre"), person(role = c("aut", "cre"),
@ -36,7 +36,7 @@ Depends:
R (>= 3.1.0) R (>= 3.1.0)
Imports: Imports:
backports, backports,
clean (>= 1.1.0), cleaner,
crayon (>= 1.3.0), crayon (>= 1.3.0),
data.table (>= 1.9.0), data.table (>= 1.9.0),
dplyr (>= 0.7.0), dplyr (>= 0.7.0),

View File

@ -232,9 +232,10 @@ exportMethods(skewness.matrix)
exportMethods(summary.mic) exportMethods(summary.mic)
exportMethods(summary.mo) exportMethods(summary.mo)
exportMethods(summary.rsi) exportMethods(summary.rsi)
importFrom(clean,freq) importFrom(cleaner,freq)
importFrom(clean,freq.default) importFrom(cleaner,freq.default)
importFrom(clean,top_freq) importFrom(cleaner,percentage)
importFrom(cleaner,top_freq)
importFrom(crayon,bgGreen) importFrom(crayon,bgGreen)
importFrom(crayon,bgRed) importFrom(crayon,bgRed)
importFrom(crayon,bgYellow) importFrom(crayon,bgYellow)

12
NEWS.md
View File

@ -1,8 +1,10 @@
# AMR 0.8.0.9007 # AMR 0.8.0.9008
<small>Last updated: 30-Oct-2019</small> <small>Last updated: 03-Nov-2019</small>
### New ### New
* Support for a new MDRO guideline: Magiorakos AP, Srinivasan A *et al.* "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012). **This is now the new default guideline for the `mdro()` function.** * Support for a new MDRO guideline: Magiorakos AP, Srinivasan A *et al.* "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012).
* This is now the new default guideline for the `mdro()` function
* The new Verbose mode (`mdro(...., verbose = TRUE)`) returns an informative data set where the reason for MDRO determination is given for every isolate
### Changes ### Changes
* When running `as.rsi()` over a data set, it will now print the guideline that will be used if it is not specified by the user * When running `as.rsi()` over a data set, it will now print the guideline that will be used if it is not specified by the user
@ -12,6 +14,10 @@
* Added "imi" as allowed abbreviation for Imipenem * Added "imi" as allowed abbreviation for Imipenem
* Fix for automatically determining columns with antibiotic results in `mdro()` and `eucast_rules()` * Fix for automatically determining columns with antibiotic results in `mdro()` and `eucast_rules()`
* Added ATC codes for ceftaroline, ceftobiprole and faropenem and fixed two typos in the `antibiotics` data set * Added ATC codes for ceftaroline, ceftobiprole and faropenem and fixed two typos in the `antibiotics` data set
* More robust way of determining valid MIC values
### Other
* Change dependency on `clean` to `cleaner`, as this package was renamed accordingly upon CRAN request
# AMR 0.8.0 # AMR 0.8.0

View File

@ -27,7 +27,7 @@
#' @details The function returns a \code{data.frame} with columns \code{"resistant"} and \code{"visual_resistance"}. The values in that columns are calculated with \code{\link{portion_R}}. #' @details The function returns a \code{data.frame} with columns \code{"resistant"} and \code{"visual_resistance"}. The values in that columns are calculated with \code{\link{portion_R}}.
#' @return \code{data.frame} with column names of \code{tbl} as row names #' @return \code{data.frame} with column names of \code{tbl} as row names
#' @inheritSection AMR Read more on our website! #' @inheritSection AMR Read more on our website!
# @importFrom clean percentage #' @importFrom cleaner percentage
#' @export #' @export
#' @examples #' @examples
#' availability(example_isolates) #' availability(example_isolates)

View File

@ -33,7 +33,6 @@
#' @inheritParams base::formatC #' @inheritParams base::formatC
#' @importFrom dplyr %>% rename group_by select mutate filter summarise ungroup #' @importFrom dplyr %>% rename group_by select mutate filter summarise ungroup
#' @importFrom tidyr spread #' @importFrom tidyr spread
# @importFrom clean freq percentage
#' @details The function \code{format} calculates the resistance per bug-drug combination. Use \code{combine_IR = FALSE} (default) to test R vs. S+I and \code{combine_IR = TRUE} to test R+I vs. S. #' @details The function \code{format} calculates the resistance per bug-drug combination. Use \code{combine_IR = FALSE} (default) to test R vs. S+I and \code{combine_IR = TRUE} to test R+I vs. S.
#' #'
#' The language of the output can be overwritten with \code{options(AMR_locale)}, please see \link{translate}. #' The language of the output can be overwritten with \code{options(AMR_locale)}, please see \link{translate}.
@ -95,6 +94,7 @@ bug_drug_combinations <- function(x,
#' @importFrom dplyr everything rename %>% ungroup group_by summarise mutate_all arrange everything lag #' @importFrom dplyr everything rename %>% ungroup group_by summarise mutate_all arrange everything lag
#' @importFrom tidyr spread #' @importFrom tidyr spread
#' @importFrom cleaner percentage
#' @exportMethod format.bug_drug_combinations #' @exportMethod format.bug_drug_combinations
#' @export #' @export
#' @rdname bug_drug_combinations #' @rdname bug_drug_combinations

View File

@ -90,7 +90,6 @@ NULL
#' @export #' @export
#' @examples #' @examples
#' library(dplyr) #' library(dplyr)
#' library(clean)
#' microorganisms %>% freq(kingdom) #' microorganisms %>% freq(kingdom)
#' microorganisms %>% group_by(kingdom) %>% freq(phylum, nmax = NULL) #' microorganisms %>% group_by(kingdom) %>% freq(phylum, nmax = NULL)
catalogue_of_life_version <- function() { catalogue_of_life_version <- function() {

View File

@ -19,14 +19,13 @@
# Visit our website for more info: https://msberends.gitlab.io/AMR. # # Visit our website for more info: https://msberends.gitlab.io/AMR. #
# ==================================================================== # # ==================================================================== #
#' @importFrom clean freq #' @importFrom cleaner freq
#' @export #' @export
clean::freq cleaner::freq
#' @exportMethod freq.mo #' @exportMethod freq.mo
#' @importFrom dplyr n_distinct #' @importFrom dplyr n_distinct
#' @importFrom clean freq.default #' @importFrom cleaner freq.default percentage
# @importFrom clean percentage
#' @export #' @export
#' @noRd #' @noRd
freq.mo <- function(x, ...) { freq.mo <- function(x, ...) {
@ -53,7 +52,7 @@ freq.mo <- function(x, ...) {
} }
#' @exportMethod freq.rsi #' @exportMethod freq.rsi
#' @importFrom clean freq.default #' @importFrom cleaner freq.default
#' @export #' @export
#' @noRd #' @noRd
freq.rsi <- function(x, ...) { freq.rsi <- function(x, ...) {

View File

@ -337,7 +337,7 @@ facet_rsi <- function(facet = c("interpretation", "antibiotic"), nrow = NULL) {
} }
#' @rdname ggplot_rsi #' @rdname ggplot_rsi
# @importFrom clean percentage #' @importFrom cleaner percentage
#' @export #' @export
scale_y_percent <- function(breaks = seq(0, 1, 0.1), limits = NULL) { scale_y_percent <- function(breaks = seq(0, 1, 0.1), limits = NULL) {
stopifnot_installed_package("ggplot2") stopifnot_installed_package("ggplot2")
@ -387,7 +387,7 @@ theme_rsi <- function() {
#' @rdname ggplot_rsi #' @rdname ggplot_rsi
#' @importFrom dplyr mutate %>% group_by_at #' @importFrom dplyr mutate %>% group_by_at
# @importFrom clean percentage #' @importFrom cleaner percentage
#' @export #' @export
labels_rsi_count <- function(position = NULL, labels_rsi_count <- function(position = NULL,
x = "antibiotic", x = "antibiotic",

View File

@ -48,7 +48,6 @@
#' #'
#' # get frequencies of bacteria whose name start with 'Ent' or 'ent' #' # get frequencies of bacteria whose name start with 'Ent' or 'ent'
#' library(dplyr) #' library(dplyr)
#' library(clean)
#' example_isolates %>% #' example_isolates %>%
#' left_join_microorganisms() %>% #' left_join_microorganisms() %>%
#' filter(genus %like% '^ent') %>% #' filter(genus %like% '^ent') %>%

284
R/mdro.R
View File

@ -22,13 +22,16 @@
#' Determine multidrug-resistant organisms (MDRO) #' Determine multidrug-resistant organisms (MDRO)
#' #'
#' Determine which isolates are multidrug-resistant organisms (MDRO) according to (country-specific) guidelines. #' Determine which isolates are multidrug-resistant organisms (MDRO) according to (country-specific) guidelines.
#' @param x table with antibiotic columns, like e.g. \code{AMX} and \code{AMC}
#' @param guideline a specific guideline to follow. When left empty, the publication by Magiorakos \emph{et al.} (2012, Clinical Microbiology and Infection) will be followed, see Details. #' @param guideline a specific guideline to follow. When left empty, the publication by Magiorakos \emph{et al.} (2012, Clinical Microbiology and Infection) will be followed, see Details.
#' @param info print progress #' @param info print progress
#' @inheritParams eucast_rules #' @inheritParams eucast_rules
#' @param verbose print additional info: missing antibiotic columns per parameter #' @param verbose print additional info: missing antibiotic columns per parameter
#' @param pct_required_classes minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for \emph{S. aureus}. Setting this \code{pct_required_classes} argument to \code{0.5} (default) means that for every \emph{S. aureus} isolate at least 8 different classes must be available. Any lower number of available classes will return \code{NA} for that isolate.
#' @param verbose a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.
#' @inheritSection eucast_rules Antibiotics #' @inheritSection eucast_rules Antibiotics
#' @details Currently supported guidelines are (case-insensitive): #' @details
#' For the \code{pct_required_classes} argument, values above 1 will be divided by 100. This is to support both fractions (\code{0.75} or \code{3/4}) and percentages (\code{75}).
#' Currently supported guidelines are (case-insensitive):
#' \itemize{ #' \itemize{
#' \item{\code{guideline = "CMI2012"}: Magiorakos AP, Srinivasan A \emph{et al.} "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012) (\href{https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext}{link})} #' \item{\code{guideline = "CMI2012"}: Magiorakos AP, Srinivasan A \emph{et al.} "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012) (\href{https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext}{link})}
#' \item{\code{guideline = "EUCAST"}: The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (\href{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}{link})} #' \item{\code{guideline = "EUCAST"}: The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (\href{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}{link})}
@ -38,6 +41,7 @@
#' } #' }
#' #'
#' Please suggest your own (country-specific) guidelines by letting us know: \url{https://gitlab.com/msberends/AMR/issues/new}. #' Please suggest your own (country-specific) guidelines by letting us know: \url{https://gitlab.com/msberends/AMR/issues/new}.
#'
#' @return \itemize{ #' @return \itemize{
#' \item{CMI 2012 paper - function \code{mdr_cmi2012()} or \code{mdro()}:\cr Ordered factor with levels \code{Negative < Multi-drug-resistant (MDR) < Extensively drug-resistant (XDR) < Pandrug-resistant (PDR)}} #' \item{CMI 2012 paper - function \code{mdr_cmi2012()} or \code{mdro()}:\cr Ordered factor with levels \code{Negative < Multi-drug-resistant (MDR) < Extensively drug-resistant (XDR) < Pandrug-resistant (PDR)}}
#' \item{TB guideline - function \code{mdr_tb()} or \code{mdro(..., guideline = "TB")}:\cr Ordered factor with levels \code{Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant < Extensively drug-resistant}} #' \item{TB guideline - function \code{mdr_tb()} or \code{mdro(..., guideline = "TB")}:\cr Ordered factor with levels \code{Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant < Extensively drug-resistant}}
@ -47,6 +51,7 @@
#' @rdname mdro #' @rdname mdro
#' @importFrom dplyr %>% filter_all #' @importFrom dplyr %>% filter_all
#' @importFrom crayon blue bold italic #' @importFrom crayon blue bold italic
#' @importFrom cleaner percentage
#' @export #' @export
#' @inheritSection AMR Read more on our website! #' @inheritSection AMR Read more on our website!
#' @source #' @source
@ -54,13 +59,13 @@
#' @examples #' @examples
#' library(dplyr) #' library(dplyr)
#' #'
#' example_isolates %>% #' example_isolates %>%
#' mdro() %>% #' mdro() %>%
#' freq() #' freq()
#' #'
#' \donttest{ #' \donttest{
#' example_isolates %>% #' example_isolates %>%
#' mutate(EUCAST = mdro(.), #' mutate(EUCAST = eucast_exceptional_phenotypes(.),
#' BRMO = brmo(.), #' BRMO = brmo(.),
#' MRGN = mrgn(.)) #' MRGN = mrgn(.))
#' #'
@ -74,13 +79,35 @@ mdro <- function(x,
col_mo = NULL, col_mo = NULL,
info = TRUE, info = TRUE,
verbose = FALSE, verbose = FALSE,
pct_required_classes = 0.5,
...) { ...) {
if (verbose == TRUE & interactive()) {
txt <- paste0("WARNING: In Verbose mode, the mdro() function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.",
"\n\nThis may overwrite your existing data if you use e.g.:",
"\ndata <- mdro(data, verbose = TRUE)\n\nDo you want to continue?")
if ("rstudioapi" %in% rownames(utils::installed.packages())) {
q_continue <- rstudioapi::showQuestion("Using verbose = TRUE with mdro()", txt)
} else {
q_continue <- menu(choices = c("OK", "Cancel"), graphics = TRUE, title = txt)
}
if (q_continue %in% c(FALSE, 2)) {
message("Cancelled, returning original data")
return(x)
}
}
if (!is.data.frame(x)) { if (!is.data.frame(x)) {
stop("`x` must be a data frame.", call. = FALSE) stop("`x` must be a data frame.", call. = FALSE)
} }
if (!is.numeric(pct_required_classes)) {
stop("`pct_required_classes` must be numeric.", call. = FALSE)
}
if (pct_required_classes > 1) {
# allow pct_required_classes = 75 -> pct_required_classes = 0.75
pct_required_classes <- pct_required_classes / 100
}
if (!is.null(list(...)$country)) { if (!is.null(list(...)$country)) {
warning("Using `country` is deprecated, use `guideline` instead. Please see ?mdro.", call. = FALSE) warning("Using `country` is deprecated, use `guideline` instead. Please see ?mdro.", call. = FALSE)
guideline <- list(...)$country guideline <- list(...)$country
@ -88,7 +115,7 @@ mdro <- function(x,
if (length(guideline) > 1) { if (length(guideline) > 1) {
stop("`guideline` must be a length one character string.", call. = FALSE) stop("`guideline` must be a length one character string.", call. = FALSE)
} }
if (is.null(guideline)) { if (is.null(guideline)) {
# default to the paper by Magiorakos et al. (2012) # default to the paper by Magiorakos et al. (2012)
guideline <- "cmi2012" guideline <- "cmi2012"
@ -103,7 +130,7 @@ mdro <- function(x,
stop("invalid guideline: ", guideline, call. = FALSE) stop("invalid guideline: ", guideline, call. = FALSE)
} }
guideline <- list(code = tolower(guideline)) guideline <- list(code = tolower(guideline))
# try to find columns based on type # try to find columns based on type
# -- mo # -- mo
if (is.null(col_mo)) { if (is.null(col_mo)) {
@ -118,7 +145,7 @@ mdro <- function(x,
if (is.null(col_mo)) { if (is.null(col_mo)) {
stop("`col_mo` must be set.", call. = FALSE) stop("`col_mo` must be set.", call. = FALSE)
} }
if (guideline$code == "cmi2012") { if (guideline$code == "cmi2012") {
guideline$name <- "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." guideline$name <- "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance."
guideline$author <- "Magiorakos AP, Srinivasan A, Carey RB, ..., Vatopoulos A, Weber JT, Monnet DL" guideline$author <- "Magiorakos AP, Srinivasan A, Carey RB, ..., Vatopoulos A, Weber JT, Monnet DL"
@ -130,13 +157,13 @@ mdro <- function(x,
guideline$author <- "EUCAST (European Committee on Antimicrobial Susceptibility Testing)" guideline$author <- "EUCAST (European Committee on Antimicrobial Susceptibility Testing)"
guideline$version <- "3.1" guideline$version <- "3.1"
guideline$source <- "http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf" guideline$source <- "http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf"
} else if (guideline$code == "tb") { } else if (guideline$code == "tb") {
guideline$name <- "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" guideline$name <- "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis"
guideline$author <- "WHO (World Health Organization)" guideline$author <- "WHO (World Health Organization)"
guideline$version <- "WHO/HTM/TB/2014.11" guideline$version <- "WHO/HTM/TB/2014.11"
guideline$source <- "https://www.who.int/tb/publications/pmdt_companionhandbook/en/" guideline$source <- "https://www.who.int/tb/publications/pmdt_companionhandbook/en/"
# support per country: # support per country:
} else if (guideline$code == "mrgn") { } else if (guideline$code == "mrgn") {
guideline$name <- "Cross-border comparison of the Dutch and German guidelines on multidrug-resistant Gram-negative microorganisms" guideline$name <- "Cross-border comparison of the Dutch and German guidelines on multidrug-resistant Gram-negative microorganisms"
@ -152,7 +179,7 @@ mdro <- function(x,
} else { } else {
stop("This guideline is currently unsupported: ", guideline$code, call. = FALSE) stop("This guideline is currently unsupported: ", guideline$code, call. = FALSE)
} }
if (guideline$code == "cmi2012") { if (guideline$code == "cmi2012") {
cols_ab <- get_column_abx(x = x, cols_ab <- get_column_abx(x = x,
soft_dependencies = c( soft_dependencies = c(
@ -270,7 +297,7 @@ mdro <- function(x,
"TCY", "TCY",
"DOX", "DOX",
"MNO" "MNO"
), ),
verbose = verbose, ...) verbose = verbose, ...)
} else if (guideline$code == "tb") { } else if (guideline$code == "tb") {
cols_ab <- get_column_abx(x = x, cols_ab <- get_column_abx(x = x,
@ -295,7 +322,7 @@ mdro <- function(x,
} else { } else {
cols_ab <- get_column_abx(x = x, verbose = verbose, ...) cols_ab <- get_column_abx(x = x, verbose = verbose, ...)
} }
AMC <- cols_ab["AMC"] AMC <- cols_ab["AMC"]
AMK <- cols_ab["AMK"] AMK <- cols_ab["AMK"]
AMP <- cols_ab["AMP"] AMP <- cols_ab["AMP"]
@ -391,21 +418,23 @@ mdro <- function(x,
bold("Source: "), guideline$source, "\n", bold("Source: "), guideline$source, "\n",
"\n", sep = "") "\n", sep = "")
} }
ab_missing <- function(ab) { ab_missing <- function(ab) {
isTRUE(ab %in% c(NULL, NA)) | length(ab) == 0 isTRUE(ab %in% c(NULL, NA)) | length(ab) == 0
} }
ab_NA <- function(x) { ab_NA <- function(x) {
x[!is.na(x)] x[!is.na(x)]
} }
verbose_df <- NULL
# antibiotic classes # antibiotic classes
aminoglycosides <- c(TOB, GEN) aminoglycosides <- c(TOB, GEN)
cephalosporins <- c(FEP, CTX, FOX, CED, CAZ, CRO, CXM, CZO) cephalosporins <- c(FEP, CTX, FOX, CED, CAZ, CRO, CXM, CZO)
cephalosporins_3rd <- c(CTX, CRO, CAZ) cephalosporins_3rd <- c(CTX, CRO, CAZ)
carbapenems <- c(ETP, IPM, MEM) carbapenems <- c(ETP, IPM, MEM)
fluoroquinolones <- c(OFX, CIP, LVX, MFX) fluoroquinolones <- c(OFX, CIP, LVX, MFX)
# helper function for editing the table # helper function for editing the table
trans_tbl <- function(to, rows, cols, any_all) { trans_tbl <- function(to, rows, cols, any_all) {
cols <- cols[!ab_missing(cols)] cols <- cols[!ab_missing(cols)]
@ -421,41 +450,41 @@ mdro <- function(x,
} }
rows <- rows[rows %in% row_filter] rows <- rows[rows %in% row_filter]
x[rows, "MDRO"] <<- to x[rows, "MDRO"] <<- to
x[rows, "reason"] <<- paste0(any_all, " of these ", ifelse(any_all == "any", "is", "are"), " R: ",
paste(cols, collapse = ", "))
} }
} }
trans_tbl2 <- function(txt, rows, lst) { trans_tbl2 <- function(txt, rows, lst) {
if (info == TRUE) { if (info == TRUE) {
message(blue(txt, "..."), appendLF = FALSE) message(blue(txt, "..."), appendLF = FALSE)
} }
# function specific for the CMI paper of 2012 (Magiorakos et al.) if (length(rows) > 0) {
lst_vector <- unlist(lst)[!is.na(unlist(lst))] # function specific for the CMI paper of 2012 (Magiorakos et al.)
x$total_groups <- NA_integer_ lst_vector <- unlist(lst)[!is.na(unlist(lst))]
x$affected_groups <- NA_integer_ x[rows, "classes_in_guideline"] <<- length(lst)
x[rows, "total_groups"] <- length(lst) x[rows, "classes_available"] <<- sapply(rows,
# now the hard part - using two sapply()s for super fast results: function(row, group_tbl = lst) {
# [1] run through all `rows` with sapply() sum(sapply(group_tbl, function(group) !all(is.na(group))))
# [2] within each row, run through all antibiotic groups with another sapply() })
# [3] determine for each antibiotic group in that row if at least 1 drug is R of I # now the hard part - using two sapply()s for super fast results:
# [4] sum the number of TRUEs of this determination # [1] run through all `rows` with sapply()
x[rows, "affected_groups"] <- sapply(rows, # [2] within each row, run through all antibiotic classes with another sapply()
function(row, group_tbl = lst) { # [3] determine for each antibiotic group in that row if at least 1 drug is R of I
sum(sapply(group_tbl, # [4] sum the number of TRUEs of this determination
function(group) { x[rows, "classes_affected"] <<- sapply(rows,
any(x[row, group[!is.na(group)]] == "R") | function(row, group_tbl = lst) {
any(x[row, group[!is.na(group)]] == "I") sum(sapply(group_tbl,
}), function(group) {
na.rm = TRUE) any(x[row, group[!is.na(group)]] == "R") |
}) any(x[row, group[!is.na(group)]] == "I")
# now set MDROs: }),
# MDR (=2): >=3 groups affected na.rm = TRUE)
x[which(x$row_number %in% rows & x$affected_groups >= 3), "MDRO"] <<- 2 })
# XDR (=3): all but <=2 groups affected x[filter_at(x[rows,],
x[which(x$row_number %in% rows & (x$total_groups - x$affected_groups) <= 2), "MDRO"] <<- 3 vars(lst_vector),
# PDR (=4): all agents are R all_vars(. %in% c("R", "I")))$row_number, "classes_affected"] <<- 999
x[filter_at(x[rows, ], }
vars(lst_vector),
all_vars(. %in% c("R", "I")))$row_number,
"MDRO"] <<- 4
if (info == TRUE) { if (info == TRUE) {
message(blue(" OK")) message(blue(" OK"))
} }
@ -465,9 +494,10 @@ mdro <- function(x,
mutate_at(vars(col_mo), as.mo) %>% mutate_at(vars(col_mo), as.mo) %>%
# join to microorganisms data set # join to microorganisms data set
left_join_microorganisms(by = col_mo) %>% left_join_microorganisms(by = col_mo) %>%
# add unconfirmed to where genus is available # add unavailable to where genus is available
mutate(MDRO = ifelse(!is.na(genus), 1, NA_integer_), mutate(MDRO = ifelse(!is.na(genus), 1, NA_integer_),
row_number = seq_len(nrow(.))) %>% row_number = seq_len(nrow(.)),
reason = paste0("not covered by ", toupper(guideline$code), " guideline")) %>%
# transform to data.frame so subsetting is possible with x[y, z] (might not be the case with tibble/data.table/...) # transform to data.frame so subsetting is possible with x[y, z] (might not be the case with tibble/data.table/...)
as.data.frame(stringsAsFactors = FALSE) as.data.frame(stringsAsFactors = FALSE)
@ -475,19 +505,34 @@ mdro <- function(x,
# CMI, 2012 --------------------------------------------------------------- # CMI, 2012 ---------------------------------------------------------------
# Non-susceptible = R and I # Non-susceptible = R and I
# (see header 'Approaches to Creating Definitions for MDR, XDR and PDR' in paper) # (see header 'Approaches to Creating Definitions for MDR, XDR and PDR' in paper)
# take amoxicillin if ampicillin is unavailable # take amoxicillin if ampicillin is unavailable
if (is.na(AMP) & !is.na(AMX)) AMP <- AMX if (is.na(AMP) & !is.na(AMX)) {
if (verbose == TRUE) {
message(blue("NOTE: Filling ampicillin (AMP) results with amoxicillin (AMX) results"))
}
AMP <- AMX
}
# take ceftriaxone if cefotaxime is unavailable and vice versa # take ceftriaxone if cefotaxime is unavailable and vice versa
if (is.na(CRO) & !is.na(CTX)) CRO <- CTX if (is.na(CRO) & !is.na(CTX)) {
if (is.na(CTX) & !is.na(CRO)) CTX <- CRO if (verbose == TRUE) {
message(blue("NOTE: Filling ceftriaxone (CRO) results with cefotaxime (CTX) results"))
}
CRO <- CTX
}
if (is.na(CTX) & !is.na(CRO)) {
if (verbose == TRUE) {
message(blue("NOTE: Filling cefotaxime (CTX) results with ceftriaxone (CRO) results"))
}
CTX <- CRO
}
# intrinsic resistant must not be considered for the determination of MDR, # intrinsic resistant must not be considered for the determination of MDR,
# so let's just remove them, meticulously following the paper # so let's just remove them, meticulously following the paper
x[which(x$genus == "Enterococcus" & x$species == "faecium"), ab_NA(IPM)] <- NA x[which(x$genus == "Enterococcus" & x$species == "faecium"), ab_NA(IPM)] <- NA
x[which(x$genus == "Enterococcus" & x$species == "faecalis"), ab_NA(QDA)] <- NA x[which(x$genus == "Enterococcus" & x$species == "faecalis"), ab_NA(QDA)] <- NA
x[which((x$genus == "Providencia" & x$species == "rettgeri") x[which((x$genus == "Providencia" & x$species == "rettgeri")
| (x$genus == "Providencia" & x$species == "stuartii")), ab_NA(c(GEN, TOB, NET))] <- NA | (x$genus == "Providencia" & x$species == "stuartii")), ab_NA(c(GEN, TOB, NET))] <- NA
x[which(x$genus == "Escherichia" & x$species == "hermannii"), ab_NA(c(TCC, TZP))] <- NA x[which(x$genus == "Escherichia" & x$species == "hermannii"), ab_NA(c(TCC, TZP))] <- NA
x[which((x$genus == "Citrobacter" & x$species == "freundii") x[which((x$genus == "Citrobacter" & x$species == "freundii")
| (x$genus == "Enterobacter" & x$species == "aerogenes") | (x$genus == "Enterobacter" & x$species == "aerogenes")
@ -554,6 +599,10 @@ mdro <- function(x,
| (x$genus == "Providencia" & x$species == "rettgeri") | (x$genus == "Providencia" & x$species == "rettgeri")
| (x$genus == "Providencia" & x$species == "stuartii")), ab_NA(c(DOX, MNO))] <- NA | (x$genus == "Providencia" & x$species == "stuartii")), ab_NA(c(DOX, MNO))] <- NA
x$classes_in_guideline <- NA_integer_
x$classes_available <- NA_integer_
x$classes_affected <- NA_integer_
# now add the MDR levels to the data # now add the MDR levels to the data
trans_tbl(2, trans_tbl(2,
which(x$genus == "Staphylococcus" & x$species == "aureus"), which(x$genus == "Staphylococcus" & x$species == "aureus"),
@ -592,7 +641,7 @@ mdro <- function(x,
QDA, QDA,
c(DOX, MNO))) c(DOX, MNO)))
trans_tbl2(paste0("Table 3 - ", italic("Enterobacteriaceae"), trans_tbl2(paste0("Table 3 - ", italic("Enterobacteriaceae"),
" (before the taxonomic reclassification by Adeolu ", italic("et al."), ", 2016)"), " (before the taxonomic reclassification by Adeolu ", italic("et al."), ", 2016)"),
# this new order was previously 'Enterobacteriales' and contained only the family 'Enterobacteriaceae': # this new order was previously 'Enterobacteriales' and contained only the family 'Enterobacteriaceae':
which(x$order == "Enterobacterales"), which(x$order == "Enterobacterales"),
list(c(GEN, TOB, AMK, NET), list(c(GEN, TOB, AMK, NET),
@ -634,6 +683,37 @@ mdro <- function(x,
SAM, SAM,
c(COL, PLB), c(COL, PLB),
c(TCY, DOX, MNO))) c(TCY, DOX, MNO)))
# now set MDROs:
# MDR (=2): >=3 classes affected
x[which(x$classes_affected >= 3), "MDRO"] <- 2
if (verbose == TRUE) {
x[which(x$classes_affected >= 3), "reason"] <- paste0("at least 3 classes contain R or I: ", x$classes_affected[which(x$classes_affected >= 3)],
" out of ", x$classes_available[which(x$classes_affected >= 3)], " available classes")
}
# XDR (=3): all but <=2 classes affected
x[which((x$classes_in_guideline - x$classes_affected) <= 2), "MDRO"] <- 3
if (verbose == TRUE) {
x[which((x$classes_in_guideline - x$classes_affected) <= 2), "reason"] <- paste0("less than 3 classes remain susceptible (", x$classes_in_guideline[which((x$classes_in_guideline - x$classes_affected) <= 2)] - x$classes_affected[which((x$classes_in_guideline - x$classes_affected) <= 2)],
" out of ", x$classes_in_guideline[which((x$classes_in_guideline - x$classes_affected) <= 2)], " classes)")
}
# PDR (=4): all agents are R
x[which(x$classes_affected == 999 & x$classes_in_guideline == x$classes_available), "MDRO"] <- 4
if (verbose == TRUE) {
x[which(x$classes_affected == 999 & x$classes_in_guideline == x$classes_available), "reason"] <- paste("all antibiotics in all", x$classes_in_guideline[which(x$classes_affected == 999 & x$classes_in_guideline == x$classes_available)], "classes were tested R or I")
}
# not enough classes available
x[which(x$classes_available < base::floor(x$classes_in_guideline * pct_required_classes)), "MDRO"] <- -1
if (verbose == TRUE) {
x[which(x$classes_available < base::floor(x$classes_in_guideline * pct_required_classes)), "reason"] <- paste0("not enough classes available: ", x$classes_available[which(x$classes_available < base::floor(x$classes_in_guideline * pct_required_classes))],
" instead of ", (base::floor(x$classes_in_guideline * pct_required_classes))[which(x$classes_available < base::floor(x$classes_in_guideline * pct_required_classes))],
" (~", percentage(pct_required_classes), " of ", x$classes_in_guideline[which(x$classes_available < base::floor(x$classes_in_guideline * pct_required_classes))], ")")
}
# some more info on negative results
if (verbose == TRUE) {
x[which(x$MDRO == 1 & !is.na(x$classes_affected)), "reason"] <- paste0(x$classes_affected[which(x$MDRO == 1 & !is.na(x$classes_affected))], " of ", x$classes_available[which(x$MDRO == 1 & !is.na(x$classes_affected))], " available classes contain R or I (3 required for MDR)")
}
} }
if (guideline$code == "eucast") { if (guideline$code == "eucast") {
@ -693,14 +773,14 @@ mdro <- function(x,
# Table 7 # Table 7
trans_tbl(3, trans_tbl(3,
which(x$genus == "Bacteroides"), which(x$genus == "Bacteroides"),
MTR, MTR,
"any") "any")
trans_tbl(3, trans_tbl(3,
which(x$fullname %like% "^Clostridium difficile"), which(x$fullname %like% "^Clostridium difficile"),
c(MTR, VAN), c(MTR, VAN),
"any") "any")
} }
if (guideline$code == "mrgn") { if (guideline$code == "mrgn") {
# Germany ----------------------------------------------------------------- # Germany -----------------------------------------------------------------
CTX_or_CAZ <- CTX %or% CAZ CTX_or_CAZ <- CTX %or% CAZ
@ -715,7 +795,7 @@ mdro <- function(x,
# Table 1 # Table 1
x[which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification x[which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
x$fullname %like% "^Acinetobacter baumannii") & x$fullname %like% "^Acinetobacter baumannii") &
x[, PIP] == "R" & x[, PIP] == "R" &
x[, CTX_or_CAZ] == "R" & x[, CTX_or_CAZ] == "R" &
x[, IPM_or_MEM] == "S" & x[, IPM_or_MEM] == "S" &
@ -749,7 +829,7 @@ mdro <- function(x,
x[, CIP] == "R"), x[, CIP] == "R"),
"MDRO"] <- 3 # 3 = 4MRGN "MDRO"] <- 3 # 3 = 4MRGN
} }
if (guideline$code == "brmo") { if (guideline$code == "brmo") {
# Netherlands ------------------------------------------------------------- # Netherlands -------------------------------------------------------------
aminoglycosides <- aminoglycosides[!is.na(aminoglycosides)] aminoglycosides <- aminoglycosides[!is.na(aminoglycosides)]
@ -762,23 +842,23 @@ mdro <- function(x,
if (length(ESBLs) != 2) { if (length(ESBLs) != 2) {
ESBLs <- character(0) ESBLs <- character(0)
} }
# Table 1 # Table 1
trans_tbl(3, trans_tbl(3,
which(x$order == "Enterobacterales"), # following in fact the old Enterobacteriaceae classification which(x$order == "Enterobacterales"), # following in fact the old Enterobacteriaceae classification
c(aminoglycosides, fluoroquinolones), c(aminoglycosides, fluoroquinolones),
"all") "all")
trans_tbl(2, trans_tbl(2,
which(x$order == "Enterobacterales"), # following in fact the old Enterobacteriaceae classification which(x$order == "Enterobacterales"), # following in fact the old Enterobacteriaceae classification
carbapenems, carbapenems,
"any") "any")
trans_tbl(2, trans_tbl(2,
which(x$order == "Enterobacterales"), # following in fact the old Enterobacteriaceae classification which(x$order == "Enterobacterales"), # following in fact the old Enterobacteriaceae classification
ESBLs, ESBLs,
"all") "all")
# Table 2 # Table 2
trans_tbl(2, trans_tbl(2,
which(x$genus == "Acinetobacter"), which(x$genus == "Acinetobacter"),
@ -788,12 +868,12 @@ mdro <- function(x,
which(x$genus == "Acinetobacter"), which(x$genus == "Acinetobacter"),
c(aminoglycosides, fluoroquinolones), c(aminoglycosides, fluoroquinolones),
"all") "all")
trans_tbl(3, trans_tbl(3,
which(x$fullname %like% "^Stenotrophomonas maltophilia"), which(x$fullname %like% "^Stenotrophomonas maltophilia"),
SXT, SXT,
"all") "all")
if (!ab_missing(MEM) & !ab_missing(IPM) if (!ab_missing(MEM) & !ab_missing(IPM)
& !ab_missing(GEN) & !ab_missing(TOB) & !ab_missing(GEN) & !ab_missing(TOB)
& !ab_missing(CIP) & !ab_missing(CIP)
@ -812,7 +892,7 @@ mdro <- function(x,
x$fullname %like% "Pseudomonas aeruginosa" x$fullname %like% "Pseudomonas aeruginosa"
& x$psae >= 3 & x$psae >= 3
), "MDRO"] <- 3 ), "MDRO"] <- 3
# Table 3 # Table 3
trans_tbl(3, trans_tbl(3,
which(x$fullname %like% "Streptococcus pneumoniae"), which(x$fullname %like% "Streptococcus pneumoniae"),
@ -827,7 +907,7 @@ mdro <- function(x,
c(PEN, VAN), c(PEN, VAN),
"all") "all")
} }
prepare_drug <- function(ab) { prepare_drug <- function(ab) {
# returns vector values of drug # returns vector values of drug
# if `ab` is a column name, looks up the values in `x` # if `ab` is a column name, looks up the values in `x`
@ -858,7 +938,7 @@ mdro <- function(x,
ab != "R" ab != "R"
} }
} }
if (guideline$code == "tb") { if (guideline$code == "tb") {
# Tuberculosis ------------------------------------------------------------ # Tuberculosis ------------------------------------------------------------
x <- x %>% x <- x %>%
@ -881,43 +961,59 @@ mdro <- function(x,
TRUE, FALSE), TRUE, FALSE),
xdr = ifelse(mdr & xdr & second, TRUE, FALSE)) %>% xdr = ifelse(mdr & xdr & second, TRUE, FALSE)) %>%
mutate(MDRO = case_when(xdr ~ 5, mutate(MDRO = case_when(xdr ~ 5,
mdr ~ 4, mdr ~ 4,
poly ~ 3, poly ~ 3,
mono ~ 2, mono ~ 2,
TRUE ~ 1), TRUE ~ 1),
# keep all real TB, make other species NA # keep all real TB, make other species NA
MDRO = ifelse(x$fullname == "Mycobacterium tuberculosis", MDRO, NA_real_)) MDRO = ifelse(x$fullname == "Mycobacterium tuberculosis", MDRO, NA_real_))
} }
if (info == TRUE) { if (info == TRUE) {
cat(bold(paste0("=> Found ", sum(x$MDRO %in% c(2:5), na.rm = TRUE), " MDROs out of ", sum(!is.na(x$MDRO)), cat(bold(paste0("=> Found ", sum(x$MDRO %in% c(2:5), na.rm = TRUE), " MDROs out of ", sum(!is.na(x$MDRO)),
" possible cases (", percentage(sum(x$MDRO %in% c(2:5), na.rm = TRUE) / sum(!is.na(x$MDRO))), ")"))) " tested isolates (", percentage(sum(x$MDRO %in% c(2:5), na.rm = TRUE) / sum(!is.na(x$MDRO))), ")\n")))
} }
# return results # Results ----
if (guideline$code == "cmi2012") { if (guideline$code == "cmi2012") {
factor(x = x$MDRO, if (any(x$MDRO == -1)) {
levels = 1:4, warning("NA introduced for isolates where the available percentage of antimicrobial classes was below ",
labels = c("Negative", "Multi-drug-resistant (MDR)", percentage(pct_required_classes), " (set with `pct_required_classes`)")
"Extensively drug-resistant (XDR)", "Pandrug-resistant (PDR)"), # set these -1s to NA
ordered = TRUE) x[which(x$MDRO == -1), "MDRO"] <- NA_integer_
}
x$MDRO <- factor(x = x$MDRO,
levels = 1:4,
labels = c("Negative", "Multi-drug-resistant (MDR)",
"Extensively drug-resistant (XDR)", "Pandrug-resistant (PDR)"),
ordered = TRUE)
} else if (guideline$code == "tb") { } else if (guideline$code == "tb") {
factor(x = x$MDRO, x$MDRO <- factor(x = x$MDRO,
levels = 1:5, levels = 1:5,
labels = c("Negative", "Mono-resistant", "Poly-resistant", labels = c("Negative", "Mono-resistant", "Poly-resistant",
"Multi-drug-resistant", "Extensively drug-resistant"), "Multi-drug-resistant", "Extensively drug-resistant"),
ordered = TRUE) ordered = TRUE)
} else if (guideline$code == "mrgn") { } else if (guideline$code == "mrgn") {
factor(x = x$MDRO, x$MDRO <- factor(x = x$MDRO,
levels = 1:3, levels = 1:3,
labels = c("Negative", "3MRGN", "4MRGN"), labels = c("Negative", "3MRGN", "4MRGN"),
ordered = TRUE) ordered = TRUE)
} else { } else {
factor(x = x$MDRO, x$MDRO <- factor(x = x$MDRO,
levels = 1:3, levels = 1:3,
labels = c("Negative", "Positive, unconfirmed", "Positive"), labels = c("Negative", "Positive, unconfirmed", "Positive"),
ordered = TRUE) ordered = TRUE)
} }
if (verbose == TRUE) {
x[, c("row_number",
col_mo,
"MDRO",
"reason")]
} else {
x$MDRO
}
} }
#' @rdname mdro #' @rdname mdro

103
R/mic.R
View File

@ -51,8 +51,6 @@
#' #'
#' plot(mic_data) #' plot(mic_data)
#' barplot(mic_data) #' barplot(mic_data)
#'
#' library(clean)
#' freq(mic_data) #' freq(mic_data)
as.mic <- function(x, na.rm = FALSE) { as.mic <- function(x, na.rm = FALSE) {
if (is.mic(x)) { if (is.mic(x)) {
@ -97,98 +95,15 @@ as.mic <- function(x, na.rm = FALSE) {
x[x.bak != "" & x == ""] <- "invalid" x[x.bak != "" & x == ""] <- "invalid"
# these are allowed MIC values and will become factor levels # these are allowed MIC values and will become factor levels
lvls <- c("<0.001", "<=0.001", "0.001", ">=0.001", ">0.001", ops <- c("<", "<=", "", ">=", ">")
"<0.002", "<=0.002", "0.002", ">=0.002", ">0.002", lvls <- c(c(t(sapply(ops, function(x) paste0(x, "0.00", 1:9)))),
"<0.003", "<=0.003", "0.003", ">=0.003", ">0.003", unique(c(t(sapply(ops, function(x) paste0(x, sort(as.double(paste0("0.0",
"<0.004", "<=0.004", "0.004", ">=0.004", ">0.004", sort(c(1:99, 125, 128, 256, 512, 625)))))))))),
"<0.005", "<=0.005", "0.005", ">=0.005", ">0.005", unique(c(t(sapply(ops, function(x) paste0(x, sort(as.double(paste0("0.",
"<0.006", "<=0.006", "0.006", ">=0.006", ">0.006", c(1:99, 125, 128, 256, 512))))))))),
"<0.007", "<=0.007", "0.007", ">=0.007", ">0.007", c(t(sapply(ops, function(x) paste0(x, sort(c(1:9, 1.5)))))),
"<0.008", "<=0.008", "0.008", ">=0.008", ">0.008", c(t(sapply(ops, function(x) paste0(x, c(10:98)[9:98 %% 2 == TRUE])))),
"<0.009", "<=0.009", "0.009", ">=0.009", ">0.009", c(t(sapply(ops, function(x) paste0(x, sort(c(2 ^ c(7:10), 80 * c(2:12))))))))
"<0.01", "<=0.01", "0.01", ">=0.01", ">0.01",
"<0.012", "<=0.012", "0.012", ">=0.012", ">0.012",
"<0.0125", "<=0.0125", "0.0125", ">=0.0125", ">0.0125",
"<0.016", "<=0.016", "0.016", ">=0.016", ">0.016",
"<0.019", "<=0.019", "0.019", ">=0.019", ">0.019",
"<0.02", "<=0.02", "0.02", ">=0.02", ">0.02",
"<0.023", "<=0.023", "0.023", ">=0.023", ">0.023",
"<0.025", "<=0.025", "0.025", ">=0.025", ">0.025",
"<0.028", "<=0.028", "0.028", ">=0.028", ">0.028",
"<0.03", "<=0.03", "0.03", ">=0.03", ">0.03",
"<0.031", "<=0.031", "0.031", ">=0.031", ">0.031",
"<0.032", "<=0.032", "0.032", ">=0.032", ">0.032",
"<0.038", "<=0.038", "0.038", ">=0.038", ">0.038",
"<0.04", "<=0.04", "0.04", ">=0.04", ">0.04",
"<0.047", "<=0.047", "0.047", ">=0.047", ">0.047",
"<0.05", "<=0.05", "0.05", ">=0.05", ">0.05",
"<0.054", "<=0.054", "0.054", ">=0.054", ">0.054",
"<0.06", "<=0.06", "0.06", ">=0.06", ">0.06",
"<0.0625", "<=0.0625", "0.0625", ">=0.0625", ">0.0625",
"<0.063", "<=0.063", "0.063", ">=0.063", ">0.063",
"<0.064", "<=0.064", "0.064", ">=0.064", ">0.064",
"<0.075", "<=0.075", "0.075", ">=0.075", ">0.075",
"<0.08", "<=0.08", "0.08", ">=0.08", ">0.08",
"<0.09", "<=0.09", "0.09", ">=0.09", ">0.09",
"<0.094", "<=0.094", "0.094", ">=0.094", ">0.094",
"<0.095", "<=0.095", "0.095", ">=0.095", ">0.095",
"<0.1", "<=0.1", "0.1", ">=0.1", ">0.1",
"<0.12", "<=0.12", "0.12", ">=0.12", ">0.12",
"<0.125", "<=0.125", "0.125", ">=0.125", ">0.125",
"<0.128", "<=0.128", "0.128", ">=0.128", ">0.128",
"<0.15", "<=0.15", "0.15", ">=0.15", ">0.15",
"<0.16", "<=0.16", "0.16", ">=0.16", ">0.16",
"<0.17", "<=0.17", "0.17", ">=0.17", ">0.17",
"<0.18", "<=0.18", "0.18", ">=0.18", ">0.18",
"<0.19", "<=0.19", "0.19", ">=0.19", ">0.19",
"<0.2", "<=0.2", "0.2", ">=0.2", ">0.2",
"<0.23", "<=0.23", "0.23", ">=0.23", ">0.23",
"<0.25", "<=0.25", "0.25", ">=0.25", ">0.25",
"<0.256", "<=0.256", "0.256", ">=0.256", ">0.256",
"<0.28", "<=0.28", "0.28", ">=0.28", ">0.28",
"<0.3", "<=0.3", "0.3", ">=0.3", ">0.3",
"<0.32", "<=0.32", "0.32", ">=0.32", ">0.32",
"<0.35", "<=0.35", "0.35", ">=0.35", ">0.35",
"<0.36", "<=0.36", "0.36", ">=0.36", ">0.36",
"<0.38", "<=0.38", "0.38", ">=0.38", ">0.38",
"<0.47", "<=0.47", "0.47", ">=0.47", ">0.47",
"<0.5", "<=0.5", "0.5", ">=0.5", ">0.5",
"<0.512", "<=0.512", "0.512", ">=0.512", ">0.512",
"<0.64", "<=0.64", "0.64", ">=0.64", ">0.64",
"<0.73", "<=0.73", "0.73", ">=0.73", ">0.73",
"<0.75", "<=0.75", "0.75", ">=0.75", ">0.75",
"<0.8", "<=0.8", "0.8", ">=0.8", ">0.8",
"<0.94", "<=0.94", "0.94", ">=0.94", ">0.94",
"<1", "<=1", "1", ">=1", ">1",
"<1.5", "<=1.5", "1.5", ">=1.5", ">1.5",
"<2", "<=2", "2", ">=2", ">2",
"<3", "<=3", "3", ">=3", ">3",
"<4", "<=4", "4", ">=4", ">4",
"<5", "<=5", "5", ">=5", ">5",
"<6", "<=6", "6", ">=6", ">6",
"<7", "<=7", "7", ">=7", ">7",
"<8", "<=8", "8", ">=8", ">8",
"<10", "<=10", "10", ">=10", ">10",
"<12", "<=12", "12", ">=12", ">12",
"<16", "<=16", "16", ">=16", ">16",
"<20", "<=20", "20", ">=20", ">20",
"<24", "<=24", "24", ">=24", ">24",
"<32", "<=32", "32", ">=32", ">32",
"<40", "<=40", "40", ">=40", ">40",
"<48", "<=48", "48", ">=48", ">48",
"<64", "<=64", "64", ">=64", ">64",
"<80", "<=80", "80", ">=80", ">80",
"<96", "<=96", "96", ">=96", ">96",
"<128", "<=128", "128", ">=128", ">128",
"129",
"<160", "<=160", "160", ">=160", ">160",
"<256", "<=256", "256", ">=256", ">256",
"257",
"<320", "<=320", "320", ">=320", ">320",
"<512", "<=512", "512", ">=512", ">512",
"513",
"<1024", "<=1024", "1024", ">=1024", ">1024",
"1025")
na_before <- x[is.na(x) | x == ""] %>% length() na_before <- x[is.na(x) | x == ""] %>% length()
x[!x %in% lvls] <- NA x[!x %in% lvls] <- NA

View File

@ -127,45 +127,3 @@ class_integrity_check <- function(value, type, check_vector) {
} }
value value
} }
# Percentages -------------------------------------------------------------
# Can all be removed when clean 1.2.0 is on CRAN
getdecimalplaces <- function(x, minimum = 0, maximum = 3) {
if (maximum < minimum) {
maximum <- minimum
}
if (minimum > maximum) {
minimum <- maximum
}
max_places <- max(unlist(lapply(strsplit(sub("0+$", "",
as.character(x * 100)), ".", fixed = TRUE),
function(y) ifelse(length(y) == 2, nchar(y[2]), 0))), na.rm = TRUE)
max(min(max_places,
maximum, na.rm = TRUE),
minimum, na.rm = TRUE)
}
round2 <- function(x, digits = 0, force_zero = TRUE) {
# https://stackoverflow.com/a/12688836/4575331
val <- (trunc((abs(x) * 10 ^ digits) + 0.5) / 10 ^ digits) * sign(x)
if (digits > 0 & force_zero == TRUE) {
val[val != as.integer(val) & !is.na(val)] <- paste0(val[val != as.integer(val) & !is.na(val)],
strrep("0", max(0, digits - nchar(gsub(".*[.](.*)$", "\\1", val[val != as.integer(val) & !is.na(val)])))))
}
val
}
percentage <- function(x, digits = NULL, ...) {
if (is.null(digits)) {
digits <- getdecimalplaces(x, minimum = 0, maximum = 1)
}
# round right: percentage(0.4455) should return "44.6%", not "44.5%"
x <- as.numeric(round2(x, digits = digits + 2))
x_formatted <- format(as.double(x) * 100, scientific = FALSE, digits = digits, nsmall = digits, ...)
x_formatted[!is.na(x)] <- paste0(x_formatted[!is.na(x)], "%")
x_formatted
}

4
R/mo.R
View File

@ -267,7 +267,7 @@ is.mo <- function(x) {
#' @importFrom dplyr %>% pull left_join n_distinct progress_estimated filter distinct #' @importFrom dplyr %>% pull left_join n_distinct progress_estimated filter distinct
#' @importFrom data.table data.table as.data.table setkey #' @importFrom data.table data.table as.data.table setkey
#' @importFrom crayon magenta red blue silver italic #' @importFrom crayon magenta red blue silver italic
# @importFrom clean percentage #' @importFrom cleaner percentage
# param property a column name of AMR::microorganisms # param property a column name of AMR::microorganisms
# param initial_search logical - is FALSE when coming from uncertain tries, which uses exec_as.mo internally too # param initial_search logical - is FALSE when coming from uncertain tries, which uses exec_as.mo internally too
# param dyslexia_mode logical - also check for characters that resemble others # param dyslexia_mode logical - also check for characters that resemble others
@ -1774,7 +1774,7 @@ pillar_shaft.mo <- function(x, ...) {
#' @exportMethod summary.mo #' @exportMethod summary.mo
#' @importFrom dplyr n_distinct #' @importFrom dplyr n_distinct
#' @importFrom clean freq top_freq #' @importFrom cleaner freq top_freq
#' @export #' @export
#' @noRd #' @noRd
summary.mo <- function(object, ...) { summary.mo <- function(object, ...) {

View File

@ -73,8 +73,6 @@
#' #'
#' plot(rsi_data) # for percentages #' plot(rsi_data) # for percentages
#' barplot(rsi_data) # for frequencies #' barplot(rsi_data) # for frequencies
#'
#' library(clean)
#' freq(rsi_data) # frequency table with informative header #' freq(rsi_data) # frequency table with informative header
#' #'
#' # using dplyr's mutate #' # using dplyr's mutate

View File

@ -39,7 +39,7 @@ dots2vars <- function(...) {
} }
#' @importFrom dplyr %>% pull all_vars any_vars filter_all funs mutate_all #' @importFrom dplyr %>% pull all_vars any_vars filter_all funs mutate_all
# @importFrom clean percentage #' @importFrom cleaner percentage
rsi_calc <- function(..., rsi_calc <- function(...,
ab_result, ab_result,
minimum = 0, minimum = 0,

View File

@ -308,7 +308,7 @@ antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]] <- list(c(anti
antibiotics[which(antibiotics$ab == "GEH"), "abbreviations"][[1]] <- list(c("gehl", "gentamicin high", "genta high")) antibiotics[which(antibiotics$ab == "GEH"), "abbreviations"][[1]] <- list(c("gehl", "gentamicin high", "genta high"))
antibiotics[which(antibiotics$ab == "STH"), "abbreviations"][[1]] <- list(c("sthl", "streptomycin high", "strepto high")) antibiotics[which(antibiotics$ab == "STH"), "abbreviations"][[1]] <- list(c("sthl", "streptomycin high", "strepto high"))
# add imi to imipenem # add imi to imipenem
antibiotics[which(antibiotics$ab == "IPM"), "abbreviations"][[1]] <- list(c("imip", "imi")) antibiotics[which(antibiotics$ab == "IPM"), "abbreviations"][[1]] <- list(c("imip", "imi", "imp"))
## new ATC codes ## new ATC codes
# ceftaroline # ceftaroline

Binary file not shown.

View File

@ -84,7 +84,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a> <a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -84,7 +84,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">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -84,7 +84,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">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -84,7 +84,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">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -45,7 +45,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">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -84,7 +84,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">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>
@ -231,16 +231,20 @@
</div> </div>
<div id="amr-0-8-0-9007" class="section level1"> <div id="amr-0-8-0-9008" class="section level1">
<h1 class="page-header"> <h1 class="page-header">
<a href="#amr-0-8-0-9007" class="anchor"></a>AMR 0.8.0.9007<small> Unreleased </small> <a href="#amr-0-8-0-9008" class="anchor"></a>AMR 0.8.0.9008<small> Unreleased </small>
</h1> </h1>
<p><small>Last updated: 30-Oct-2019</small></p> <p><small>Last updated: 03-Nov-2019</small></p>
<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>
<ul> <ul>
<li>Support for a new MDRO guideline: Magiorakos AP, Srinivasan A <em>et al.</em> “Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance.” Clinical Microbiology and Infection (2012). <strong>This is now the new default guideline for the <code><a href="../reference/mdro.html">mdro()</a></code> function.</strong> <li>Support for a new MDRO guideline: Magiorakos AP, Srinivasan A <em>et al.</em> “Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance.” Clinical Microbiology and Infection (2012).
<ul>
<li>This is now the new default guideline for the <code><a href="../reference/mdro.html">mdro()</a></code> function</li>
<li>The new Verbose mode (<code><a href="../reference/mdro.html">mdro(...., verbose = TRUE)</a></code>) returns an informative data set where the reason for MDRO determination is given for every isolate</li>
</ul>
</li> </li>
</ul> </ul>
</div> </div>
@ -257,6 +261,14 @@
<li>Fix for automatically determining columns with antibiotic results in <code><a href="../reference/mdro.html">mdro()</a></code> and <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> <li>Fix for automatically determining columns with antibiotic results in <code><a href="../reference/mdro.html">mdro()</a></code> and <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>
</li> </li>
<li>Added ATC codes for ceftaroline, ceftobiprole and faropenem and fixed two typos in the <code>antibiotics</code> data set</li> <li>Added ATC codes for ceftaroline, ceftobiprole and faropenem and fixed two typos in the <code>antibiotics</code> data set</li>
<li>More robust way of determining valid MIC values</li>
</ul>
</div>
<div id="other" class="section level3">
<h3 class="hasAnchor">
<a href="#other" class="anchor"></a>Other</h3>
<ul>
<li>Change dependency on <code>clean</code> to <code>cleaner</code>, as this package was renamed accordingly upon CRAN request</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -286,7 +298,7 @@ For WHONET users, this means that all records/isolates with organism code <code>
<a class="sourceLine" id="cb2-10" data-line-number="10"><span class="co">#&gt; Warning message:</span></a> <a class="sourceLine" id="cb2-10" data-line-number="10"><span class="co">#&gt; Warning message:</span></a>
<a class="sourceLine" id="cb2-11" data-line-number="11"><span class="co">#&gt; invalid microorganism code, NA generated</span></a></code></pre></div> <a class="sourceLine" id="cb2-11" data-line-number="11"><span class="co">#&gt; invalid microorganism code, NA generated</span></a></code></pre></div>
This is important, because a value like <code>"testvalue"</code> could never be understood by e.g. <code><a href="../reference/mo_property.html">mo_name()</a></code>, although the class would suggest a valid microbial code.</li> This is important, because a value like <code>"testvalue"</code> could never be understood by e.g. <code><a href="../reference/mo_property.html">mo_name()</a></code>, although the class would suggest a valid microbial code.</li>
<li>Function <code><a href="https://rdrr.io/pkg/clean/man/freq.html">freq()</a></code> has moved to a new package, <a href="https://github.com/msberends/clean"><code>clean</code></a> (<a href="https://cran.r-project.org/package=clean">CRAN link</a>), since creating frequency tables actually does not fit the scope of this package. The <code><a href="https://rdrr.io/pkg/clean/man/freq.html">freq()</a></code> function still works, since it is re-exported from the <code>clean</code> package (which will be installed automatically upon updating this <code>AMR</code> package).</li> <li>Function <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> has moved to a new package, <a href="https://github.com/msberends/clean"><code>clean</code></a> (<a href="https://cran.r-project.org/package=clean">CRAN link</a>), since creating frequency tables actually does not fit the scope of this package. The <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> function still works, since it is re-exported from the <code>clean</code> package (which will be installed automatically upon updating this <code>AMR</code> package).</li>
<li><p>Renamed data set <code>septic_patients</code> to <code>example_isolates</code></p></li> <li><p>Renamed data set <code>septic_patients</code> to <code>example_isolates</code></p></li>
</ul> </ul>
</div> </div>
@ -401,9 +413,9 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
</li> </li>
<li>Added more MIC factor levels (<code><a href="../reference/as.mic.html">as.mic()</a></code>)</li> <li>Added more MIC factor levels (<code><a href="../reference/as.mic.html">as.mic()</a></code>)</li>
</ul> </ul>
<div id="other" class="section level4"> <div id="other-1" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other" class="anchor"></a>Other</h4> <a href="#other-1" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors</li> <li>Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors</li>
<li>Cleaned the coding style of every single syntax line in this package with the help of the <code>lintr</code> package</li> <li>Cleaned the coding style of every single syntax line in this package with the help of the <code>lintr</code> package</li>
@ -484,9 +496,9 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
</li> </li>
</ul> </ul>
</div> </div>
<div id="other-1" class="section level4"> <div id="other-2" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-1" class="anchor"></a>Other</h4> <a href="#other-2" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Fixed a note thrown by CRAN tests</li> <li>Fixed a note thrown by CRAN tests</li>
</ul> </ul>
@ -543,7 +555,7 @@ Please <a href="https://gitlab.com/msberends/AMR/issues/new?issue%5Btitle%5D=Tra
<li>The <code><a href="../reference/age.html">age()</a></code> function gained a new parameter <code>exact</code> to determine ages with decimals</li> <li>The <code><a href="../reference/age.html">age()</a></code> function gained a new parameter <code>exact</code> to determine ages with decimals</li>
<li>Removed deprecated functions <code>guess_mo()</code>, <code>guess_atc()</code>, <code>EUCAST_rules()</code>, <code>interpretive_reading()</code>, <code>rsi()</code> <li>Removed deprecated functions <code>guess_mo()</code>, <code>guess_atc()</code>, <code>EUCAST_rules()</code>, <code>interpretive_reading()</code>, <code>rsi()</code>
</li> </li>
<li>Frequency tables (<code><a href="https://rdrr.io/pkg/clean/man/freq.html">freq()</a></code>): <li>Frequency tables (<code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code>):
<ul> <ul>
<li>speed improvement for microbial IDs</li> <li>speed improvement for microbial IDs</li>
<li>fixed factor level names for R Markdown</li> <li>fixed factor level names for R Markdown</li>
@ -551,12 +563,12 @@ Please <a href="https://gitlab.com/msberends/AMR/issues/new?issue%5Btitle%5D=Tra
<li> <li>
<p>support for boxplots:</p> <p>support for boxplots:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(age) <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb9-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(age) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/graphics/boxplot.html">boxplot</a></span>()</a> <a class="sourceLine" id="cb9-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/graphics/boxplot.html">boxplot</a></span>()</a>
<a class="sourceLine" id="cb9-4" data-line-number="4"><span class="co"># grouped boxplots:</span></a> <a class="sourceLine" id="cb9-4" data-line-number="4"><span class="co"># grouped boxplots:</span></a>
<a class="sourceLine" id="cb9-5" data-line-number="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb9-5" data-line-number="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-6" data-line-number="6"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb9-6" data-line-number="6"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-7" data-line-number="7"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(age) <span class="op">%&gt;%</span></a> <a class="sourceLine" id="cb9-7" data-line-number="7"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(age) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-8" data-line-number="8"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/graphics/boxplot.html">boxplot</a></span>()</a></code></pre></div> <a class="sourceLine" id="cb9-8" data-line-number="8"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/graphics/boxplot.html">boxplot</a></span>()</a></code></pre></div>
</li> </li>
</ul> </ul>
@ -567,7 +579,7 @@ Please <a href="https://gitlab.com/msberends/AMR/issues/new?issue%5Btitle%5D=EUC
<li>Added ceftazidim intrinsic resistance to <em>Streptococci</em> <li>Added ceftazidim intrinsic resistance to <em>Streptococci</em>
</li> </li>
<li>Changed default settings for <code><a href="../reference/age_groups.html">age_groups()</a></code>, to let groups of fives and tens end with 100+ instead of 120+</li> <li>Changed default settings for <code><a href="../reference/age_groups.html">age_groups()</a></code>, to let groups of fives and tens end with 100+ instead of 120+</li>
<li>Fix for <code><a href="https://rdrr.io/pkg/clean/man/freq.html">freq()</a></code> for when all values are <code>NA</code> <li>Fix for <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> for when all values are <code>NA</code>
</li> </li>
<li>Fix for <code><a href="../reference/first_isolate.html">first_isolate()</a></code> for when dates are missing</li> <li>Fix for <code><a href="../reference/first_isolate.html">first_isolate()</a></code> for when dates are missing</li>
<li>Improved speed of <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code> <li>Improved speed of <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code>
@ -580,9 +592,9 @@ Please <a href="https://gitlab.com/msberends/AMR/issues/new?issue%5Btitle%5D=EUC
<li><p>Fix for <code><a href="../reference/mo_property.html">mo_shortname()</a></code> where species would not be determined correctly</p></li> <li><p>Fix for <code><a href="../reference/mo_property.html">mo_shortname()</a></code> where species would not be determined correctly</p></li>
</ul> </ul>
</div> </div>
<div id="other-2" class="section level4"> <div id="other-3" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-2" class="anchor"></a>Other</h4> <a href="#other-3" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Support for R 3.6.0 and later by providing support for <a href="https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html">staged install</a> <li>Support for R 3.6.0 and later by providing support for <a href="https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html">staged install</a>
</li> </li>
@ -789,7 +801,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
</li> </li>
</ul> </ul>
</li> </li>
<li>Frequency tables (<code><a href="https://rdrr.io/pkg/clean/man/freq.html">freq()</a></code> function): <li>Frequency tables (<code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> function):
<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>
@ -797,15 +809,15 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<a class="sourceLine" id="cb19-2" data-line-number="2"><span class="co"># OLD WAY</span></a> <a class="sourceLine" id="cb19-2" data-line-number="2"><span class="co"># OLD WAY</span></a>
<a class="sourceLine" id="cb19-3" data-line-number="3">septic_patients <span class="op">%&gt;%</span></a> <a class="sourceLine" id="cb19-3" data-line-number="3">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb19-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">genus =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo)) <span class="op">%&gt;%</span></a> <a class="sourceLine" id="cb19-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">genus =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo)) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb19-5" data-line-number="5"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(genus)</a> <a class="sourceLine" id="cb19-5" data-line-number="5"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(genus)</a>
<a class="sourceLine" id="cb19-6" data-line-number="6"><span class="co"># NEW WAY</span></a> <a class="sourceLine" id="cb19-6" data-line-number="6"><span class="co"># NEW WAY</span></a>
<a class="sourceLine" id="cb19-7" data-line-number="7">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb19-7" data-line-number="7">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb19-8" data-line-number="8"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a> <a class="sourceLine" id="cb19-8" data-line-number="8"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a>
<a class="sourceLine" id="cb19-9" data-line-number="9"></a> <a class="sourceLine" id="cb19-9" data-line-number="9"></a>
<a class="sourceLine" id="cb19-10" data-line-number="10"><span class="co"># Even supports grouping variables:</span></a> <a class="sourceLine" id="cb19-10" data-line-number="10"><span class="co"># Even supports grouping variables:</span></a>
<a class="sourceLine" id="cb19-11" data-line-number="11">septic_patients <span class="op">%&gt;%</span></a> <a class="sourceLine" id="cb19-11" data-line-number="11">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb19-12" data-line-number="12"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(gender) <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb19-12" data-line-number="12"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(gender) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb19-13" data-line-number="13"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a></code></pre></div> <a class="sourceLine" id="cb19-13" data-line-number="13"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(mo))</a></code></pre></div>
</li> </li>
<li>Header info is now available as a list, with the <code>header</code> function</li> <li>Header info is now available as a list, with the <code>header</code> function</li>
<li>The parameter <code>header</code> is now set to <code>TRUE</code> at default, even for markdown</li> <li>The parameter <code>header</code> is now set to <code>TRUE</code> at default, even for markdown</li>
@ -828,9 +840,9 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<li>if using different lengths of pattern and x in <code><a href="../reference/like.html">%like%</a></code>, it will now return the call</li> <li>if using different lengths of pattern and x in <code><a href="../reference/like.html">%like%</a></code>, it will now return the call</li>
</ul> </ul>
</div> </div>
<div id="other-3" class="section level4"> <div id="other-4" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-3" class="anchor"></a>Other</h4> <a href="#other-4" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Updated licence text to emphasise GPL 2.0 and that this is an R package.</li> <li>Updated licence text to emphasise GPL 2.0 and that this is an R package.</li>
</ul> </ul>
@ -892,18 +904,18 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<li>Using <code>portion_*</code> functions now throws a warning when total available isolate is below parameter <code>minimum</code> <li>Using <code>portion_*</code> functions now throws a warning when total available isolate is below parameter <code>minimum</code>
</li> </li>
<li>Functions <code>as.mo</code>, <code>as.rsi</code>, <code>as.mic</code>, <code>as.atc</code> and <code>freq</code> will not set package name as attribute anymore</li> <li>Functions <code>as.mo</code>, <code>as.rsi</code>, <code>as.mic</code>, <code>as.atc</code> and <code>freq</code> will not set package name as attribute anymore</li>
<li>Frequency tables - <code><a href="https://rdrr.io/pkg/clean/man/freq.html">freq()</a></code>: <li>Frequency tables - <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code>:
<ul> <ul>
<li> <li>
<p>Support for grouping variables, test with:</p> <p>Support for grouping variables, test with:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb21-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb21-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb21-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(gender)</a></code></pre></div> <a class="sourceLine" id="cb21-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(gender)</a></code></pre></div>
</li> </li>
<li> <li>
<p>Support for (un)selecting columns:</p> <p>Support for (un)selecting columns:</p>
<div class="sourceCode" id="cb22"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb22-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode" id="cb22"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb22-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb22-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb22-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb22-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span>count, <span class="op">-</span>cum_count) <span class="co"># only get item, percent, cum_percent</span></a></code></pre></div> <a class="sourceLine" id="cb22-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span>count, <span class="op">-</span>cum_count) <span class="co"># only get item, percent, cum_percent</span></a></code></pre></div>
</li> </li>
<li>Check for <code><a href="https://rdrr.io/pkg/hms/man/Deprecated.html">hms::is.hms</a></code> <li>Check for <code><a href="https://rdrr.io/pkg/hms/man/Deprecated.html">hms::is.hms</a></code>
@ -953,9 +965,9 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<li><p>Percentages will now will rounded more logically (e.g. in <code>freq</code> function)</p></li> <li><p>Percentages will now will rounded more logically (e.g. in <code>freq</code> function)</p></li>
</ul> </ul>
</div> </div>
<div id="other-4" class="section level4"> <div id="other-5" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-4" class="anchor"></a>Other</h4> <a href="#other-5" class="anchor"></a>Other</h4>
<ul> <ul>
<li>New dependency on package <code>crayon</code>, to support formatted text in the console</li> <li>New dependency on package <code>crayon</code>, to support formatted text in the console</li>
<li>Dependency <code>tidyr</code> is now mandatory (went to <code>Import</code> field) since <code>portion_df</code> and <code>count_df</code> rely on it</li> <li>Dependency <code>tidyr</code> is now mandatory (went to <code>Import</code> field) since <code>portion_df</code> and <code>count_df</code> rely on it</li>
@ -1082,17 +1094,17 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<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="cb29"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb29-1" data-line-number="1">my_matrix =<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/with.html">with</a></span>(septic_patients, <span class="kw"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(<span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(age, gender), <span class="dt">ncol =</span> <span class="dv">2</span>))</a> <div class="sourceCode" id="cb29"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb29-1" data-line-number="1">my_matrix =<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/with.html">with</a></span>(septic_patients, <span class="kw"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(<span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(age, gender), <span class="dt">ncol =</span> <span class="dv">2</span>))</a>
<a class="sourceLine" id="cb29-2" data-line-number="2"><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(my_matrix)</a></code></pre></div> <a class="sourceLine" id="cb29-2" data-line-number="2"><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(my_matrix)</a></code></pre></div>
<p>For lists, subsetting is possible:</p> <p>For lists, subsetting is possible:</p>
<div class="sourceCode" id="cb30"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb30-1" data-line-number="1">my_list =<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/list.html">list</a></span>(<span class="dt">age =</span> septic_patients<span class="op">$</span>age, <span class="dt">gender =</span> septic_patients<span class="op">$</span>gender)</a> <div class="sourceCode" id="cb30"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb30-1" data-line-number="1">my_list =<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/list.html">list</a></span>(<span class="dt">age =</span> septic_patients<span class="op">$</span>age, <span class="dt">gender =</span> septic_patients<span class="op">$</span>gender)</a>
<a class="sourceLine" id="cb30-2" data-line-number="2">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(age)</a> <a class="sourceLine" id="cb30-2" data-line-number="2">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(age)</a>
<a class="sourceLine" id="cb30-3" data-line-number="3">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(gender)</a></code></pre></div> <a class="sourceLine" id="cb30-3" data-line-number="3">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(gender)</a></code></pre></div>
</li> </li>
</ul> </ul>
</div> </div>
<div id="other-5" class="section level4"> <div id="other-6" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-5" class="anchor"></a>Other</h4> <a href="#other-6" class="anchor"></a>Other</h4>
<ul> <ul>
<li>More unit tests to ensure better integrity of functions</li> <li>More unit tests to ensure better integrity of functions</li>
</ul> </ul>
@ -1160,13 +1172,13 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<ul> <ul>
<li>A vignette to explain its usage</li> <li>A vignette to explain its usage</li>
<li>Support for <code>rsi</code> (antimicrobial resistance) to use as input</li> <li>Support for <code>rsi</code> (antimicrobial resistance) to use as input</li>
<li>Support for <code>table</code> to use as input: <code><a href="https://rdrr.io/pkg/clean/man/freq.html">freq(table(x, y))</a></code> <li>Support for <code>table</code> to use as input: <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq(table(x, y))</a></code>
</li> </li>
<li>Support for existing functions <code>hist</code> and <code>plot</code> to use a frequency table as input: <code><a href="https://rdrr.io/r/graphics/hist.html">hist(freq(df$age))</a></code> <li>Support for existing functions <code>hist</code> and <code>plot</code> to use a frequency table as input: <code><a href="https://rdrr.io/r/graphics/hist.html">hist(freq(df$age))</a></code>
</li> </li>
<li>Support for <code>as.vector</code>, <code>as.data.frame</code>, <code>as_tibble</code> and <code>format</code> <li>Support for <code>as.vector</code>, <code>as.data.frame</code>, <code>as_tibble</code> and <code>format</code>
</li> </li>
<li>Support for quasiquotation: <code><a href="https://rdrr.io/pkg/clean/man/freq.html">freq(mydata, mycolumn)</a></code> is the same as <code>mydata %&gt;% freq(mycolumn)</code> <li>Support for quasiquotation: <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq(mydata, mycolumn)</a></code> is the same as <code>mydata %&gt;% freq(mycolumn)</code>
</li> </li>
<li>Function <code>top_freq</code> function to return the top/below <em>n</em> items as vector</li> <li>Function <code>top_freq</code> function to return the top/below <em>n</em> items as vector</li>
<li>Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)</li> <li>Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)</li>
@ -1219,9 +1231,9 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<li>Other small fixes</li> <li>Other small fixes</li>
</ul> </ul>
</div> </div>
<div id="other-6" class="section level4"> <div id="other-7" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-6" class="anchor"></a>Other</h4> <a href="#other-7" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher <li>Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher
<ul> <ul>
@ -1281,9 +1293,9 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<li>Functions <code>as.rsi</code> and <code>as.mic</code> now add the package name and version as attributes</li> <li>Functions <code>as.rsi</code> and <code>as.mic</code> now add the package name and version as attributes</li>
</ul> </ul>
</div> </div>
<div id="other-7" class="section level4"> <div id="other-8" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-7" class="anchor"></a>Other</h4> <a href="#other-8" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Expanded <code>README.md</code> with more examples</li> <li>Expanded <code>README.md</code> with more examples</li>
<li>Added <a href="https://orcid.org">ORCID</a> of authors to DESCRIPTION file</li> <li>Added <a href="https://orcid.org">ORCID</a> of authors to DESCRIPTION file</li>
@ -1320,7 +1332,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<div id="tocnav"> <div id="tocnav">
<h2>Contents</h2> <h2>Contents</h2>
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li><a href="#amr-0-8-0-9007">0.8.0.9007</a></li> <li><a href="#amr-0-8-0-9008">0.8.0.9008</a></li>
<li><a href="#amr-0-8-0">0.8.0</a></li> <li><a href="#amr-0-8-0">0.8.0</a></li>
<li><a href="#amr-0-7-1">0.7.1</a></li> <li><a href="#amr-0-7-1">0.7.1</a></li>
<li><a href="#amr-0-7-0">0.7.0</a></li> <li><a href="#amr-0-7-0">0.7.0</a></li>

View File

@ -85,7 +85,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">0.8.0</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>
@ -288,9 +288,7 @@
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='no'>mic_data</span>) <span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='no'>mic_data</span>)
<span class='fu'><a href='https://rdrr.io/r/graphics/barplot.html'>barplot</a></span>(<span class='no'>mic_data</span>) <span class='fu'><a href='https://rdrr.io/r/graphics/barplot.html'>barplot</a></span>(<span class='no'>mic_data</span>)
<span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>(<span class='no'>mic_data</span>)</pre>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>clean</span>)
<span class='fu'><a href='https://rdrr.io/pkg/clean/man/freq.html'>freq</a></span>(<span class='no'>mic_data</span>)</pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -85,7 +85,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">0.8.0</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>
@ -336,9 +336,7 @@
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='no'>rsi_data</span>) <span class='co'># for percentages</span> <span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='no'>rsi_data</span>) <span class='co'># for percentages</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/barplot.html'>barplot</a></span>(<span class='no'>rsi_data</span>) <span class='co'># for frequencies</span> <span class='fu'><a href='https://rdrr.io/r/graphics/barplot.html'>barplot</a></span>(<span class='no'>rsi_data</span>) <span class='co'># for frequencies</span>
<span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>(<span class='no'>rsi_data</span>) <span class='co'># frequency table with informative header</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>clean</span>)
<span class='fu'><a href='https://rdrr.io/pkg/clean/man/freq.html'>freq</a></span>(<span class='no'>rsi_data</span>) <span class='co'># frequency table with informative header</span>
<span class='co'># using dplyr's mutate</span> <span class='co'># using dplyr's mutate</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>) <span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)

View File

@ -85,7 +85,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">0.8.0</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>
@ -264,9 +264,8 @@ This package contains the complete taxonomic tree of almost all microorganisms (
<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='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>) <pre class="examples"><span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>clean</span>) <span class='no'>microorganisms</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>(<span class='no'>kingdom</span>)
<span class='no'>microorganisms</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://rdrr.io/pkg/clean/man/freq.html'>freq</a></span>(<span class='no'>kingdom</span>) <span class='no'>microorganisms</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>kingdom</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>(<span class='no'>phylum</span>, <span class='kw'>nmax</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
<span class='no'>microorganisms</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>kingdom</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://rdrr.io/pkg/clean/man/freq.html'>freq</a></span>(<span class='no'>phylum</span>, <span class='kw'>nmax</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -85,7 +85,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">0.8.0.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -84,7 +84,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">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -85,7 +85,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">0.8.0</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>
@ -304,11 +304,10 @@
<span class='co'># get frequencies of bacteria whose name start with 'Ent' or 'ent'</span> <span class='co'># get frequencies of bacteria whose name start with 'Ent' or 'ent'</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>) <span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>clean</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='join.html'>left_join_microorganisms</a></span>() <span class='kw'>%&gt;%</span> <span class='fu'><a href='join.html'>left_join_microorganisms</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>genus</span> <span class='kw'>%like%</span> <span class='st'>'^ent'</span>) <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>genus</span> <span class='kw'>%like%</span> <span class='st'>'^ent'</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://rdrr.io/pkg/clean/man/freq.html'>freq</a></span>(<span class='no'>genus</span>, <span class='no'>species</span>)</pre> <span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>(<span class='no'>genus</span>, <span class='no'>species</span>)</pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2> <h2>Contents</h2>

View File

@ -85,7 +85,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">0.8.0.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>
@ -238,7 +238,7 @@
</div> </div>
<pre class="usage"><span class='fu'>mdro</span>(<span class='no'>x</span>, <span class='kw'>guideline</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>col_mo</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>info</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <pre class="usage"><span class='fu'>mdro</span>(<span class='no'>x</span>, <span class='kw'>guideline</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>col_mo</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>info</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='no'>...</span>) <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>pct_required_classes</span> <span class='kw'>=</span> <span class='fl'>0.5</span>, <span class='no'>...</span>)
<span class='fu'>brmo</span>(<span class='no'>x</span>, <span class='kw'>guideline</span> <span class='kw'>=</span> <span class='st'>"BRMO"</span>, <span class='no'>...</span>) <span class='fu'>brmo</span>(<span class='no'>x</span>, <span class='kw'>guideline</span> <span class='kw'>=</span> <span class='st'>"BRMO"</span>, <span class='no'>...</span>)
@ -255,7 +255,7 @@
<colgroup><col class="name" /><col class="desc" /></colgroup> <colgroup><col class="name" /><col class="desc" /></colgroup>
<tr> <tr>
<th>x</th> <th>x</th>
<td><p>table with antibiotic columns, like e.g. <code>AMX</code> and <code>AMC</code></p></td> <td><p>data with antibiotic columns, like e.g. <code>AMX</code> and <code>AMC</code></p></td>
</tr> </tr>
<tr> <tr>
<th>guideline</th> <th>guideline</th>
@ -273,10 +273,18 @@
<th>verbose</th> <th>verbose</th>
<td><p>print additional info: missing antibiotic columns per parameter</p></td> <td><p>print additional info: missing antibiotic columns per parameter</p></td>
</tr> </tr>
<tr>
<th>pct_required_classes</th>
<td><p>minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for <em>S. aureus</em>. Setting this <code>pct_required_classes</code> argument to <code>0.5</code> (default) means that for every <em>S. aureus</em> isolate at least 8 different classes must be available. Any lower number of available classes will return <code>NA</code> for that isolate.</p></td>
</tr>
<tr> <tr>
<th>...</th> <th>...</th>
<td><p>column name of an antibiotic, see section Antibiotics</p></td> <td><p>column name of an antibiotic, see section Antibiotics</p></td>
</tr> </tr>
<tr>
<th>verbose</th>
<td><p>a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.</p></td>
</tr>
</table> </table>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2> <h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
@ -294,7 +302,8 @@
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2> <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>Currently supported guidelines are (case-insensitive):</p><ul> <p>For the <code>pct_required_classes</code> argument, values above 1 will be divided by 100. This is to support both fractions (<code>0.75</code> or <code>3/4</code>) and percentages (<code>75</code>).
Currently supported guidelines are (case-insensitive):</p><ul>
<li><p><code>guideline = "CMI2012"</code>: Magiorakos AP, Srinivasan A <em>et al.</em> "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012) (<a href='https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext'>link</a>)</p></li> <li><p><code>guideline = "CMI2012"</code>: Magiorakos AP, Srinivasan A <em>et al.</em> "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012) (<a href='https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext'>link</a>)</p></li>
<li><p><code>guideline = "EUCAST"</code>: The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (<a href='http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf'>link</a>)</p></li> <li><p><code>guideline = "EUCAST"</code>: The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (<a href='http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf'>link</a>)</p></li>
<li><p><code>guideline = "TB"</code>: The international guideline for multi-drug resistant tuberculosis - World Health Organization "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" (<a href='https://www.who.int/tb/publications/pmdt_companionhandbook/en/'>link</a>)</p></li> <li><p><code>guideline = "TB"</code>: The international guideline for multi-drug resistant tuberculosis - World Health Organization "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" (<a href='https://www.who.int/tb/publications/pmdt_companionhandbook/en/'>link</a>)</p></li>
@ -399,18 +408,18 @@
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'>mdro</span>() <span class='kw'>%&gt;%</span> <span class='fu'>mdro</span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://rdrr.io/pkg/clean/man/freq.html'>freq</a></span>() <span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>()
<span class='co'># \donttest{</span> <span class='co'># \donttest{</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>EUCAST</span> <span class='kw'>=</span> <span class='fu'>mdro</span>(<span class='no'>.</span>), <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>EUCAST</span> <span class='kw'>=</span> <span class='fu'>eucast_exceptional_phenotypes</span>(<span class='no'>.</span>),
<span class='kw'>BRMO</span> <span class='kw'>=</span> <span class='fu'>brmo</span>(<span class='no'>.</span>), <span class='kw'>BRMO</span> <span class='kw'>=</span> <span class='fu'>brmo</span>(<span class='no'>.</span>),
<span class='kw'>MRGN</span> <span class='kw'>=</span> <span class='fu'>mrgn</span>(<span class='no'>.</span>)) <span class='kw'>MRGN</span> <span class='kw'>=</span> <span class='fu'>mrgn</span>(<span class='no'>.</span>))
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>rename</a></span>(<span class='kw'>PIP</span> <span class='kw'>=</span> <span class='no'>TZP</span>) <span class='kw'>%&gt;%</span> <span class='co'># no piperacillin, so take piperacillin/tazobactam</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>rename</a></span>(<span class='kw'>PIP</span> <span class='kw'>=</span> <span class='no'>TZP</span>) <span class='kw'>%&gt;%</span> <span class='co'># no piperacillin, so take piperacillin/tazobactam</span>
<span class='fu'>mrgn</span>() <span class='kw'>%&gt;%</span> <span class='co'># check German guideline</span> <span class='fu'>mrgn</span>() <span class='kw'>%&gt;%</span> <span class='co'># check German guideline</span>
<span class='fu'><a href='https://rdrr.io/pkg/clean/man/freq.html'>freq</a></span>() <span class='co'># check frequencies</span> <span class='fu'><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></span>() <span class='co'># check frequencies</span>
<span class='co'># }</span></pre> <span class='co'># }</span></pre>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@ -85,7 +85,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">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -85,7 +85,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">0.8.0.9007</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>

View File

@ -54,7 +54,7 @@
<meta property="og:description" content="These objects are imported from other packages. Follow the links <meta property="og:description" content="These objects are imported from other packages. Follow the links
below to see their documentation. below to see their documentation.
cleanfreq cleanerfreq
" /> " />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" /> <meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
@ -90,7 +90,7 @@ below to see their documentation.
</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">0.8.0</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
</span> </span>
</div> </div>
@ -242,7 +242,7 @@ below to see their documentation.
<p>These objects are imported from other packages. Follow the links <p>These objects are imported from other packages. Follow the links
below to see their documentation.</p> below to see their documentation.</p>
<dl class='dl-horizontal'> <dl class='dl-horizontal'>
<dt>clean</dt><dd><p><code><a href='https://rdrr.io/pkg/clean/man/freq.html'>freq</a></code></p></dd> <dt>cleaner</dt><dd><p><code><a href='https://rdrr.io/pkg/cleaner/man/freq.html'>freq</a></code></p></dd>
</dl> </dl>
</div> </div>

View File

@ -47,8 +47,6 @@ as.rsi(x = as.mic(4),
plot(mic_data) plot(mic_data)
barplot(mic_data) barplot(mic_data)
library(clean)
freq(mic_data) freq(mic_data)
} }
\seealso{ \seealso{

View File

@ -90,8 +90,6 @@ as.rsi(x = as.mic(4),
plot(rsi_data) # for percentages plot(rsi_data) # for percentages
barplot(rsi_data) # for frequencies barplot(rsi_data) # for frequencies
library(clean)
freq(rsi_data) # frequency table with informative header freq(rsi_data) # frequency table with informative header
# using dplyr's mutate # using dplyr's mutate

View File

@ -30,7 +30,6 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
\examples{ \examples{
library(dplyr) library(dplyr)
library(clean)
microorganisms \%>\% freq(kingdom) microorganisms \%>\% freq(kingdom)
microorganisms \%>\% group_by(kingdom) \%>\% freq(phylum, nmax = NULL) microorganisms \%>\% group_by(kingdom) \%>\% freq(phylum, nmax = NULL)
} }

View File

@ -62,7 +62,6 @@ a \%like\% b
# get frequencies of bacteria whose name start with 'Ent' or 'ent' # get frequencies of bacteria whose name start with 'Ent' or 'ent'
library(dplyr) library(dplyr)
library(clean)
example_isolates \%>\% example_isolates \%>\%
left_join_microorganisms() \%>\% left_join_microorganisms() \%>\%
filter(genus \%like\% '^ent') \%>\% filter(genus \%like\% '^ent') \%>\%

View File

@ -13,7 +13,7 @@ Please see Details for the list of publications used for this function.
} }
\usage{ \usage{
mdro(x, guideline = NULL, col_mo = NULL, info = TRUE, mdro(x, guideline = NULL, col_mo = NULL, info = TRUE,
verbose = FALSE, ...) verbose = FALSE, pct_required_classes = 0.5, ...)
brmo(x, guideline = "BRMO", ...) brmo(x, guideline = "BRMO", ...)
@ -26,7 +26,7 @@ mdr_cmi2012(x, guideline = "CMI2012", ...)
eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...) eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...)
} }
\arguments{ \arguments{
\item{x}{table with antibiotic columns, like e.g. \code{AMX} and \code{AMC}} \item{x}{data with antibiotic columns, like e.g. \code{AMX} and \code{AMC}}
\item{guideline}{a specific guideline to follow. When left empty, the publication by Magiorakos \emph{et al.} (2012, Clinical Microbiology and Infection) will be followed, see Details.} \item{guideline}{a specific guideline to follow. When left empty, the publication by Magiorakos \emph{et al.} (2012, Clinical Microbiology and Infection) will be followed, see Details.}
@ -36,7 +36,11 @@ eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...)
\item{verbose}{print additional info: missing antibiotic columns per parameter} \item{verbose}{print additional info: missing antibiotic columns per parameter}
\item{pct_required_classes}{minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for \emph{S. aureus}. Setting this \code{pct_required_classes} argument to \code{0.5} (default) means that for every \emph{S. aureus} isolate at least 8 different classes must be available. Any lower number of available classes will return \code{NA} for that isolate.}
\item{...}{column name of an antibiotic, see section Antibiotics} \item{...}{column name of an antibiotic, see section Antibiotics}
\item{verbose}{a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.}
} }
\value{ \value{
\itemize{ \itemize{
@ -50,6 +54,7 @@ eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...)
Determine which isolates are multidrug-resistant organisms (MDRO) according to (country-specific) guidelines. Determine which isolates are multidrug-resistant organisms (MDRO) according to (country-specific) guidelines.
} }
\details{ \details{
For the \code{pct_required_classes} argument, values above 1 will be divided by 100. This is to support both fractions (\code{0.75} or \code{3/4}) and percentages (\code{75}).
Currently supported guidelines are (case-insensitive): Currently supported guidelines are (case-insensitive):
\itemize{ \itemize{
\item{\code{guideline = "CMI2012"}: Magiorakos AP, Srinivasan A \emph{et al.} "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012) (\href{https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext}{link})} \item{\code{guideline = "CMI2012"}: Magiorakos AP, Srinivasan A \emph{et al.} "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012) (\href{https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext}{link})}
@ -156,13 +161,13 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
\examples{ \examples{
library(dplyr) library(dplyr)
example_isolates \%>\% example_isolates \%>\%
mdro() \%>\% mdro() \%>\%
freq() freq()
\donttest{ \donttest{
example_isolates \%>\% example_isolates \%>\%
mutate(EUCAST = mdro(.), mutate(EUCAST = eucast_exceptional_phenotypes(.),
BRMO = brmo(.), BRMO = brmo(.),
MRGN = mrgn(.)) MRGN = mrgn(.))

View File

@ -11,6 +11,6 @@ These objects are imported from other packages. Follow the links
below to see their documentation. below to see their documentation.
\describe{ \describe{
\item{clean}{\code{\link[clean]{freq}}} \item{cleaner}{\code{\link[cleaner]{freq}}}
}} }}

View File

@ -22,7 +22,7 @@
context("freq.R") context("freq.R")
test_that("frequency table works", { test_that("frequency table works", {
library(clean) library(cleaner)
# mo # mo
expect_true(is.freq(freq(example_isolates$mo))) expect_true(is.freq(freq(example_isolates$mo)))
# for this to work, the output of mo_gramstain() is to be expected as follows: # for this to work, the output of mo_gramstain() is to be expected as follows:

View File

@ -133,6 +133,7 @@ test_that("mdro works", {
"S. aureus", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R" "S. aureus", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R"
) )
expect_equal(as.integer(mdro(stau)), c(1:4)) expect_equal(as.integer(mdro(stau)), c(1:4))
expect_s3_class(mdro(stau, verbose = TRUE), "data.frame")
ente <- tribble( ente <- tribble(
~mo, ~GEH, ~STH, ~IPM, ~MEM, ~DOR, ~CIP, ~LVX, ~MFX, ~VAN, ~TEC, ~TGC, ~DAP, ~LNZ, ~AMP, ~QDA, ~DOX, ~MNO, ~mo, ~GEH, ~STH, ~IPM, ~MEM, ~DOR, ~CIP, ~LVX, ~MFX, ~VAN, ~TEC, ~TGC, ~DAP, ~LNZ, ~AMP, ~QDA, ~DOX, ~MNO,
@ -142,6 +143,7 @@ test_that("mdro works", {
"Enterococcus", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R" "Enterococcus", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R"
) )
expect_equal(as.integer(mdro(ente)), c(1:4)) expect_equal(as.integer(mdro(ente)), c(1:4))
expect_s3_class(mdro(ente, verbose = TRUE), "data.frame")
entero <- tribble( entero <- tribble(
~mo, ~GEN, ~TOB, ~AMK, ~NET, ~CPT, ~TCC, ~TZP, ~ETP, ~IPM, ~MEM, ~DOR, ~CZO, ~CXM, ~CTX, ~CAZ, ~FEP, ~FOX, ~CTT, ~CIP, ~SXT, ~TGC, ~ATM, ~AMP, ~AMC, ~SAM, ~CHL, ~FOS, ~COL, ~TCY, ~DOX, ~MNO, ~mo, ~GEN, ~TOB, ~AMK, ~NET, ~CPT, ~TCC, ~TZP, ~ETP, ~IPM, ~MEM, ~DOR, ~CZO, ~CXM, ~CTX, ~CAZ, ~FEP, ~FOX, ~CTT, ~CIP, ~SXT, ~TGC, ~ATM, ~AMP, ~AMC, ~SAM, ~CHL, ~FOS, ~COL, ~TCY, ~DOX, ~MNO,
@ -151,6 +153,7 @@ test_that("mdro works", {
"E. coli", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R" "E. coli", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R"
) )
expect_equal(as.integer(mdro(entero)), c(1:4)) expect_equal(as.integer(mdro(entero)), c(1:4))
expect_s3_class(mdro(entero, verbose = TRUE), "data.frame")
pseud <- tribble( pseud <- tribble(
~mo, ~GEN, ~TOB, ~AMK, ~NET, ~IPM, ~MEM, ~DOR, ~CAZ, ~FEP, ~CIP, ~LVX, ~TCC, ~TZP, ~ATM, ~FOS, ~COL, ~PLB, ~mo, ~GEN, ~TOB, ~AMK, ~NET, ~IPM, ~MEM, ~DOR, ~CAZ, ~FEP, ~CIP, ~LVX, ~TCC, ~TZP, ~ATM, ~FOS, ~COL, ~PLB,
@ -160,6 +163,7 @@ test_that("mdro works", {
"P. aeruginosa", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R" "P. aeruginosa", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R"
) )
expect_equal(as.integer(mdro(pseud)), c(1:4)) expect_equal(as.integer(mdro(pseud)), c(1:4))
expect_s3_class(mdro(pseud, verbose = TRUE), "data.frame")
acin <- tribble( acin <- tribble(
~mo, ~GEN, ~TOB, ~AMK, ~NET, ~IPM, ~MEM, ~DOR, ~CIP, ~LVX, ~TZP, ~TCC, ~CTX, ~CRO, ~CAZ, ~FEP, ~SXT, ~SAM, ~COL, ~PLB, ~TCY, ~DOX, ~MNO, ~mo, ~GEN, ~TOB, ~AMK, ~NET, ~IPM, ~MEM, ~DOR, ~CIP, ~LVX, ~TZP, ~TCC, ~CTX, ~CRO, ~CAZ, ~FEP, ~SXT, ~SAM, ~COL, ~PLB, ~TCY, ~DOX, ~MNO,
@ -169,5 +173,6 @@ test_that("mdro works", {
"A. baumannii", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R" "A. baumannii", "R", "R", "I", "I", "I", "I", "I", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R"
) )
expect_equal(as.integer(mdro(acin)), c(1:4)) expect_equal(as.integer(mdro(acin)), c(1:4))
expect_s3_class(mdro(acin, verbose = TRUE), "data.frame")
}) })