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

(v1.3.0.9028) eucast fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-09-24 12:38:13 +02:00
parent 027215ed94
commit 1d982a82b4
24 changed files with 121 additions and 88 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 1.3.0.9027 Version: 1.3.0.9028
Date: 2020-09-24 Date: 2020-09-24
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(

View File

@ -1,4 +1,4 @@
# AMR 1.3.0.9027 # AMR 1.3.0.9028
## <small>Last updated: 24 September 2020</small> ## <small>Last updated: 24 September 2020</small>
Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly! Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly!
@ -32,6 +32,7 @@ Note: some changes in this version were suggested by anonymous reviewers from th
your_data %>% mutate(across(where(is.mic), as.rsi)) your_data %>% mutate(across(where(is.mic), as.rsi))
your_data %>% mutate(across(where(is.disk), as.rsi)) your_data %>% mutate(across(where(is.disk), as.rsi))
``` ```
* Cleaning columns in a data.frame now allows you to specify those columns with tidy selection, e.g. `as.rsi(df, col1:col9)`
* Big speed improvement for interpreting MIC values and disk zone diameters. When interpreting 5,000 MIC values of two antibiotics (10,000 values in total), our benchmarks showed a total run time going from 80.7-85.1 seconds to 1.8-2.0 seconds. * Big speed improvement for interpreting MIC values and disk zone diameters. When interpreting 5,000 MIC values of two antibiotics (10,000 values in total), our benchmarks showed a total run time going from 80.7-85.1 seconds to 1.8-2.0 seconds.
* Added parameter 'add_intrinsic_resistance' (defaults to `FALSE`), that considers intrinsic resistance according to EUCAST * Added parameter 'add_intrinsic_resistance' (defaults to `FALSE`), that considers intrinsic resistance according to EUCAST
* Fixed a bug where in EUCAST rules the breakpoint for R would be interpreted as ">=" while this should have been "<" * Fixed a bug where in EUCAST rules the breakpoint for R would be interpreted as ">=" while this should have been "<"

View File

@ -136,6 +136,11 @@ eucast_rules <- function(x,
version_expertrules = 3.2, version_expertrules = 3.2,
...) { ...) {
x_deparsed <- deparse(substitute(x))
if (!x_deparsed %like% "[a-z]") {
x_deparsed <- "your_data"
}
check_dataset_integrity() check_dataset_integrity()
version_breakpoints <- as.double(version_breakpoints) version_breakpoints <- as.double(version_breakpoints)
@ -152,12 +157,12 @@ eucast_rules <- function(x,
rules <- getOption("AMR.eucast_rules") rules <- getOption("AMR.eucast_rules")
} }
if (verbose == TRUE & info == TRUE) { if (interactive() & verbose == TRUE & info == TRUE) {
txt <- paste0("WARNING: In Verbose mode, the eucast_rules() function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way.", txt <- paste0("WARNING: In Verbose mode, the eucast_rules() function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way.",
"\n\nThis may overwrite your existing data if you use e.g.:", "\n\nThis may overwrite your existing data if you use e.g.:",
"\ndata <- eucast_rules(data, verbose = TRUE)\n\nDo you want to continue?") "\ndata <- eucast_rules(data, verbose = TRUE)\n\nDo you want to continue?")
showQuestion <- import_fn("showQuestion", "rstudioapi", error_on_fail = FALSE) showQuestion <- import_fn("showQuestion", "rstudioapi", error_on_fail = FALSE)
if (!is.null(showQuestion) & interactive()) { if (!is.null(showQuestion)) {
q_continue <- showQuestion("Using verbose = TRUE with eucast_rules()", txt) q_continue <- showQuestion("Using verbose = TRUE with eucast_rules()", txt)
} else { } else {
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt) q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
@ -504,6 +509,7 @@ eucast_rules <- function(x,
paste(collapse = ", ") paste(collapse = ", ")
x <- gsub("_", " ", x, fixed = TRUE) x <- gsub("_", " ", x, fixed = TRUE)
x <- gsub("except CAZ", paste("except", ab_name("CAZ", language = NULL, tolower = TRUE)), x, fixed = TRUE) x <- gsub("except CAZ", paste("except", ab_name("CAZ", language = NULL, tolower = TRUE)), x, fixed = TRUE)
x <- gsub("cephalosporins (1st|2nd|3rd|4th|5th)", "cephalosporins (\\1 gen.)", x)
x x
} }
format_antibiotic_names <- function(ab_names, ab_results) { format_antibiotic_names <- function(ab_names, ab_results) {
@ -881,9 +887,13 @@ eucast_rules <- function(x,
rownames(verbose_info) <- NULL rownames(verbose_info) <- NULL
affected <- x.bak[which(x.bak$`.rowid` %in% x$`.rowid`), , drop = FALSE] affected <- x.bak[which(x.bak$`.rowid` %in% x$`.rowid`), , drop = FALSE]
rows_affected <- as.integer(rownames(affected)) rows_affected <- as.integer(rownames(affected))
verbose_info <- data.frame(row = rows_affected, rowid = affected[, ".rowid", drop = TRUE]) %pm>% verbose_info <- verbose_info %pm>%
pm_left_join(verbose_info, by = "rowid") %pm>% pm_left_join(data.frame(row = rows_affected,
rowid = affected[, ".rowid", drop = TRUE],
stringsAsFactors = FALSE),
by = "rowid") %pm>%
pm_select(-rowid) %pm>% pm_select(-rowid) %pm>%
pm_select(row, pm_everything()) %pm>%
pm_filter(!is.na(new)) %pm>% pm_filter(!is.na(new)) %pm>%
pm_arrange(row, rule_group, rule_name, col) pm_arrange(row, rule_group, rule_name, col)
@ -919,7 +929,7 @@ eucast_rules <- function(x,
pm_count(new, name = "n") pm_count(new, name = "n")
cat(paste(" -", cat(paste(" -",
paste0(formatnr(added_summary$n), " test result", ifelse(added_summary$n > 1, "s", ""), paste0(formatnr(added_summary$n), " test result", ifelse(added_summary$n > 1, "s", ""),
" added as ", added_summary$new), collapse = "\n")) " added as ", paste0('"', added_summary$new, '"')), collapse = "\n"))
} }
# print changed values # print changed values
@ -942,7 +952,7 @@ eucast_rules <- function(x,
pm_count(old, new, name = "n") pm_count(old, new, name = "n")
cat(paste(" -", cat(paste(" -",
paste0(formatnr(changed_summary$n), " test result", ifelse(changed_summary$n > 1, "s", ""), " changed from ", paste0(formatnr(changed_summary$n), " test result", ifelse(changed_summary$n > 1, "s", ""), " changed from ",
changed_summary$old, " to ", changed_summary$new), collapse = "\n")) paste0('"', changed_summary$old, '"'), " to ", paste0('"', changed_summary$new, '"')), collapse = "\n"))
cat("\n") cat("\n")
} }
@ -955,9 +965,12 @@ eucast_rules <- function(x,
} }
} }
if (isTRUE(warn_lacking_rsi_class)) { if (isTRUE(warn_lacking_rsi_class)) {
warning("Not all columns with antimicrobial results are of class <rsi>.\n", unique_cols <- colnames(x.bak)[colnames(x.bak) %in% verbose_info$col]
"Transform eligible columns to class <rsi> on beforehand: your_data %pm>% mutate_if(is.rsi.eligible, as.rsi)", warning("Not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
" ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
" ", x_deparsed, " %>% as.rsi(", unique_cols[1], ":", unique_cols[length(unique_cols)], ")",
call. = FALSE) call. = FALSE)
} }
@ -1010,7 +1023,7 @@ edit_rsi <- function(x,
if (length(rows) > 0 & length(cols) > 0) { if (length(rows) > 0 & length(cols) > 0) {
new_edits <- x new_edits <- x
if (any(!sapply(x[, cols, drop = FALSE], is.rsi), na.rm = TRUE)) { if (any(!sapply(x[, cols, drop = FALSE], is.rsi), na.rm = TRUE)) {
track_changes$warn <- TRUE track_changes$rsi_warn <- TRUE
} }
tryCatch( tryCatch(
# insert into original table # insert into original table
@ -1044,7 +1057,7 @@ edit_rsi <- function(x,
) )
track_changes$output <- new_edits track_changes$output <- new_edits
if (isTRUE(info) && isFALSE(all.equal(x, track_changes$output))) { if (isTRUE(info) && !isTRUE(all.equal(x, track_changes$output))) {
get_original_rows <- function(rowids) { get_original_rows <- function(rowids) {
as.integer(rownames(original_data[which(original_data$.rowid %in% rowids), , drop = FALSE])) as.integer(rownames(original_data[which(original_data$.rowid %in% rowids), , drop = FALSE]))
} }

58
R/rsi.R
View File

@ -33,7 +33,7 @@
#' @param conserve_capped_values a logical to indicate that MIC values starting with `">"` (but not `">="`) must always return "R" , and that MIC values starting with `"<"` (but not `"<="`) must always return "S" #' @param conserve_capped_values a logical to indicate that MIC values starting with `">"` (but not `">="`) must always return "R" , and that MIC values starting with `"<"` (but not `"<="`) must always return "S"
#' @param add_intrinsic_resistance *(only useful when using a EUCAST guideline)* a logical to indicate whether intrinsic antibiotic resistance must also be considered for applicable bug-drug combinations, meaning that e.g. ampicillin will always return "R" in *Klebsiella* species. Determination is based on the [intrinsic_resistant] data set, that itself is based on 'EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes', version `r EUCAST_VERSION_EXPERT_RULES`. #' @param add_intrinsic_resistance *(only useful when using a EUCAST guideline)* a logical to indicate whether intrinsic antibiotic resistance must also be considered for applicable bug-drug combinations, meaning that e.g. ampicillin will always return "R" in *Klebsiella* species. Determination is based on the [intrinsic_resistant] data set, that itself is based on 'EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes', version `r EUCAST_VERSION_EXPERT_RULES`.
#' @param threshold maximum fraction of invalid antimicrobial interpretations of `x`, please see *Examples* #' @param threshold maximum fraction of invalid antimicrobial interpretations of `x`, please see *Examples*
#' @param ... parameters passed on to methods #' @param ... for using on a [data.frame]: names of columns to apply [as.rsi()] on (supports tidy selection like `AMX:VAN`). Otherwise: parameters passed on to methods.
#' @details #' @details
#' ## How it works #' ## How it works
#' #'
@ -86,7 +86,7 @@
#' A microorganism is categorised as *Susceptible, Increased exposure* when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection. #' A microorganism is categorised as *Susceptible, Increased exposure* when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
#' #'
#' This AMR package honours this new insight. Use [susceptibility()] (equal to [proportion_SI()]) to determine antimicrobial susceptibility and [count_susceptible()] (equal to [count_SI()]) to count susceptible isolates. #' This AMR package honours this new insight. Use [susceptibility()] (equal to [proportion_SI()]) to determine antimicrobial susceptibility and [count_susceptible()] (equal to [count_SI()]) to count susceptible isolates.
#' @return Ordered factor with new class [`rsi`] #' @return Ordered [factor] with new class [`rsi`]
#' @aliases rsi #' @aliases rsi
#' @export #' @export
#' @seealso [as.mic()], [as.disk()], [as.mo()] #' @seealso [as.mic()], [as.disk()], [as.mo()]
@ -150,7 +150,7 @@
#' #'
#' as.rsi(c("S", "I", "R", "A", "B", "C")) #' as.rsi(c("S", "I", "R", "A", "B", "C"))
#' as.rsi("<= 0.002; S") # will return "S" #' as.rsi("<= 0.002; S") # will return "S"
#'
#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370))) #' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
#' is.rsi(rsi_data) #' is.rsi(rsi_data)
#' plot(rsi_data) # for percentages #' plot(rsi_data) # for percentages
@ -160,6 +160,9 @@
#' library(dplyr) #' library(dplyr)
#' example_isolates %>% #' example_isolates %>%
#' mutate_at(vars(PEN:RIF), as.rsi) #' mutate_at(vars(PEN:RIF), as.rsi)
#' # same:
#' example_isolates %>%
#' as.rsi(PEN:RIF)
#' #'
#' # fastest way to transform all columns with already valid AMR results to class `rsi`: #' # fastest way to transform all columns with already valid AMR results to class `rsi`:
#' example_isolates %>% #' example_isolates %>%
@ -419,12 +422,13 @@ as.rsi.disk <- function(x,
#' @rdname as.rsi #' @rdname as.rsi
#' @export #' @export
as.rsi.data.frame <- function(x, as.rsi.data.frame <- function(x,
...,
col_mo = NULL, col_mo = NULL,
guideline = "EUCAST", guideline = "EUCAST",
uti = NULL, uti = NULL,
conserve_capped_values = FALSE, conserve_capped_values = FALSE,
add_intrinsic_resistance = FALSE, add_intrinsic_resistance = FALSE) {
...) {
# 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)) {
@ -471,38 +475,46 @@ as.rsi.data.frame <- function(x,
} }
i <- 0 i <- 0
sel <- colnames(pm_select(x, ...))
ab_cols <- colnames(x)[sapply(x, function(y) { ab_cols <- colnames(x)[sapply(x, function(y) {
i <<- i + 1 i <<- i + 1
check <- is.mic(y) | is.disk(y) check <- is.mic(y) | is.disk(y)
ab <- colnames(x)[i] ab <- colnames(x)[i]
ab_coerced <- suppressWarnings(as.ab(ab)) if (length(sel) == 0 || (length(sel) > 0 && ab %in% sel)) {
if (is.na(ab_coerced)) { ab_coerced <- suppressWarnings(as.ab(ab))
# not even a valid AB code if (is.na(ab_coerced) | !ab %in% sel) {
return(FALSE) # not even a valid AB code
} else if (!check & all_valid_mics(y)) { return(FALSE)
message(font_blue(paste0("NOTE: Assuming column `", ab, "` (", } else {
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""), if (!check & all_valid_mics(y)) {
ab_name(ab_coerced, tolower = TRUE), ") contains MIC values."))) message(font_blue(paste0("NOTE: Assuming column `", ab, "` (",
return(TRUE) ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
} else if (!check & all_valid_disks(y)) { ab_name(ab_coerced, tolower = TRUE), ") contains MIC values.")))
message(font_blue(paste0("NOTE: Assuming column `", ab, "` (", } else if (!check & all_valid_disks(y)) {
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""), message(font_blue(paste0("NOTE: Assuming column `", ab, "` (",
ab_name(ab_coerced, tolower = TRUE), ") contains disk zones."))) ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
return(TRUE) ab_name(ab_coerced, tolower = TRUE), ") contains disk zones.")))
} else if (!is.rsi(y)) {
message(font_blue(paste0("NOTE: Assuming column `", ab, "` (",
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
ab_name(ab_coerced, tolower = TRUE), ") must be cleaned to valid R/SI values.")))
}
return(TRUE)
}
} else { } else {
return(check) return(FALSE)
} }
})] })]
stop_if(length(ab_cols) == 0, stop_if(length(ab_cols) == 0,
"no columns with MIC values or disk zones found in this data set. Use as.mic() or as.disk() to transform antimicrobial columns.") "no columns with MIC values, disk zones or antibiotic column names found in this data set. Use as.mic() or as.disk() to transform antimicrobial columns.")
# set type per column # set type per column
types <- character(length(ab_cols)) types <- character(length(ab_cols))
types[sapply(x[, ab_cols], is.mic)] <- "mic" types[sapply(x[, ab_cols], is.mic)] <- "mic"
types[types == "" & sapply(x[, ab_cols], all_valid_mics)] <- "mic" types[types == "" & sapply(x[, ab_cols], all_valid_mics)] <- "mic"
types[sapply(x[, ab_cols], is.disk)] <- "disk" types[sapply(x[, ab_cols], is.disk)] <- "disk"
types[types == "" & sapply(x[, ab_cols], all_valid_disks)] <- "disk" types[types == "" & sapply(x[, ab_cols], all_valid_disks)] <- "disk"
types[types == "" & !sapply(x[, ab_cols], is.rsi)] <- "rsi"
for (i in seq_len(length(ab_cols))) { for (i in seq_len(length(ab_cols))) {
if (types[i] == "mic") { if (types[i] == "mic") {
@ -518,6 +530,8 @@ as.rsi.data.frame <- function(x,
ab = ab_cols[i], ab = ab_cols[i],
guideline = guideline, guideline = guideline,
uti = uti) uti = uti)
} else if (types[i] == "rsi") {
x[, ab_cols[i]] <- as.rsi.default(x = x %pm>% pm_pull(ab_cols[i]))
} }
} }

View File

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

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9027</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -39,7 +39,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>
@ -494,7 +494,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
<a href="#antibiotic-agents" class="anchor"></a>Antibiotic agents</h2> <a href="#antibiotic-agents" class="anchor"></a>Antibiotic agents</h2>
<p>A data set with 455 rows and 14 columns, containing the following column names:<br><em>ab, atc, cid, name, group, atc_group1, atc_group2, abbreviations, synonyms, oral_ddd, oral_units, iv_ddd, iv_units, loinc</em>.</p> <p>A data set with 455 rows and 14 columns, containing the following column names:<br><em>ab, atc, cid, name, group, atc_group1, atc_group2, abbreviations, synonyms, oral_ddd, oral_units, iv_ddd, iv_units, loinc</em>.</p>
<p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p> <p>This data set is in R available as <code>antibiotics</code>, after you load the <code>AMR</code> package.</p>
<p>It was last updated on 20 September 2020 11:45:13 CEST. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p> <p>It was last updated on 24 September 2020 00:50:35 CEST. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/antibiotics.html">here</a>.</p>
<p><strong>Direct download links:</strong></p> <p><strong>Direct download links:</strong></p>
<ul> <ul>
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (31 kB)<br> <li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/antibiotics.rds">R file</a> (31 kB)<br>
@ -789,7 +789,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
<a href="#intrinsic-bacterial-resistance" class="anchor"></a>Intrinsic bacterial resistance</h2> <a href="#intrinsic-bacterial-resistance" class="anchor"></a>Intrinsic bacterial resistance</h2>
<p>A data set with 93,892 rows and 2 columns, containing the following column names:<br><em>microorganism, antibiotic</em>.</p> <p>A data set with 93,892 rows and 2 columns, containing the following column names:<br><em>microorganism, antibiotic</em>.</p>
<p>This data set is in R available as <code>intrinsic_resistant</code>, after you load the <code>AMR</code> package.</p> <p>This data set is in R available as <code>intrinsic_resistant</code>, after you load the <code>AMR</code> package.</p>
<p>It was last updated on 23 September 2020 23:42:04 CEST. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</p> <p>It was last updated on 24 September 2020 00:50:35 CEST. Find more info about the structure of this data set <a href="https://msberends.github.io/AMR/reference/intrinsic_resistant.html">here</a>.</p>
<p><strong>Direct download links:</strong></p> <p><strong>Direct download links:</strong></p>
<ul> <ul>
<li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/intrinsic_resistant.rds">R file</a> (67 kB)<br> <li>Download as <a href="https://github.com/msberends/AMR/raw/master/data-raw/../data-raw/intrinsic_resistant.rds">R file</a> (67 kB)<br>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9027</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9027</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -43,7 +43,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9027</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9027</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>
@ -236,9 +236,9 @@
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small> <small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div> </div>
<div id="amr-1309027" class="section level1"> <div id="amr-1309028" class="section level1">
<h1 class="page-header" data-toc-text="1.3.0.9027"> <h1 class="page-header" data-toc-text="1.3.0.9028">
<a href="#amr-1309027" class="anchor"></a>AMR 1.3.0.9027<small> Unreleased </small> <a href="#amr-1309028" class="anchor"></a>AMR 1.3.0.9028<small> Unreleased </small>
</h1> </h1>
<div id="last-updated-24-september-2020" class="section level2"> <div id="last-updated-24-september-2020" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
@ -286,6 +286,7 @@
<span class="kw">your_data</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="fu"><a href="https://dplyr.tidyverse.org/reference/across.html">across</a></span>(<span class="fu">where</span>(<span class="kw">is.disk</span>), <span class="kw">as.rsi</span>)) <span class="kw">your_data</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="fu"><a href="https://dplyr.tidyverse.org/reference/across.html">across</a></span>(<span class="fu">where</span>(<span class="kw">is.disk</span>), <span class="kw">as.rsi</span>))
</pre></div> </pre></div>
</li> </li>
<li><p>Cleaning columns in a data.frame now allows you to specify those columns with tidy selection, e.g. <code><a href="../reference/as.rsi.html">as.rsi(df, col1:col9)</a></code></p></li>
<li><p>Big speed improvement for interpreting MIC values and disk zone diameters. When interpreting 5,000 MIC values of two antibiotics (10,000 values in total), our benchmarks showed a total run time going from 80.7-85.1 seconds to 1.8-2.0 seconds.</p></li> <li><p>Big speed improvement for interpreting MIC values and disk zone diameters. When interpreting 5,000 MIC values of two antibiotics (10,000 values in total), our benchmarks showed a total run time going from 80.7-85.1 seconds to 1.8-2.0 seconds.</p></li>
<li><p>Added parameter add_intrinsic_resistance (defaults to <code>FALSE</code>), that considers intrinsic resistance according to EUCAST</p></li> <li><p>Added parameter add_intrinsic_resistance (defaults to <code>FALSE</code>), that considers intrinsic resistance according to EUCAST</p></li>
<li><p>Fixed a bug where in EUCAST rules the breakpoint for R would be interpreted as “&gt;=” while this should have been “&lt;</p></li> <li><p>Fixed a bug where in EUCAST rules the breakpoint for R would be interpreted as “&gt;=” while this should have been “&lt;</p></li>
@ -436,7 +437,7 @@
<p>Making this package independent of especially the tidyverse (e.g. packages <code>dplyr</code> and <code>tidyr</code>) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Good for users, but hard for package maintainers. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.</p> <p>Making this package independent of especially the tidyverse (e.g. packages <code>dplyr</code> and <code>tidyr</code>) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Good for users, but hard for package maintainers. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.</p>
<p>Negative effects of this change are:</p> <p>Negative effects of this change are:</p>
<ul> <ul>
<li>Function <code>freq()</code> that was borrowed from the <code>cleaner</code> package was removed. Use <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">cleaner::freq()</a></code>, or run <code><a href="https://github.com/msberends/cleaner">library("cleaner")</a></code> before you use <code>freq()</code>.</li> <li>Function <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code> that was borrowed from the <code>cleaner</code> package was removed. Use <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">cleaner::freq()</a></code>, or run <code><a href="https://github.com/msberends/cleaner">library("cleaner")</a></code> before you use <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code>.</li>
<li><del>Printing values of class <code>mo</code> or <code>rsi</code> in a tibble will no longer be in colour and printing <code>rsi</code> in a tibble will show the class <code>&lt;ord&gt;</code>, not <code>&lt;rsi&gt;</code> anymore. This is purely a visual effect.</del></li> <li><del>Printing values of class <code>mo</code> or <code>rsi</code> in a tibble will no longer be in colour and printing <code>rsi</code> in a tibble will show the class <code>&lt;ord&gt;</code>, not <code>&lt;rsi&gt;</code> anymore. This is purely a visual effect.</del></li>
<li><del>All functions from the <code>mo_*</code> family (like <code><a href="../reference/mo_property.html">mo_name()</a></code> and <code><a href="../reference/mo_property.html">mo_gramstain()</a></code>) are noticeably slower when running on hundreds of thousands of rows.</del></li> <li><del>All functions from the <code>mo_*</code> family (like <code><a href="../reference/mo_property.html">mo_name()</a></code> and <code><a href="../reference/mo_property.html">mo_gramstain()</a></code>) are noticeably slower when running on hundreds of thousands of rows.</del></li>
<li>For developers: classes <code>mo</code> and <code>ab</code> now both also inherit class <code>character</code>, to support any data transformation. This change invalidates code that checks for class length == 1.</li> <li>For developers: classes <code>mo</code> and <code>ab</code> now both also inherit class <code>character</code>, to support any data transformation. This change invalidates code that checks for class length == 1.</li>
@ -773,7 +774,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</pre></div> </pre></div>
<p>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.</p> <p>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.</p>
</li> </li>
<li><p>Function <code>freq()</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>freq()</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).</p></li> <li><p>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).</p></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>
@ -1042,7 +1043,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<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><a href="../reference/as.rsi.html">rsi()</a></code> <li>Removed deprecated functions <code>guess_mo()</code>, <code>guess_atc()</code>, <code>EUCAST_rules()</code>, <code>interpretive_reading()</code>, <code><a href="../reference/as.rsi.html">rsi()</a></code>
</li> </li>
<li>Frequency tables (<code>freq()</code>): <li>Frequency tables (<code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code>):
<ul> <ul>
<li><p>speed improvement for microbial IDs</p></li> <li><p>speed improvement for microbial IDs</p></li>
<li><p>fixed factor level names for R Markdown</p></li> <li><p>fixed factor level names for R Markdown</p></li>
@ -1051,12 +1052,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<p>support for boxplots:</p> <p>support for boxplots:</p>
<div class="sourceCode" id="cb20"><pre class="downlit"> <div class="sourceCode" id="cb20"><pre class="downlit">
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="kw">septic_patients</span> <span class="op">%&gt;%</span>
<span class="fu">freq</span>(<span class="kw">age</span>) <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw">age</span>) <span class="op">%&gt;%</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/boxplot.html">boxplot</a></span>() <span class="fu"><a href="https://rdrr.io/r/graphics/boxplot.html">boxplot</a></span>()
<span class="co"># grouped boxplots:</span> <span class="co"># grouped boxplots:</span>
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="kw">septic_patients</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="kw">hospital_id</span>) <span class="op">%&gt;%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="kw">hospital_id</span>) <span class="op">%&gt;%</span>
<span class="fu">freq</span>(<span class="kw">age</span>) <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw">age</span>) <span class="op">%&gt;%</span>
<span class="fu"><a href="https://rdrr.io/r/graphics/boxplot.html">boxplot</a></span>() <span class="fu"><a href="https://rdrr.io/r/graphics/boxplot.html">boxplot</a></span>()
</pre></div> </pre></div>
</li> </li>
@ -1067,7 +1068,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<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>freq()</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>
@ -1308,7 +1309,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
</li> </li>
</ul> </ul>
</li> </li>
<li>Frequency tables (<code>freq()</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>
@ -1317,15 +1318,15 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<span class="co"># OLD WAY</span> <span class="co"># OLD WAY</span>
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="kw">septic_patients</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(genus = <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="kw">mo</span>)) <span class="op">%&gt;%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(genus = <span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="kw">mo</span>)) <span class="op">%&gt;%</span>
<span class="fu">freq</span>(<span class="kw">genus</span>) <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw">genus</span>)
<span class="co"># NEW WAY</span> <span class="co"># NEW WAY</span>
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="kw">septic_patients</span> <span class="op">%&gt;%</span>
<span class="fu">freq</span>(<span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="kw">mo</span>)) <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="kw">mo</span>))
<span class="co"># Even supports grouping variables:</span> <span class="co"># Even supports grouping variables:</span>
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="kw">septic_patients</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="kw">gender</span>) <span class="op">%&gt;%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="kw">gender</span>) <span class="op">%&gt;%</span>
<span class="fu">freq</span>(<span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="kw">mo</span>)) <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="kw">mo</span>))
</pre></div> </pre></div>
</li> </li>
<li><p>Header info is now available as a list, with the <code>header</code> function</p></li> <li><p>Header info is now available as a list, with the <code>header</code> function</p></li>
@ -1409,21 +1410,21 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>Using <code>portion_*</code> functions now throws a warning when total available isolate is below parameter <code>minimum</code></p></li> <li><p>Using <code>portion_*</code> functions now throws a warning when total available isolate is below parameter <code>minimum</code></p></li>
<li><p>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</p></li> <li><p>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</p></li>
<li> <li>
<p>Frequency tables - <code>freq()</code>:</p> <p>Frequency tables - <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq()</a></code>:</p>
<ul> <ul>
<li> <li>
<p>Support for grouping variables, test with:</p> <p>Support for grouping variables, test with:</p>
<div class="sourceCode" id="cb32"><pre class="downlit"> <div class="sourceCode" id="cb32"><pre class="downlit">
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="kw">septic_patients</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="kw">hospital_id</span>) <span class="op">%&gt;%</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(<span class="kw">hospital_id</span>) <span class="op">%&gt;%</span>
<span class="fu">freq</span>(<span class="kw">gender</span>) <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw">gender</span>)
</pre></div> </pre></div>
</li> </li>
<li> <li>
<p>Support for (un)selecting columns:</p> <p>Support for (un)selecting columns:</p>
<div class="sourceCode" id="cb33"><pre class="downlit"> <div class="sourceCode" id="cb33"><pre class="downlit">
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="kw">septic_patients</span> <span class="op">%&gt;%</span>
<span class="fu">freq</span>(<span class="kw">hospital_id</span>) <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw">hospital_id</span>) <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw">count</span>, <span class="op">-</span><span class="kw">cum_count</span>) <span class="co"># only get item, percent, cum_percent</span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw">count</span>, <span class="op">-</span><span class="kw">cum_count</span>) <span class="co"># only get item, percent, cum_percent</span>
</pre></div> </pre></div>
</li> </li>
@ -1442,7 +1443,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li><p>Removed diacritics from all authors (columns <code>microorganisms$ref</code> and <code>microorganisms.old$ref</code>) to comply with CRAN policy to only allow ASCII characters</p></li> <li><p>Removed diacritics from all authors (columns <code>microorganisms$ref</code> and <code>microorganisms.old$ref</code>) to comply with CRAN policy to only allow ASCII characters</p></li>
<li><p>Fix for <code>mo_property</code> not working properly</p></li> <li><p>Fix for <code>mo_property</code> not working properly</p></li>
<li><p>Fix for <code>eucast_rules</code> where some Streptococci would become ceftazidime R in EUCAST rule 4.5</p></li> <li><p>Fix for <code>eucast_rules</code> where some Streptococci would become ceftazidime R in EUCAST rule 4.5</p></li>
<li><p>Support for named vectors of class <code>mo</code>, useful for <code>top_freq()</code></p></li> <li><p>Support for named vectors of class <code>mo</code>, useful for <code><a href="https://rdrr.io/pkg/cleaner/man/freq.html">top_freq()</a></code></p></li>
<li><p><code>ggplot_rsi</code> and <code>scale_y_percent</code> have <code>breaks</code> parameter</p></li> <li><p><code>ggplot_rsi</code> and <code>scale_y_percent</code> have <code>breaks</code> parameter</p></li>
<li> <li>
<p>AI improvements for <code>as.mo</code>:</p> <p>AI improvements for <code>as.mo</code>:</p>
@ -1609,13 +1610,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<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="cb40"><pre class="downlit"> <div class="sourceCode" id="cb40"><pre class="downlit">
<span class="kw">my_matrix</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/with.html">with</a></span>(<span class="kw">septic_patients</span>, <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="kw">age</span>, <span class="kw">gender</span>), ncol = <span class="fl">2</span>)) <span class="kw">my_matrix</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/with.html">with</a></span>(<span class="kw">septic_patients</span>, <span class="fu"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="kw">age</span>, <span class="kw">gender</span>), ncol = <span class="fl">2</span>))
<span class="fu">freq</span>(<span class="kw">my_matrix</span>) <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw">my_matrix</span>)
</pre></div> </pre></div>
<p>For lists, subsetting is possible:</p> <p>For lists, subsetting is possible:</p>
<div class="sourceCode" id="cb41"><pre class="downlit"> <div class="sourceCode" id="cb41"><pre class="downlit">
<span class="kw">my_list</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span>(age = <span class="kw">septic_patients</span><span class="op">$</span><span class="kw">age</span>, gender = <span class="kw">septic_patients</span><span class="op">$</span><span class="kw">gender</span>) <span class="kw">my_list</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html">list</a></span>(age = <span class="kw">septic_patients</span><span class="op">$</span><span class="kw">age</span>, gender = <span class="kw">septic_patients</span><span class="op">$</span><span class="kw">gender</span>)
<span class="kw">my_list</span> <span class="op">%&gt;%</span> <span class="fu">freq</span>(<span class="kw">age</span>) <span class="kw">my_list</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw">age</span>)
<span class="kw">my_list</span> <span class="op">%&gt;%</span> <span class="fu">freq</span>(<span class="kw">gender</span>) <span class="kw">my_list</span> <span class="op">%&gt;%</span> <span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="kw">gender</span>)
</pre></div> </pre></div>
</li> </li>
</ul> </ul>
@ -1690,13 +1691,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<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>freq(table(x, y))</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>freq(mydata, mycolumn)</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>

View File

@ -2,7 +2,7 @@ pandoc: 2.7.3
pkgdown: 1.5.1.9000 pkgdown: 1.5.1.9000
pkgdown_sha: eae56f08694abebf93cdfc0dd8e9ede06d8c815f pkgdown_sha: eae56f08694abebf93cdfc0dd8e9ede06d8c815f
articles: [] articles: []
last_built: 2020-09-23T22:50Z last_built: 2020-09-24T10:36Z
urls: urls:
reference: https://msberends.github.io/AMR/reference reference: https://msberends.github.io/AMR/reference
article: https://msberends.github.io/AMR/articles article: https://msberends.github.io/AMR/articles

View File

@ -82,7 +82,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -82,7 +82,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -82,7 +82,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>
@ -274,12 +274,12 @@
<span class='co'># S3 method for data.frame</span> <span class='co'># S3 method for data.frame</span>
<span class='fu'>as.rsi</span>( <span class='fu'>as.rsi</span>(
<span class='kw'>x</span>, <span class='kw'>x</span>,
<span class='kw'>...</span>,
col_mo = <span class='kw'>NULL</span>, col_mo = <span class='kw'>NULL</span>,
guideline = <span class='st'>"EUCAST"</span>, guideline = <span class='st'>"EUCAST"</span>,
uti = <span class='kw'>NULL</span>, uti = <span class='kw'>NULL</span>,
conserve_capped_values = <span class='fl'>FALSE</span>, conserve_capped_values = <span class='fl'>FALSE</span>,
add_intrinsic_resistance = <span class='fl'>FALSE</span>, add_intrinsic_resistance = <span class='fl'>FALSE</span>
<span class='kw'>...</span>
)</pre> )</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
@ -291,7 +291,7 @@
</tr> </tr>
<tr> <tr>
<th>...</th> <th>...</th>
<td><p>parameters passed on to methods</p></td> <td><p>for using on a <a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a>: names of columns to apply <code>as.rsi()</code> on (supports tidy selection like <code>AMX:VAN</code>). Otherwise: parameters passed on to methods.</p></td>
</tr> </tr>
<tr> <tr>
<th>threshold</th> <th>threshold</th>
@ -330,7 +330,7 @@ list(version_txt = "v3.2", year = 2020, title = "EUCAST Expert Rules / EUCAST In
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2> <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
<p>Ordered factor with new class <code>rsi</code></p> <p>Ordered <a href='https://rdrr.io/r/base/factor.html'>factor</a> with new class <code>rsi</code></p>
<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>
@ -468,7 +468,6 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='fu'>as.rsi</span>(<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"S"</span>, <span class='st'>"I"</span>, <span class='st'>"R"</span>, <span class='st'>"A"</span>, <span class='st'>"B"</span>, <span class='st'>"C"</span>)) <span class='fu'>as.rsi</span>(<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"S"</span>, <span class='st'>"I"</span>, <span class='st'>"R"</span>, <span class='st'>"A"</span>, <span class='st'>"B"</span>, <span class='st'>"C"</span>))
<span class='fu'>as.rsi</span>(<span class='st'>"&lt;= 0.002; S"</span>) <span class='co'># will return "S"</span> <span class='fu'>as.rsi</span>(<span class='st'>"&lt;= 0.002; S"</span>) <span class='co'># will return "S"</span>
<span class='kw'>rsi_data</span> <span class='op'>&lt;-</span> <span class='fu'>as.rsi</span>(<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fu'><a href='https://rdrr.io/r/base/rep.html'>rep</a></span>(<span class='st'>"S"</span>, <span class='fl'>474</span>), <span class='fu'><a href='https://rdrr.io/r/base/rep.html'>rep</a></span>(<span class='st'>"I"</span>, <span class='fl'>36</span>), <span class='fu'><a href='https://rdrr.io/r/base/rep.html'>rep</a></span>(<span class='st'>"R"</span>, <span class='fl'>370</span>))) <span class='kw'>rsi_data</span> <span class='op'>&lt;-</span> <span class='fu'>as.rsi</span>(<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fu'><a href='https://rdrr.io/r/base/rep.html'>rep</a></span>(<span class='st'>"S"</span>, <span class='fl'>474</span>), <span class='fu'><a href='https://rdrr.io/r/base/rep.html'>rep</a></span>(<span class='st'>"I"</span>, <span class='fl'>36</span>), <span class='fu'><a href='https://rdrr.io/r/base/rep.html'>rep</a></span>(<span class='st'>"R"</span>, <span class='fl'>370</span>)))
<span class='fu'>is.rsi</span>(<span class='kw'>rsi_data</span>) <span class='fu'>is.rsi</span>(<span class='kw'>rsi_data</span>)
<span class='fu'><a href='plot.html'>plot</a></span>(<span class='kw'>rsi_data</span>) <span class='co'># for percentages</span> <span class='fu'><a href='plot.html'>plot</a></span>(<span class='kw'>rsi_data</span>) <span class='co'># for percentages</span>
@ -478,6 +477,9 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>) <span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>PEN</span><span class='op'>:</span><span class='kw'>RIF</span>), <span class='kw'>as.rsi</span>) <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>PEN</span><span class='op'>:</span><span class='kw'>RIF</span>), <span class='kw'>as.rsi</span>)
<span class='co'># same: </span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>as.rsi</span>(<span class='kw'>PEN</span><span class='op'>:</span><span class='kw'>RIF</span>)
<span class='co'># fastest way to transform all columns with already valid AMR results to class `rsi`:</span> <span class='co'># fastest way to transform all columns with already valid AMR results to class `rsi`:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>

View File

@ -82,7 +82,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9027</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -82,7 +82,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -82,7 +82,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -82,7 +82,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -83,7 +83,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9027</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
</span> </span>
</div> </div>

View File

@ -39,18 +39,18 @@ is.rsi.eligible(x, threshold = 0.05)
\method{as.rsi}{data.frame}( \method{as.rsi}{data.frame}(
x, x,
...,
col_mo = NULL, col_mo = NULL,
guideline = "EUCAST", guideline = "EUCAST",
uti = NULL, uti = NULL,
conserve_capped_values = FALSE, conserve_capped_values = FALSE,
add_intrinsic_resistance = FALSE, add_intrinsic_resistance = FALSE
...
) )
} }
\arguments{ \arguments{
\item{x}{vector of values (for class \code{\link{mic}}: an MIC value in mg/L, for class \code{\link{disk}}: a disk diffusion radius in millimetres)} \item{x}{vector of values (for class \code{\link{mic}}: an MIC value in mg/L, for class \code{\link{disk}}: a disk diffusion radius in millimetres)}
\item{...}{parameters passed on to methods} \item{...}{for using on a \link{data.frame}: names of columns to apply \code{\link[=as.rsi]{as.rsi()}} on (supports tidy selection like \code{AMX:VAN}). Otherwise: parameters passed on to methods.}
\item{threshold}{maximum fraction of invalid antimicrobial interpretations of \code{x}, please see \emph{Examples}} \item{threshold}{maximum fraction of invalid antimicrobial interpretations of \code{x}, please see \emph{Examples}}
@ -70,7 +70,7 @@ list(version_txt = "v3.2", year = 2020, title = "EUCAST Expert Rules / EUCAST In
\item{col_mo}{column name of the IDs of the microorganisms (see \code{\link[=as.mo]{as.mo()}}), defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.} \item{col_mo}{column name of the IDs of the microorganisms (see \code{\link[=as.mo]{as.mo()}}), defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.}
} }
\value{ \value{
Ordered factor with new class \code{\link{rsi}} Ordered \link{factor} with new class \code{\link{rsi}}
} }
\description{ \description{
Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class \code{\link{rsi}}, which is an ordered factor with levels \verb{S < I < R}. Values that cannot be interpreted will be returned as \code{NA} with a warning. Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class \code{\link{rsi}}, which is an ordered factor with levels \verb{S < I < R}. Values that cannot be interpreted will be returned as \code{NA} with a warning.
@ -211,7 +211,6 @@ as.rsi(x = as.disk(18),
as.rsi(c("S", "I", "R", "A", "B", "C")) as.rsi(c("S", "I", "R", "A", "B", "C"))
as.rsi("<= 0.002; S") # will return "S" as.rsi("<= 0.002; S") # will return "S"
rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370))) rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
is.rsi(rsi_data) is.rsi(rsi_data)
plot(rsi_data) # for percentages plot(rsi_data) # for percentages
@ -221,6 +220,9 @@ barplot(rsi_data) # for frequencies
library(dplyr) library(dplyr)
example_isolates \%>\% example_isolates \%>\%
mutate_at(vars(PEN:RIF), as.rsi) mutate_at(vars(PEN:RIF), as.rsi)
# same:
example_isolates \%>\%
as.rsi(PEN:RIF)
# fastest way to transform all columns with already valid AMR results to class `rsi`: # fastest way to transform all columns with already valid AMR results to class `rsi`:
example_isolates \%>\% example_isolates \%>\%