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

(v0.7.1.9091) percentage from clean pkg

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-09-30 16:45:36 +02:00
parent b39e7feae6
commit edb599ae0b
30 changed files with 419 additions and 435 deletions

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 0.7.1.9090 Version: 0.7.1.9091
Date: 2019-09-26 Date: 2019-09-30
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(
person(role = c("aut", "cre"), person(role = c("aut", "cre"),
@ -34,7 +34,7 @@ Depends:
R (>= 3.1.0) R (>= 3.1.0)
Imports: Imports:
backports, backports,
clean (>= 1.1.0), clean (>= 1.1.0.9000),
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

@ -233,6 +233,7 @@ exportMethods(summary.mo)
exportMethods(summary.rsi) exportMethods(summary.rsi)
importFrom(clean,freq) importFrom(clean,freq)
importFrom(clean,freq.default) importFrom(clean,freq.default)
importFrom(clean,percentage)
importFrom(clean,top_freq) importFrom(clean,top_freq)
importFrom(crayon,bgGreen) importFrom(crayon,bgGreen)
importFrom(crayon,bgRed) importFrom(crayon,bgRed)
@ -305,7 +306,6 @@ importFrom(pillar,pillar_shaft)
importFrom(pillar,type_sum) importFrom(pillar,type_sum)
importFrom(rlang,as_label) importFrom(rlang,as_label)
importFrom(rlang,enquos) importFrom(rlang,enquos)
importFrom(scales,percent)
importFrom(stats,complete.cases) importFrom(stats,complete.cases)
importFrom(stats,glm) importFrom(stats,glm)
importFrom(stats,lm) importFrom(stats,lm)
@ -314,7 +314,6 @@ importFrom(stats,predict)
importFrom(tidyr,gather) importFrom(tidyr,gather)
importFrom(tidyr,spread) importFrom(tidyr,spread)
importFrom(utils,browseURL) importFrom(utils,browseURL)
importFrom(utils,installed.packages)
importFrom(utils,menu) importFrom(utils,menu)
importFrom(utils,read.csv) importFrom(utils,read.csv)
importFrom(utils,write.csv) importFrom(utils,write.csv)

View File

@ -1,5 +1,5 @@
# AMR 0.7.1.9090 # AMR 0.7.1.9091
<small>Last updated: 26-Sep-2019</small> <small>Last updated: 30-Sep-2019</small>
### Breaking ### Breaking
* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new parameter `include_unknown`: * Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new parameter `include_unknown`:

View File

@ -67,5 +67,4 @@
#' @rdname AMR #' @rdname AMR
# # prevent NOTE on R >= 3.6 # # prevent NOTE on R >= 3.6
#' @importFrom microbenchmark microbenchmark #' @importFrom microbenchmark microbenchmark
#' @importFrom scales percent
NULL NULL

View File

@ -27,6 +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
#' @export #' @export
#' @examples #' @examples
#' availability(example_isolates) #' availability(example_isolates)
@ -47,7 +48,7 @@ availability <- function(tbl, width = NULL) {
n <- base::sapply(tbl, function(x) base::length(x[!base::is.na(x)])) n <- base::sapply(tbl, function(x) base::length(x[!base::is.na(x)]))
R <- base::sapply(tbl, function(x) base::ifelse(is.rsi(x), portion_R(x, minimum = 0), NA)) R <- base::sapply(tbl, function(x) base::ifelse(is.rsi(x), portion_R(x, minimum = 0), NA))
R_print <- character(length(R)) R_print <- character(length(R))
R_print[!is.na(R)] <- percent(R[!is.na(R)], round = 1, force_zero = TRUE) R_print[!is.na(R)] <- percentage(R[!is.na(R)])
R_print[is.na(R)] <- "" R_print[is.na(R)] <- ""
if (is.null(width)) { if (is.null(width)) {
@ -77,7 +78,7 @@ availability <- function(tbl, width = NULL) {
x_chars_empty <- strrep("-", width - nchar(x_chars)) x_chars_empty <- strrep("-", width - nchar(x_chars))
df <- data.frame(count = n, df <- data.frame(count = n,
available = percent(x, round = 1, force_zero = TRUE), available = percentage(x),
visual_availabilty = paste0("|", x_chars, x_chars_empty, "|"), visual_availabilty = paste0("|", x_chars, x_chars_empty, "|"),
resistant = R_print, resistant = R_print,
visual_resistance = vis_resistance) visual_resistance = vis_resistance)

View File

@ -33,7 +33,7 @@
#' @inheritParams base::formatC #' @inheritParams base::formatC
#' @importFrom dplyr %>% rename group_by select mutate filter pull #' @importFrom dplyr %>% rename group_by select mutate filter pull
#' @importFrom tidyr spread #' @importFrom tidyr spread
#' @importFrom clean freq #' @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}.
@ -140,7 +140,7 @@ format.bug_drug_combinations <- function(x,
summarise(isolates = sum(isolates, na.rm = TRUE), summarise(isolates = sum(isolates, na.rm = TRUE),
total = sum(total, na.rm = TRUE)) %>% total = sum(total, na.rm = TRUE)) %>%
ungroup() %>% ungroup() %>%
mutate(txt = paste0(percent(isolates / total, force_zero = TRUE, decimal.mark = decimal.mark, big.mark = big.mark), mutate(txt = paste0(percentage(isolates / total, decimal.mark = decimal.mark, big.mark = big.mark),
" (", trimws(format(isolates, big.mark = big.mark)), "/", " (", trimws(format(isolates, big.mark = big.mark)), "/",
trimws(format(total, big.mark = big.mark)), ")")) %>% trimws(format(total, big.mark = big.mark)), ")")) %>%
select(ab, ab_txt, mo, txt) %>% select(ab, ab_txt, mo, txt) %>%

View File

@ -75,6 +75,7 @@
#' @export #' @export
#' @importFrom dplyr arrange_at lag between row_number filter mutate arrange pull ungroup #' @importFrom dplyr arrange_at lag between row_number filter mutate arrange pull ungroup
#' @importFrom crayon blue bold silver #' @importFrom crayon blue bold silver
#' @importFrom clean percentage
#' @return Logical vector #' @return Logical vector
#' @source Methodology of this function is based on: \strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}. #' @source Methodology of this function is based on: \strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}.
#' @inheritSection AMR Read more on our website! #' @inheritSection AMR Read more on our website!
@ -525,8 +526,8 @@ first_isolate <- function(x,
if (info == TRUE) { if (info == TRUE) {
n_found <- base::sum(all_first, na.rm = TRUE) n_found <- base::sum(all_first, na.rm = TRUE)
p_found_total <- percent(n_found / nrow(x), force_zero = TRUE) p_found_total <- percentage(n_found / nrow(x))
p_found_scope <- percent(n_found / scope.size, force_zero = TRUE) p_found_scope <- percentage(n_found / scope.size)
# mark up number of found # mark up number of found
n_found <- base::format(n_found, big.mark = big.mark, decimal.mark = decimal.mark) n_found <- base::format(n_found, big.mark = big.mark, decimal.mark = decimal.mark)
if (p_found_total != p_found_scope) { if (p_found_total != p_found_scope) {

View File

@ -25,22 +25,26 @@ clean::freq
#' @exportMethod freq.mo #' @exportMethod freq.mo
#' @importFrom dplyr n_distinct #' @importFrom dplyr n_distinct
#' @importFrom clean freq.default #' @importFrom clean freq.default percentage
#' @export #' @export
#' @noRd #' @noRd
freq.mo <- function(x, ...) { freq.mo <- function(x, ...) {
x_noNA <- as.mo(x[!is.na(x)]) # as.mo() to get the newest mo codes x_noNA <- as.mo(x[!is.na(x)]) # as.mo() to get the newest mo codes
grams <- mo_gramstain(x_noNA, language = NULL) grams <- mo_gramstain(x_noNA, language = NULL)
digits <- list(...)$digits
if (is.null(digits)) {
digits <- 2
}
freq.default(x = x, ..., freq.default(x = x, ...,
.add_header = list(`Gram-negative` = paste0(format(sum(grams == "Gram-negative", na.rm = TRUE), .add_header = list(`Gram-negative` = paste0(format(sum(grams == "Gram-negative", na.rm = TRUE),
big.mark = ",", big.mark = ",",
decimal.mark = "."), decimal.mark = "."),
" (", percent(sum(grams == "Gram-negative", na.rm = TRUE) / length(grams), force_zero = TRUE, round = 2), " (", percentage(sum(grams == "Gram-negative", na.rm = TRUE) / length(grams), digits = digits),
")"), ")"),
`Gram-positive` = paste0(format(sum(grams == "Gram-positive", na.rm = TRUE), `Gram-positive` = paste0(format(sum(grams == "Gram-positive", na.rm = TRUE),
big.mark = ",", big.mark = ",",
decimal.mark = "."), decimal.mark = "."),
" (", percent(sum(grams == "Gram-positive", na.rm = TRUE) / length(grams), force_zero = TRUE, round = 2), " (", percentage(sum(grams == "Gram-positive", na.rm = TRUE) / length(grams), digits = digits),
")"), ")"),
`Nr of genera` = n_distinct(mo_genus(x_noNA, language = NULL)), `Nr of genera` = n_distinct(mo_genus(x_noNA, language = NULL)),
`Nr of species` = n_distinct(paste(mo_genus(x_noNA, language = NULL), `Nr of species` = n_distinct(paste(mo_genus(x_noNA, language = NULL),

View File

@ -58,7 +58,6 @@
#' #'
#' \code{ggplot_rsi} is a wrapper around all above functions that uses data as first input. This makes it possible to use this function after a pipe (\code{\%>\%}). See Examples. #' \code{ggplot_rsi} is a wrapper around all above functions that uses data as first input. This makes it possible to use this function after a pipe (\code{\%>\%}). See Examples.
#' @rdname ggplot_rsi #' @rdname ggplot_rsi
#' @importFrom utils installed.packages
#' @export #' @export
#' @inheritSection AMR Read more on our website! #' @inheritSection AMR Read more on our website!
#' @examples #' @examples
@ -338,6 +337,7 @@ facet_rsi <- function(facet = c("interpretation", "antibiotic"), nrow = NULL) {
} }
#' @rdname ggplot_rsi #' @rdname ggplot_rsi
#' @importFrom clean 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")
@ -346,7 +346,7 @@ scale_y_percent <- function(breaks = seq(0, 1, 0.1), limits = NULL) {
breaks <- breaks / 100 breaks <- breaks / 100
} }
ggplot2::scale_y_continuous(breaks = breaks, ggplot2::scale_y_continuous(breaks = breaks,
labels = percent(breaks), labels = percentage(breaks),
limits = limits) limits = limits)
} }
@ -387,6 +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
#' @export #' @export
labels_rsi_count <- function(position = NULL, labels_rsi_count <- function(position = NULL,
x = "antibiotic", x = "antibiotic",
@ -417,7 +418,7 @@ labels_rsi_count <- function(position = NULL,
combine_SI = combine_SI, combine_SI = combine_SI,
combine_IR = combine_IR) %>% combine_IR = combine_IR) %>%
group_by_at(x_name) %>% group_by_at(x_name) %>%
mutate(lbl = paste0(percent(value / sum(value, na.rm = TRUE), force_zero = TRUE), mutate(lbl = paste0(percentage(value / sum(value, na.rm = TRUE)),
"\n(n=", isolates, ")")) "\n(n=", isolates, ")"))
}) })
} }

View File

@ -29,22 +29,6 @@ addin_insert_like <- function() {
rstudioapi::insertText(" %like% ") rstudioapi::insertText(" %like% ")
} }
percent_clean <- clean:::percent
# No export, no Rd
percent <- function(x, round = 1, force_zero = FALSE, decimal.mark = getOption("OutDec"), big.mark = ",", ...) {
if (decimal.mark == big.mark) {
if (decimal.mark == ",") {
big.mark <- "."
} else if (decimal.mark == ".") {
big.mark <- ","
} else {
big.mark <- " "
}
}
percent_clean(x = x, round = round, force_zero = force_zero,
decimal.mark = decimal.mark, big.mark = big.mark, ...)
}
#' @importFrom crayon blue bold red #' @importFrom crayon blue bold red
#' @importFrom dplyr %>% pull #' @importFrom dplyr %>% pull
search_type_in_df <- function(x, type) { search_type_in_df <- function(x, type) {

3
R/mo.R
View File

@ -268,6 +268,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
# 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
@ -1575,7 +1576,7 @@ exec_as.mo <- function(x,
total_failures <- length(x_input[as.character(x_input) %in% as.character(failures) & !x_input %in% c(NA, NULL, NaN)]) total_failures <- length(x_input[as.character(x_input) %in% as.character(failures) & !x_input %in% c(NA, NULL, NaN)])
total_n <- length(x_input[!x_input %in% c(NA, NULL, NaN)]) total_n <- length(x_input[!x_input %in% c(NA, NULL, NaN)])
msg <- paste0(nr2char(n_distinct(failures)), " unique ", plural[1], msg <- paste0(nr2char(n_distinct(failures)), " unique ", plural[1],
" (covering ", percent(total_failures / total_n, round = 1, force_zero = TRUE), " (covering ", percentage(total_failures / total_n),
") could not be coerced and ", plural[3], " considered 'unknown'") ") could not be coerced and ", plural[3], " considered 'unknown'")
if (n_distinct(failures) <= 10) { if (n_distinct(failures) <= 10) {
msg <- paste0(msg, ": ", paste('"', unique(failures), '"', sep = "", collapse = ', ')) msg <- paste0(msg, ": ", paste('"', unique(failures), '"', sep = "", collapse = ', '))

View File

@ -26,7 +26,7 @@
#' \code{portion_R} and \code{portion_IR} can be used to calculate resistance, \code{portion_S} and \code{portion_SI} can be used to calculate susceptibility.\cr #' \code{portion_R} and \code{portion_IR} can be used to calculate resistance, \code{portion_S} and \code{portion_SI} can be used to calculate susceptibility.\cr
#' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples. #' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.
#' @param minimum the minimum allowed number of available (tested) isolates. Any isolate count lower than \code{minimum} will return \code{NA} with a warning. The default number of \code{30} isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source. #' @param minimum the minimum allowed number of available (tested) isolates. Any isolate count lower than \code{minimum} will return \code{NA} with a warning. The default number of \code{30} isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.
#' @param as_percent a logical to indicate whether the output must be returned as a hundred fold with \% sign (a character). A value of \code{0.123456} will then be returned as \code{"12.3\%"}. #' @param as_percent a logical to indicate whether the output must be returned as a hundred fold with \% sign (a character) using\code{\link[clean]{percentage}}. A value of \code{0.123456} will then be returned as \code{"12.3\%"}.
#' @param only_all_tested (for combination therapies, i.e. using more than one variable for \code{...}) a logical to indicate that isolates must be tested for all antibiotics, see section \emph{Combination therapy} below #' @param only_all_tested (for combination therapies, i.e. using more than one variable for \code{...}) a logical to indicate that isolates must be tested for all antibiotics, see section \emph{Combination therapy} below
#' @param data a \code{data.frame} containing columns with class \code{rsi} (see \code{\link{as.rsi}}) #' @param data a \code{data.frame} containing columns with class \code{rsi} (see \code{\link{as.rsi}})
#' @param translate_ab a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations to, using \code{\link{ab_property}} #' @param translate_ab a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations to, using \code{\link{ab_property}}

View File

@ -39,6 +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
rsi_calc <- function(..., rsi_calc <- function(...,
ab_result, ab_result,
minimum = 0, minimum = 0,
@ -162,7 +163,7 @@ rsi_calc <- function(...,
} }
if (as_percent == TRUE) { if (as_percent == TRUE) {
percent(fraction, force_zero = TRUE) percentage(fraction, digits = 1)
} else { } else {
fraction fraction
} }

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.7.1.9090</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</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.7.1.9090</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</span>
</span> </span>
</div> </div>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -41,7 +41,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.7.1.9090</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</span>
</span> </span>
</div> </div>
@ -187,7 +187,7 @@
<h1>How to determine multi-drug resistance (MDR)</h1> <h1>How to determine multi-drug resistance (MDR)</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">26 September 2019</h4> <h4 class="date">30 September 2019</h4>
<div class="hidden name"><code>MDR.Rmd</code></div> <div class="hidden name"><code>MDR.Rmd</code></div>
@ -230,19 +230,19 @@
<p>The data set looks like this now:</p> <p>The data set looks like this now:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="kw"><a href="https://rdrr.io/r/utils/head.html">head</a></span>(my_TB_data)</a> <div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="kw"><a href="https://rdrr.io/r/utils/head.html">head</a></span>(my_TB_data)</a>
<a class="sourceLine" id="cb3-2" data-line-number="2"><span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span></a> <a class="sourceLine" id="cb3-2" data-line-number="2"><span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span></a>
<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="co"># 1 R R R R S R</span></a> <a class="sourceLine" id="cb3-3" data-line-number="3"><span class="co"># 1 R S R R S R</span></a>
<a class="sourceLine" id="cb3-4" data-line-number="4"><span class="co"># 2 R I R R R R</span></a> <a class="sourceLine" id="cb3-4" data-line-number="4"><span class="co"># 2 I R S R R R</span></a>
<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="co"># 3 S S R S R R</span></a> <a class="sourceLine" id="cb3-5" data-line-number="5"><span class="co"># 3 R R R S R R</span></a>
<a class="sourceLine" id="cb3-6" data-line-number="6"><span class="co"># 4 S I S S R I</span></a> <a class="sourceLine" id="cb3-6" data-line-number="6"><span class="co"># 4 R S I I R S</span></a>
<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="co"># 5 I S R R R S</span></a> <a class="sourceLine" id="cb3-7" data-line-number="7"><span class="co"># 5 S S I I R S</span></a>
<a class="sourceLine" id="cb3-8" data-line-number="8"><span class="co"># 6 R S S S R R</span></a> <a class="sourceLine" id="cb3-8" data-line-number="8"><span class="co"># 6 S S S R S S</span></a>
<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="co"># kanamycin</span></a> <a class="sourceLine" id="cb3-9" data-line-number="9"><span class="co"># kanamycin</span></a>
<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="co"># 1 R</span></a> <a class="sourceLine" id="cb3-10" data-line-number="10"><span class="co"># 1 R</span></a>
<a class="sourceLine" id="cb3-11" data-line-number="11"><span class="co"># 2 R</span></a> <a class="sourceLine" id="cb3-11" data-line-number="11"><span class="co"># 2 S</span></a>
<a class="sourceLine" id="cb3-12" data-line-number="12"><span class="co"># 3 R</span></a> <a class="sourceLine" id="cb3-12" data-line-number="12"><span class="co"># 3 S</span></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># 4 S</span></a> <a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># 4 R</span></a>
<a class="sourceLine" id="cb3-14" data-line-number="14"><span class="co"># 5 I</span></a> <a class="sourceLine" id="cb3-14" data-line-number="14"><span class="co"># 5 R</span></a>
<a class="sourceLine" id="cb3-15" data-line-number="15"><span class="co"># 6 I</span></a></code></pre></div> <a class="sourceLine" id="cb3-15" data-line-number="15"><span class="co"># 6 S</span></a></code></pre></div>
<p>We can now add the interpretation of MDR-TB to our data set:</p> <p>We can now add the interpretation of MDR-TB to our data set:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1">my_TB_data<span class="op">$</span>mdr &lt;-<span class="st"> </span><span class="kw"><a href="../reference/mdro.html">mdr_tb</a></span>(my_TB_data)</a> <div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1">my_TB_data<span class="op">$</span>mdr &lt;-<span class="st"> </span><span class="kw"><a href="../reference/mdro.html">mdr_tb</a></span>(my_TB_data)</a>
<a class="sourceLine" id="cb4-2" data-line-number="2"><span class="co"># </span><span class="al">NOTE</span><span class="co">: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.</span></a> <a class="sourceLine" id="cb4-2" data-line-number="2"><span class="co"># </span><span class="al">NOTE</span><span class="co">: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.</span></a>
@ -258,7 +258,7 @@
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1"><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(my_TB_data<span class="op">$</span>mdr)</a></code></pre></div> <div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1"><span class="kw"><a href="https://rdrr.io/pkg/clean/man/freq.html">freq</a></span>(my_TB_data<span class="op">$</span>mdr)</a></code></pre></div>
<p><strong>Frequency table</strong></p> <p><strong>Frequency table</strong></p>
<p>Class: factor &gt; ordered (numeric)<br> <p>Class: factor &gt; ordered (numeric)<br>
Length: 5,000 (of which NA: 0 = 0.00%)<br> Length: 5,000 (of which NA: 0 = 0%)<br>
Levels: 5: Negative &lt; Mono-resistant &lt; Poly-resistant &lt; Multi-drug-resistant &lt;<br> Levels: 5: Negative &lt; Mono-resistant &lt; Poly-resistant &lt; Multi-drug-resistant &lt;<br>
Unique: 5</p> Unique: 5</p>
<table class="table"> <table class="table">
@ -274,42 +274,42 @@ Unique: 5</p>
<tr class="odd"> <tr class="odd">
<td align="left">1</td> <td align="left">1</td>
<td align="left">Mono-resistant</td> <td align="left">Mono-resistant</td>
<td align="right">3255</td> <td align="right">3250</td>
<td align="right">65.1%</td> <td align="right">65.00%</td>
<td align="right">3255</td> <td align="right">3250</td>
<td align="right">65.1%</td> <td align="right">65.00%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">2</td> <td align="left">2</td>
<td align="left">Negative</td> <td align="left">Negative</td>
<td align="right">638</td> <td align="right">634</td>
<td align="right">12.8%</td> <td align="right">12.68%</td>
<td align="right">3893</td> <td align="right">3884</td>
<td align="right">77.9%</td> <td align="right">77.68%</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="left">3</td> <td align="left">3</td>
<td align="left">Multi-drug-resistant</td> <td align="left">Multi-drug-resistant</td>
<td align="right">618</td> <td align="right">623</td>
<td align="right">12.4%</td> <td align="right">12.46%</td>
<td align="right">4511</td> <td align="right">4507</td>
<td align="right">90.2%</td> <td align="right">90.14%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">4</td> <td align="left">4</td>
<td align="left">Poly-resistant</td> <td align="left">Poly-resistant</td>
<td align="right">276</td> <td align="right">282</td>
<td align="right">5.5%</td> <td align="right">5.64%</td>
<td align="right">4787</td> <td align="right">4789</td>
<td align="right">95.7%</td> <td align="right">95.78%</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="left">5</td> <td align="left">5</td>
<td align="left">Extensive drug-resistant</td> <td align="left">Extensive drug-resistant</td>
<td align="right">213</td> <td align="right">211</td>
<td align="right">4.3%</td> <td align="right">4.22%</td>
<td align="right">5000</td> <td align="right">5000</td>
<td align="right">100.0%</td> <td align="right">100.00%</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

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.7.1.9090</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</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.7.1.9090</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</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">0.7.1.9090</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</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.7.1.9090</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</span>
</span> </span>
</div> </div>
@ -231,11 +231,11 @@
</div> </div>
<div id="amr-0-7-1-9090" class="section level1"> <div id="amr-0-7-1-9091" class="section level1">
<h1 class="page-header"> <h1 class="page-header">
<a href="#amr-0-7-1-9090" class="anchor"></a>AMR 0.7.1.9090<small> Unreleased </small> <a href="#amr-0-7-1-9091" class="anchor"></a>AMR 0.7.1.9091<small> Unreleased </small>
</h1> </h1>
<p><small>Last updated: 26-Sep-2019</small></p> <p><small>Last updated: 30-Sep-2019</small></p>
<div id="breaking" class="section level3"> <div id="breaking" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">
<a href="#breaking" class="anchor"></a>Breaking</h3> <a href="#breaking" class="anchor"></a>Breaking</h3>
@ -1288,7 +1288,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-7-1-9090">0.7.1.9090</a></li> <li><a href="#amr-0-7-1-9091">0.7.1.9091</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>
<li><a href="#amr-0-6-1">0.6.1</a></li> <li><a href="#amr-0-6-1">0.6.1</a></li>

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.7.1.9090</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</span>
</span> </span>
</div> </div>

View File

@ -15,21 +15,25 @@
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" /> <link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" /> <link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" /> <link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" />
<!-- jquery --> <!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Bootstrap --> <!-- Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" /> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<!-- Font Awesome icons --> <!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous" />
<!-- clipboard.js --> <!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
<!-- sticky kit --> <!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>
<!-- pkgdown --> <!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet"> <link href="../pkgdown.css" rel="stylesheet">
@ -45,16 +49,16 @@
<link href="../extra.css" rel="stylesheet"> <link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script> <script src="../extra.js"></script>
<meta property="og:title" content="Calculate resistance of isolates — portion" />
<meta property="og:title" content="Calculate resistance of isolates — portion" />
<meta property="og:description" content="These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in dplyrs summarise and support grouped variables, see Examples. <meta property="og:description" content="These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in dplyrs summarise and support grouped variables, see Examples.
portion_R and portion_IR can be used to calculate resistance, portion_S and portion_SI can be used to calculate susceptibility." /> portion_R and portion_IR can be used to calculate resistance, portion_S and portion_SI can be used to calculate susceptibility." />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" /> <meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
<!-- mathjax --> <!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
@ -65,6 +69,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<![endif]--> <![endif]-->
</head> </head>
<body> <body>
@ -81,7 +86,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</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.7.1.9067</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9091</span>
</span> </span>
</div> </div>
@ -190,7 +195,6 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</a> </a>
</li> </li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li> <li>
<a href="https://gitlab.com/msberends/AMR"> <a href="https://gitlab.com/msberends/AMR">
@ -208,7 +212,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</li> </li>
</ul> </ul>
<form class="navbar-form navbar-right" role="search"> <form class="navbar-form navbar-right hidden-xs hidden-sm" role="search">
<div class="form-group"> <div class="form-group">
<input type="search" class="form-control" name="search-input" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off"> <input type="search" class="form-control" name="search-input" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off">
</div> </div>
@ -219,6 +223,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</div><!--/.navbar --> </div><!--/.navbar -->
</header> </header>
<div class="row"> <div class="row">
@ -230,10 +235,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</div> </div>
<div class="ref-description"> <div class="ref-description">
<p>These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in <code>dplyr</code>s <code><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></code> and support grouped variables, see <em>Examples</em>.</p> <p>These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in <code>dplyr</code>s <code><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></code> and support grouped variables, see <em>Examples</em>.</p>
<p><code>portion_R</code> and <code>portion_IR</code> can be used to calculate resistance, <code>portion_S</code> and <code>portion_SI</code> can be used to calculate susceptibility.<br /></p> <p><code>portion_R</code> and <code>portion_IR</code> can be used to calculate resistance, <code>portion_S</code> and <code>portion_SI</code> can be used to calculate susceptibility.<br /></p>
</div> </div>
<pre class="usage"><span class='fu'>portion_R</span>(<span class='no'>...</span>, <span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>30</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <pre class="usage"><span class='fu'>portion_R</span>(<span class='no'>...</span>, <span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>30</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
@ -258,7 +261,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<span class='fu'>rsi_df</span>(<span class='no'>data</span>, <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='st'>"name"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='translate.html'>get_locale</a></span>(), <span class='fu'>rsi_df</span>(<span class='no'>data</span>, <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='st'>"name"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='translate.html'>get_locale</a></span>(),
<span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>30</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>combine_SI</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>30</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>combine_SI</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>combine_IR</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre> <span class='kw'>combine_IR</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</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>
<table class="ref-arguments"> <table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup> <colgroup><col class="name" /><col class="desc" /></colgroup>
@ -272,7 +275,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</tr> </tr>
<tr> <tr>
<th>as_percent</th> <th>as_percent</th>
<td><p>a logical to indicate whether the output must be returned as a hundred fold with % sign (a character). A value of <code>0.123456</code> will then be returned as <code>"12.3%"</code>.</p></td> <td><p>a logical to indicate whether the output must be returned as a hundred fold with % sign (a character) using<code><a href='https://rdrr.io/pkg/clean/man/percentage.html'>percentage</a></code>. A value of <code>0.123456</code> will then be returned as <code>"12.3%"</code>.</p></td>
</tr> </tr>
<tr> <tr>
<th>only_all_tested</th> <th>only_all_tested</th>
@ -288,7 +291,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</tr> </tr>
<tr> <tr>
<th>language</th> <th>language</th>
<td><p>language of the returned text, defaults to system language (see <code><a href='translate.html'>get_locale</a></code>) and can also be set with <code><a href='https://www.rdocumentation.org/packages/base/topics/options'>getOption</a>("AMR_locale")</code>. Use <code>language = NULL</code> or <code>language = ""</code> to prevent translation.</p></td> <td><p>language of the returned text, defaults to system language (see <code><a href='translate.html'>get_locale</a></code>) and can also be set with <code><a href='https://rdrr.io/r/base/options.html'>getOption</a>("AMR_locale")</code>. Use <code>language = NULL</code> or <code>language = ""</code> to prevent translation.</p></td>
</tr> </tr>
<tr> <tr>
<th>combine_SI</th> <th>combine_SI</th>
@ -299,27 +302,25 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<td><p>a logical to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. I+R (susceptible vs. non-susceptible). This is outdated, see parameter <code>combine_SI</code>.</p></td> <td><p>a logical to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. I+R (susceptible vs. non-susceptible). This is outdated, see parameter <code>combine_SI</code>.</p></td>
</tr> </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>
<p><strong>M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition</strong>, 2014, <em>Clinical and Laboratory Standards Institute (CLSI)</em>. <a href='https://clsi.org/standards/products/microbiology/documents/m39/'>https://clsi.org/standards/products/microbiology/documents/m39/</a>.</p> <p><strong>M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition</strong>, 2014, <em>Clinical and Laboratory Standards Institute (CLSI)</em>. <a href='https://clsi.org/standards/products/microbiology/documents/m39/'>https://clsi.org/standards/products/microbiology/documents/m39/</a>.</p>
<p>Wickham H. <strong>Tidy Data.</strong> The Journal of Statistical Software, vol. 59, 2014. <a href='http://vita.had.co.nz/papers/tidy-data.html'>http://vita.had.co.nz/papers/tidy-data.html</a></p> <p>Wickham H. <strong>Tidy Data.</strong> The Journal of Statistical Software, vol. 59, 2014. <a href='http://vita.had.co.nz/papers/tidy-data.html'>http://vita.had.co.nz/papers/tidy-data.html</a></p>
<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>Double or, when <code>as_percent = TRUE</code>, a character.</p> <p>Double or, when <code>as_percent = TRUE</code>, a character.</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>
<p><strong>Remember that you should filter your table to let it contain only first isolates!</strong> This is needed to exclude duplicates and to reduce selection bias. Use <code><a href='first_isolate.html'>first_isolate</a></code> to determine them in your data set.</p> <p><strong>Remember that you should filter your table to let it contain only first isolates!</strong> This is needed to exclude duplicates and to reduce selection bias. Use <code><a href='first_isolate.html'>first_isolate</a></code> to determine them in your data set.</p>
<p>These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the <code><a href='count.html'>count</a></code> functions to count isolates. The function <code>portion_SI()</code> is essentially equal to <code>count_SI() / count_all()</code>. <em>Low counts can infuence the outcome - the <code>portion</code> functions may camouflage this, since they only return the portion (albeit being dependent on the <code>minimum</code> parameter).</em></p> <p>These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the <code><a href='count.html'>count</a></code> functions to count isolates. The function <code>portion_SI()</code> is essentially equal to <code>count_SI() / count_all()</code>. <em>Low counts can infuence the outcome - the <code>portion</code> functions may camouflage this, since they only return the portion (albeit being dependent on the <code>minimum</code> parameter).</em></p>
<p>The function <code>portion_df</code> takes any variable from <code>data</code> that has an <code>"rsi"</code> class (created with <code><a href='as.rsi.html'>as.rsi</a></code>) and calculates the portions R, I and S. The resulting <em>tidy data</em> (see Source) <code>data.frame</code> will have three rows (S/I/R) and a column for each group and each variable with class <code>"rsi"</code>.</p> <p>The function <code>portion_df</code> takes any variable from <code>data</code> that has an <code>"rsi"</code> class (created with <code><a href='as.rsi.html'>as.rsi</a></code>) and calculates the portions R, I and S. The resulting <em>tidy data</em> (see Source) <code>data.frame</code> will have three rows (S/I/R) and a column for each group and each variable with class <code>"rsi"</code>.</p>
<p>The function <code>rsi_df</code> works exactly like <code>portion_df</code>, but adds the number of isolates.</p> <p>The function <code>rsi_df</code> works exactly like <code>portion_df</code>, but adds the number of isolates.</p>
<h2 class="hasAnchor" id="combination-therapy"><a class="anchor" href="#combination-therapy"></a>Combination therapy</h2> <h2 class="hasAnchor" id="combination-therapy"><a class="anchor" href="#combination-therapy"></a>Combination therapy</h2>
<p>When using more than one variable for <code>...</code> (= combination therapy)), use <code>only_all_tested</code> to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how <code>portion_SI</code> works to calculate the %SI:</p>
<p>When using more than one variable for <code>...</code> (= combination therapy)), use <code>only_all_tested</code> to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how <code>portion_SI</code> works to calculate the %SI:</p>
<pre> <pre>
-------------------------------------------------------------------- --------------------------------------------------------------------
only_all_tested = FALSE only_all_tested = TRUE only_all_tested = FALSE only_all_tested = TRUE
@ -338,40 +339,40 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
&lt;NA&gt; &lt;NA&gt; - - - - &lt;NA&gt; &lt;NA&gt; - - - -
-------------------------------------------------------------------- --------------------------------------------------------------------
</pre> </pre>
<p>Please note that, in combination therapies, for <code>only_all_tested = TRUE</code> applies that:</p><pre>
<p>Please note that, in combination therapies, for <code>only_all_tested = TRUE</code> applies that:</p><pre>
count_S() + count_I() + count_R() == count_all() count_S() + count_I() + count_R() == count_all()
portion_S() + portion_I() + portion_R() == 1 portion_S() + portion_I() + portion_R() == 1
</pre><p>and that, in combination therapies, for <code>only_all_tested = FALSE</code> applies that:</p><pre> </pre><p>and that, in combination therapies, for <code>only_all_tested = FALSE</code> applies that:</p><pre>
count_S() + count_I() + count_R() &gt;= count_all() count_S() + count_I() + count_R() &gt;= count_all()
portion_S() + portion_I() + portion_R() &gt;= 1 portion_S() + portion_I() + portion_R() &gt;= 1
</pre> </pre>
<p>Using <code>only_all_tested</code> has no impact when only using one antibiotic as input.</p>
<p>Using <code>only_all_tested</code> has no impact when only using one antibiotic as input.</p>
<h2 class="hasAnchor" id="interpretation-of-s-i-and-r"><a class="anchor" href="#interpretation-of-s-i-and-r"></a>Interpretation of S, I and R</h2> <h2 class="hasAnchor" id="interpretation-of-s-i-and-r"><a class="anchor" href="#interpretation-of-s-i-and-r"></a>Interpretation of S, I and R</h2>
<p>In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<p>In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".</p>
<ul> <ul>
<li><p><strong>S</strong> - Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li> <li><p><strong>S</strong> - Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.</p></li>
<li><p><strong>I</strong> - Susceptible, increased exposure: 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.</p></li> <li><p><strong>I</strong> - Susceptible, increased exposure: 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.</p></li>
<li><p><strong>R</strong> - Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.</p></li> <li><p><strong>R</strong> - Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.</p></li>
</ul> </ul>
<p>Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.</p>
<p>Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.</p>
<p>This AMR package honours this new insight. Use <code>portion_SI</code> to determine antimicrobial susceptibility and <code><a href='count.html'>count_SI</a></code> to count susceptible isolates.</p> <p>This AMR package honours this new insight. Use <code>portion_SI</code> to determine antimicrobial susceptibility and <code><a href='count.html'>count_SI</a></code> to count susceptible isolates.</p>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2> <h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2> <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p><code><a href='count.html'>count</a>_*</code> to count resistant and susceptible isolates.</p></div> <div class='dont-index'><p><code><a href='count.html'>count</a>_*</code> to count resistant and susceptible isolates.</p></div>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span> <pre class="examples"><span class='co'># example_isolates is a data set available in the AMR package.</span>
<span class='co'># example_isolates is a data set available in the AMR package.</span>
?<span class='no'>example_isolates</span> ?<span class='no'>example_isolates</span>
<span class='co'># Calculate resistance</span> <span class='co'># Calculate resistance</span>
@ -383,7 +384,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<span class='fu'>portion_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) <span class='fu'>portion_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='co'># Do the above with pipes:</span> <span class='co'># Do the above with pipes:</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>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='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_R</span>(<span class='no'>AMX</span>) <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_R</span>(<span class='no'>AMX</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_IR</span>(<span class='no'>AMX</span>) <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_IR</span>(<span class='no'>AMX</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>AMX</span>) <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>AMX</span>)
@ -451,48 +452,43 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<span class='fu'>portion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>) <span class='fu'>portion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='co'># }</span><span class='co'># NOT RUN {</span> <span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># calculate current empiric combination therapy of Helicobacter gastritis:</span> <span class='co'># calculate current empiric combination therapy of Helicobacter gastritis:</span>
<span class='no'>my_table</span> <span class='kw'>%&gt;%</span> <span class='no'>my_table</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>, <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>,
<span class='no'>genus</span> <span class='kw'>==</span> <span class='st'>"Helicobacter"</span>) <span class='kw'>%&gt;%</span> <span class='no'>genus</span> <span class='kw'>==</span> <span class='st'>"Helicobacter"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>AMX</span>, <span class='no'>MTR</span>), <span class='co'># amoxicillin with metronidazole</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'>portion_S</span>(<span class='no'>AMX</span>, <span class='no'>MTR</span>), <span class='co'># amoxicillin with metronidazole</span>
<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMX</span>, <span class='no'>MTR</span>)) <span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMX</span>, <span class='no'>MTR</span>))
<span class='co'># }</span></pre> }</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>
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li><a href="#arguments">Arguments</a></li> <li><a href="#arguments">Arguments</a></li>
<li><a href="#source">Source</a></li> <li><a href="#source">Source</a></li>
<li><a href="#value">Value</a></li> <li><a href="#value">Value</a></li>
<li><a href="#details">Details</a></li> <li><a href="#details">Details</a></li>
<li><a href="#combination-therapy">Combination therapy</a></li> <li><a href="#combination-therapy">Combination therapy</a></li>
<li><a href="#interpretation-of-s-i-and-r">Interpretation of S, I and R</a></li> <li><a href="#interpretation-of-s-i-and-r">Interpretation of S, I and R</a></li>
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li> <li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
<li><a href="#see-also">See also</a></li> <li><a href="#see-also">See also</a></li>
<li><a href="#examples">Examples</a></li> <li><a href="#examples">Examples</a></li>
</ul> </ul>
</div> </div>
</div> </div>
<footer> <footer>
<div class="copyright"> <div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p> <p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div> </div>
<div class="pkgdown"> <div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p> <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.</p>
</div> </div>
</footer> </footer>
</div> </div>
@ -515,6 +511,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</script> </script>
</body> </body>
</html> </html>

View File

@ -44,7 +44,7 @@ rsi_df(data, translate_ab = "name", language = get_locale(),
\item{minimum}{the minimum allowed number of available (tested) isolates. Any isolate count lower than \code{minimum} will return \code{NA} with a warning. The default number of \code{30} isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.} \item{minimum}{the minimum allowed number of available (tested) isolates. Any isolate count lower than \code{minimum} will return \code{NA} with a warning. The default number of \code{30} isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.}
\item{as_percent}{a logical to indicate whether the output must be returned as a hundred fold with \% sign (a character). A value of \code{0.123456} will then be returned as \code{"12.3\%"}.} \item{as_percent}{a logical to indicate whether the output must be returned as a hundred fold with \% sign (a character) using\code{\link[clean]{percentage}}. A value of \code{0.123456} will then be returned as \code{"12.3\%"}.}
\item{only_all_tested}{(for combination therapies, i.e. using more than one variable for \code{...}) a logical to indicate that isolates must be tested for all antibiotics, see section \emph{Combination therapy} below} \item{only_all_tested}{(for combination therapies, i.e. using more than one variable for \code{...}) a logical to indicate that isolates must be tested for all antibiotics, see section \emph{Combination therapy} below}

View File

@ -21,16 +21,6 @@
context("misc.R") context("misc.R")
test_that("percentages works", {
expect_equal(percent(0.25), "25%")
expect_equal(percent(0.5), "50%")
expect_equal(percent(0.500, force_zero = TRUE), "50.0%")
expect_equal(percent(0.1234), "12.3%")
# round up 0.5
expect_equal(percent(0.0054), "0.5%")
expect_equal(percent(0.0055), "0.6%")
})
test_that("functions missing in older R versions work", { test_that("functions missing in older R versions work", {
expect_equal(strrep("A", 5), "AAAAA") expect_equal(strrep("A", 5), "AAAAA")
expect_equal(strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB")) expect_equal(strrep(c("A", "B"), c(5, 2)), c("AAAAA", "BB"))

View File

@ -210,7 +210,7 @@ data <- data %>%
mutate(first = first_isolate(.)) mutate(first = first_isolate(.))
``` ```
So only `r AMR:::percent(sum(data$first) / nrow(data))` is suitable for resistance analysis! We can now filter on it with the `filter()` function, also from the `dplyr` package: So only `r clean:::percentage(sum(data$first) / nrow(data))` is suitable for resistance analysis! We can now filter on it with the `filter()` function, also from the `dplyr` package:
```{r 1st isolate filter} ```{r 1st isolate filter}
data_1st <- data %>% data_1st <- data %>%
@ -272,7 +272,7 @@ weighted_df2 %>%
knitr::kable(align = "c") knitr::kable(align = "c")
``` ```
Instead of `r sum(weighted_df$first)`, now `r sum(weighted_df2$first_weighted)` isolates are flagged. In total, `r AMR:::percent(sum(data$first_weighted) / nrow(data))` of all isolates are marked 'first weighted' - `r AMR:::percent((sum(data$first_weighted) / nrow(data)) - (sum(data$first) / nrow(data)))` more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline. Instead of `r sum(weighted_df$first)`, now `r sum(weighted_df2$first_weighted)` isolates are flagged. In total, `r clean:::percentage(sum(data$first_weighted) / nrow(data))` of all isolates are marked 'first weighted' - `r clean:::percentage((sum(data$first_weighted) / nrow(data)) - (sum(data$first) / nrow(data)))` more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.
As with `filter_first_isolate()`, there's a shortcut for this new algorithm too: As with `filter_first_isolate()`, there's a shortcut for this new algorithm too:
```{r 1st isolate filter 3, results = 'hide', message = FALSE, warning = FALSE} ```{r 1st isolate filter 3, results = 'hide', message = FALSE, warning = FALSE}