(v1.3.0.9033) skimr fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-09-28 11:00:59 +02:00
parent 519aada54f
commit 36ec8b0d81
27 changed files with 71 additions and 70 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 1.3.0.9032 Version: 1.3.0.9033
Date: 2020-09-28 Date: 2020-09-28
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(

View File

@ -1,4 +1,4 @@
# AMR 1.3.0.9032 # AMR 1.3.0.9033
## <small>Last updated: 28 September 2020</small> ## <small>Last updated: 28 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!

View File

@ -193,10 +193,10 @@ get_skimmers.disk <- function(column) {
inline_hist <- import_fn("inline_hist", "skimr", error_on_fail = FALSE) inline_hist <- import_fn("inline_hist", "skimr", error_on_fail = FALSE)
sfl( sfl(
skim_type = "disk", skim_type = "disk",
smallest = ~min(as.double(.), na.rm = TRUE), min = ~min(as.double(.), na.rm = TRUE),
largest = ~max(as.double(.), na.rm = TRUE), max = ~max(as.double(.), na.rm = TRUE),
median = ~stats::median(as.double(.), na.rm = TRUE), median = ~stats::median(as.double(.), na.rm = TRUE),
n_unique = n_unique, n_unique = ~pm_n_distinct(., na.rm = TRUE),
hist = ~inline_hist(stats::na.omit(as.double(.))) hist = ~inline_hist(stats::na.omit(as.double(.)))
) )
} }

View File

@ -42,8 +42,8 @@ EUCAST_VERSION_EXPERT_RULES <- list("3.1" = list(version_txt = "v3.1",
#' @param info print progress #' @param info print progress
#' @param rules a character vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`. #' @param rules a character vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expert"`, `"other"`, `"all"`, and defaults to `c("breakpoints", "expert")`. The default value can be set to another value, e.g. using `options(AMR_eucastrules = "all")`.
#' @param verbose a [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the 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. Using Verbose mode takes a lot more time. #' @param verbose a [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the 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. Using Verbose mode takes a lot more time.
#' @param version_breakpoints the version number to use for the EUCAST Clinical Breakpoints guideline #' @param version_breakpoints the version number to use for the EUCAST Clinical Breakpoints guideline. Currently supported: `r paste0(names(EUCAST_VERSION_BREAKPOINTS), collapse = ", ")`.
#' @param version_expertrules the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline #' @param version_expertrules the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Currently supported: `r paste0(names(EUCAST_VERSION_EXPERT_RULES), collapse = ", ")`.
#' @param ... column name of an antibiotic, please see section *Antibiotics* below #' @param ... column name of an antibiotic, please see section *Antibiotics* below
#' @inheritParams first_isolate #' @inheritParams first_isolate
#' @details #' @details
@ -143,8 +143,8 @@ eucast_rules <- function(x,
check_dataset_integrity() check_dataset_integrity()
version_breakpoints <- as.double(version_breakpoints) version_breakpoints <- as.double(gsub("[^0-9.]+", "", version_breakpoints))
version_expertrules <- as.double(version_expertrules) version_expertrules <- as.double(gsub("[^0-9.]+", "", version_expertrules))
stop_ifnot(version_breakpoints %in% as.double(names(EUCAST_VERSION_BREAKPOINTS)), stop_ifnot(version_breakpoints %in% as.double(names(EUCAST_VERSION_BREAKPOINTS)),
"EUCAST version ", version_breakpoints, " for clinical breakpoints not found") "EUCAST version ", version_breakpoints, " for clinical breakpoints not found")
stop_ifnot(version_expertrules %in% as.double(names(EUCAST_VERSION_EXPERT_RULES)), stop_ifnot(version_expertrules %in% as.double(names(EUCAST_VERSION_EXPERT_RULES)),

View File

@ -172,11 +172,11 @@ semi_join_microorganisms <- function(x, by = NULL, ...) {
dplyr_semi <- import_fn("semi_join", "dplyr", error_on_fail = FALSE) dplyr_semi <- import_fn("semi_join", "dplyr", error_on_fail = FALSE)
if (!is.null(dplyr_semi)) { if (!is.null(dplyr_semi)) {
join <- suppressWarnings( join <- suppressWarnings(
dplyr_semi(x = x, y = microorganisms, by = by,...) dplyr_semi(x = x, y = microorganisms, by = by, ...)
) )
} else { } else {
join <- suppressWarnings( join <- suppressWarnings(
pm_semi_join(x = x, y = microorganisms, by = by,...) pm_semi_join(x = x, y = microorganisms, by = by, ...)
) )
} }
class(join) <- x_class class(join) <- x_class
@ -196,11 +196,11 @@ anti_join_microorganisms <- function(x, by = NULL, ...) {
dplyr_anti <- import_fn("anti_join", "dplyr", error_on_fail = FALSE) dplyr_anti <- import_fn("anti_join", "dplyr", error_on_fail = FALSE)
if (!is.null(dplyr_anti)) { if (!is.null(dplyr_anti)) {
join <- suppressWarnings( join <- suppressWarnings(
dplyr_anti(x = x, y = microorganisms, by = by,...) dplyr_anti(x = x, y = microorganisms, by = by, ...)
) )
} else { } else {
join <- suppressWarnings( join <- suppressWarnings(
pm_anti_join(x = x, y = microorganisms, by = by,...) pm_anti_join(x = x, y = microorganisms, by = by, ...)
) )
} }
class(join) <- x_class class(join) <- x_class

View File

@ -306,7 +306,7 @@ get_skimmers.mic <- function(column) {
min = ~as.character(sort(na.omit(.))[1]), min = ~as.character(sort(na.omit(.))[1]),
max = ~as.character(sort(stats::na.omit(.))[length(stats::na.omit(.))]), max = ~as.character(sort(stats::na.omit(.))[length(stats::na.omit(.))]),
median = ~as.character(stats::na.omit(.)[as.double(stats::na.omit(.)) == median(as.double(stats::na.omit(.)))])[1], median = ~as.character(stats::na.omit(.)[as.double(stats::na.omit(.)) == median(as.double(stats::na.omit(.)))])[1],
n_unique = n_unique, n_unique = ~pm_n_distinct(., na.rm = TRUE),
hist_log2 = ~inline_hist(log2(as.double(stats::na.omit(.)))) hist_log2 = ~inline_hist(log2(as.double(stats::na.omit(.))))
) )
} }

26
R/mo.R
View File

@ -1647,7 +1647,7 @@ get_skimmers.mo <- function(column) {
sfl <- import_fn("sfl", "skimr", error_on_fail = FALSE) sfl <- import_fn("sfl", "skimr", error_on_fail = FALSE)
sfl( sfl(
skim_type = "mo", skim_type = "mo",
unique_total = n_unique, unique_total = ~pm_n_distinct(., na.rm = TRUE),
gram_negative = ~sum(mo_gramstain(stats::na.omit(.), language = NULL) == "Gram-negative", na.rm = TRUE), gram_negative = ~sum(mo_gramstain(stats::na.omit(.), language = NULL) == "Gram-negative", na.rm = TRUE),
gram_positive = ~sum(mo_gramstain(stats::na.omit(.), language = NULL) == "Gram-positive", na.rm = TRUE), gram_positive = ~sum(mo_gramstain(stats::na.omit(.), language = NULL) == "Gram-positive", na.rm = TRUE),
top_genus = ~names(sort(-table(mo_genus(stats::na.omit(.), language = NULL))))[1L], top_genus = ~names(sort(-table(mo_genus(stats::na.omit(.), language = NULL))))[1L],
@ -1778,20 +1778,20 @@ print.mo_uncertainties <- function(x, ...) {
if (NROW(x) == 0) { if (NROW(x) == 0) {
return(NULL) return(NULL)
} }
cat(font_blue(strwrap(c("Matching scores are based on human pathogenic prevalence and the resemblance between the input and the full taxonomic name. Furthermore, an indication is given about the certainty of the match - the more transformations are needed for coercion, the less certain the result.")), collapse = "\n")) cat(font_blue(strwrap(c("Matching scores are based on human pathogenic prevalence and the resemblance between the input and the full taxonomic name. Please see ?mo_matching_score.")), collapse = "\n"))
cat("\n") cat("\n")
msg <- "" msg <- ""
for (i in seq_len(nrow(x))) { for (i in seq_len(nrow(x))) {
if (x[i, ]$candidates != "") { if (x[i, ]$candidates != "") {
candidates <- unlist(strsplit(x[i, ]$candidates, ", ", fixed = TRUE)) candidates <- unlist(strsplit(x[i, ]$candidates, ", ", fixed = TRUE))
scores <- mo_matching_score(x = x[i, ]$input, scores <- mo_matching_score(x = x[i, ]$input, n = candidates)
n = candidates)
# sort on descending scores # sort on descending scores
candidates <- candidates[order(1 - scores)] candidates <- candidates[order(1 - scores)]
scores_formatted <- trimws(formatC(round(scores, 3), format = "f", digits = 3))
n_candidates <- length(candidates) n_candidates <- length(candidates)
candidates <- paste0(font_italic(candidates, collapse = NULL), candidates <- paste0(font_italic(candidates, collapse = NULL),
" (", trimws(percentage(scores[order(1 - scores)], digits = 1)), ")") " (", scores_formatted[order(1 - scores)], ")")
candidates <- paste(candidates, collapse = ", ") candidates <- paste(candidates, collapse = ", ")
# align with input after arrow # align with input after arrow
candidates <- paste0("\n", strrep(" ", nchar(x[i, ]$input) + 6), candidates <- paste0("\n", strrep(" ", nchar(x[i, ]$input) + 6),
@ -1799,23 +1799,17 @@ print.mo_uncertainties <- function(x, ...) {
} else { } else {
candidates <- "" candidates <- ""
} }
if (x[i, ]$uncertainty == 1) { score <- trimws(formatC(round(mo_matching_score(x = x[i, ]$input,
uncertainty_interpretation <- font_green("* very certain *") n = x[i, ]$fullname),
} else if (x[i, ]$uncertainty == 1) { 3),
uncertainty_interpretation <- font_yellow("* certain *") format = "f", digits = 3))
} else {
uncertainty_interpretation <- font_red("* not certain *")
}
msg <- paste(msg, msg <- paste(msg,
paste0('"', x[i, ]$input, '" -> ', paste0('"', x[i, ]$input, '" -> ',
paste0(font_bold(font_italic(x[i, ]$fullname)), paste0(font_bold(font_italic(x[i, ]$fullname)),
ifelse(!is.na(x[i, ]$renamed_to), paste(", renamed to", font_italic(x[i, ]$renamed_to)), ""), ifelse(!is.na(x[i, ]$renamed_to), paste(", renamed to", font_italic(x[i, ]$renamed_to)), ""),
" (", x[i, ]$mo, " (", x[i, ]$mo,
", matching score = ", trimws(percentage(mo_matching_score(x = x[i, ]$input, ", matching score = ", score,
n = x[i, ]$fullname),
digits = 1)),
") "), ") "),
uncertainty_interpretation,
candidates), candidates),
sep = "\n") sep = "\n")
} }

View File

@ -25,7 +25,7 @@
#' @param x Any user input value(s) #' @param x Any user input value(s)
#' @param n A full taxonomic name, that exists in [`microorganisms$fullname`][microorganisms] #' @param n A full taxonomic name, that exists in [`microorganisms$fullname`][microorganisms]
#' @section Matching score for microorganisms: #' @section Matching score for microorganisms:
#' With ambiguous user input in [as.mo()] and all the [`mo_*`][mo_property()] functions, the returned results are chosen based on their matching score using [mo_matching_score()]. This matching score \eqn{m}, ranging from 0 to 100%, is calculated as: #' With ambiguous user input in [as.mo()] and all the [`mo_*`][mo_property()] functions, the returned results are chosen based on their matching score using [mo_matching_score()]. This matching score \eqn{m}, is calculated as:
#' #'
#' \deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )} #' \deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )}
#' #'
@ -66,7 +66,7 @@ mo_matching_score <- function(x, n) {
var_F <- nchar(n) var_F <- nchar(n)
# L = modified Levenshtein distance # L = modified Levenshtein distance
var_L <- levenshtein var_L <- levenshtein
# P = Prevalence (1 to 3) # P = prevalence (1 to 3), see ?as.mo
var_P <- MO_lookup[match(n, MO_lookup$fullname), "prevalence", drop = TRUE] var_P <- MO_lookup[match(n, MO_lookup$fullname), "prevalence", drop = TRUE]
# K = kingdom index (Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5) # K = kingdom index (Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5)
var_K <- MO_lookup[match(n, MO_lookup$fullname), "kingdom_index", drop = TRUE] var_K <- MO_lookup[match(n, MO_lookup$fullname), "kingdom_index", drop = TRUE]

25
R/rsi.R
View File

@ -746,20 +746,27 @@ freq.rsi <- function(x, ...) {
# will be exported using s3_register() in R/zzz.R # will be exported using s3_register() in R/zzz.R
get_skimmers.rsi <- function(column) { get_skimmers.rsi <- function(column) {
# a bit of a crazy hack to get the variable name # get the variable name 'skim_variable'
name_call <- function(.data, name = deparse(substitute(column))) { name_call <- function(.data) {
vars <- tryCatch(eval(parse(text = ".data$skim_variable"), envir = sys.frame(2)),
error = function(e) NULL)
calls <- sys.calls() calls <- sys.calls()
calls_txt <- vapply(calls, function(x) paste(deparse(x), collapse = ""), FUN.VALUE = character(1))
if (any(calls_txt %like% "skim_variable", na.rm = TRUE)) {
ind <- which(calls_txt %like% "skim_variable")[1L]
vars <- tryCatch(eval(parse(text = ".data$skim_variable"), envir = sys.frame(ind)),
error = function(e) NULL)
} else {
vars <- NULL
}
i <- tryCatch(attributes(calls[[length(calls)]])$position, i <- tryCatch(attributes(calls[[length(calls)]])$position,
error = function(e) NULL) error = function(e) NULL)
if (is.null(vars) | is.null(i)) { if (is.null(vars) | is.null(i)) {
NA_character_ NA_character_
} else{ } else {
lengths <- sapply(vars, length) lengths <- sapply(vars, length)
lengths <- sum(lengths[!names(lengths) == "rsi"]) when_starts_rsi <- which(names(sapply(vars, length)) == "rsi")
var <- vars$rsi[i - lengths] offset <- sum(lengths[c(1:when_starts_rsi - 1)])
if (var == "data") { var <- vars$rsi[i - offset]
if (!isFALSE(var == "data")) {
NA_character_ NA_character_
} else{ } else{
ab_name(var) ab_name(var)
@ -770,7 +777,7 @@ get_skimmers.rsi <- function(column) {
sfl <- import_fn("sfl", "skimr", error_on_fail = FALSE) sfl <- import_fn("sfl", "skimr", error_on_fail = FALSE)
sfl( sfl(
skim_type = "rsi", skim_type = "rsi",
name = name_call, ab_name = name_call,
count_R = count_R, count_R = count_R,
count_S = count_susceptible, count_S = count_susceptible,
count_I = count_I, count_I = count_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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</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-1309032" class="section level1"> <div id="amr-1309033" class="section level1">
<h1 class="page-header" data-toc-text="1.3.0.9032"> <h1 class="page-header" data-toc-text="1.3.0.9033">
<a href="#amr-1309032" class="anchor"></a>AMR 1.3.0.9032<small> Unreleased </small> <a href="#amr-1309033" class="anchor"></a>AMR 1.3.0.9033<small> Unreleased </small>
</h1> </h1>
<div id="last-updated-28-september-2020" class="section level2"> <div id="last-updated-28-september-2020" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">

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-27T23:07Z last_built: 2020-09-28T09:00Z
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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</span>
</span> </span>
</div> </div>
@ -388,7 +388,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<p>With ambiguous user input in <code>as.mo()</code> and all the <code><a href='mo_property.html'>mo_*</a></code> functions, the returned results are chosen based on their matching score using <code><a href='mo_matching_score.html'>mo_matching_score()</a></code>. This matching score \(m\), ranging from 0 to 100%, is calculated as:</p> <p>With ambiguous user input in <code>as.mo()</code> and all the <code><a href='mo_property.html'>mo_*</a></code> functions, the returned results are chosen based on their matching score using <code><a href='mo_matching_score.html'>mo_matching_score()</a></code>. This matching score \(m\), is calculated as:</p>
<p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p> <p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p>
<p>where:</p><ul> <p>where:</p><ul>
<li><p>\(x\) is the user input;</p></li> <li><p>\(x\) is the user input;</p></li>

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.9028</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</span>
</span> </span>
</div> </div>
@ -280,11 +280,11 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
</tr> </tr>
<tr> <tr>
<th>version_breakpoints</th> <th>version_breakpoints</th>
<td><p>the version number to use for the EUCAST Clinical Breakpoints guideline</p></td> <td><p>the version number to use for the EUCAST Clinical Breakpoints guideline. Currently supported: 10.0.</p></td>
</tr> </tr>
<tr> <tr>
<th>version_expertrules</th> <th>version_expertrules</th>
<td><p>the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline</p></td> <td><p>the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Currently supported: 3.1, 3.2.</p></td>
</tr> </tr>
<tr> <tr>
<th>...</th> <th>...</th>

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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</span>
</span> </span>
</div> </div>
@ -261,7 +261,7 @@
<p>With ambiguous user input in <code><a href='as.mo.html'>as.mo()</a></code> and all the <code><a href='mo_property.html'>mo_*</a></code> functions, the returned results are chosen based on their matching score using <code>mo_matching_score()</code>. This matching score \(m\), ranging from 0 to 100%, is calculated as:</p> <p>With ambiguous user input in <code><a href='as.mo.html'>as.mo()</a></code> and all the <code><a href='mo_property.html'>mo_*</a></code> functions, the returned results are chosen based on their matching score using <code>mo_matching_score()</code>. This matching score \(m\), is calculated as:</p>
<p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p> <p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p>
<p>where:</p><ul> <p>where:</p><ul>
<li><p>\(x\) is the user input;</p></li> <li><p>\(x\) is the user input;</p></li>

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.9032</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9033</span>
</span> </span>
</div> </div>
@ -350,7 +350,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<p>With ambiguous user input in <code><a href='as.mo.html'>as.mo()</a></code> and all the <code>mo_*</code> functions, the returned results are chosen based on their matching score using <code><a href='mo_matching_score.html'>mo_matching_score()</a></code>. This matching score \(m\), ranging from 0 to 100%, is calculated as:</p> <p>With ambiguous user input in <code><a href='as.mo.html'>as.mo()</a></code> and all the <code>mo_*</code> functions, the returned results are chosen based on their matching score using <code><a href='mo_matching_score.html'>mo_matching_score()</a></code>. This matching score \(m\), is calculated as:</p>
<p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p> <p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p>
<p>where:</p><ul> <p>where:</p><ul>
<li><p>\(x\) is the user input;</p></li> <li><p>\(x\) is the user input;</p></li>

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

View File

@ -146,7 +146,7 @@ If the unlying code needs breaking changes, they will occur gradually. For examp
\section{Matching score for microorganisms}{ \section{Matching score for microorganisms}{
With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\link[=mo_property]{mo_*}} functions, the returned results are chosen based on their matching score using \code{\link[=mo_matching_score]{mo_matching_score()}}. This matching score \eqn{m}, ranging from 0 to 100\%, is calculated as: With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\link[=mo_property]{mo_*}} functions, the returned results are chosen based on their matching score using \code{\link[=mo_matching_score]{mo_matching_score()}}. This matching score \eqn{m}, is calculated as:
\deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )} \deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )}

View File

@ -42,9 +42,9 @@ eucast_rules(
\item{verbose}{a \link{logical} to turn Verbose mode on and off (default is off). In Verbose mode, the 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. Using Verbose mode takes a lot more time.} \item{verbose}{a \link{logical} to turn Verbose mode on and off (default is off). In Verbose mode, the 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. Using Verbose mode takes a lot more time.}
\item{version_breakpoints}{the version number to use for the EUCAST Clinical Breakpoints guideline} \item{version_breakpoints}{the version number to use for the EUCAST Clinical Breakpoints guideline. Currently supported: 10.0.}
\item{version_expertrules}{the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline} \item{version_expertrules}{the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Currently supported: 3.1, 3.2.}
\item{...}{column name of an antibiotic, please see section \emph{Antibiotics} below} \item{...}{column name of an antibiotic, please see section \emph{Antibiotics} below}
} }

View File

@ -16,7 +16,7 @@ This helper function is used by \code{\link[=as.mo]{as.mo()}} to determine the m
} }
\section{Matching score for microorganisms}{ \section{Matching score for microorganisms}{
With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\link[=mo_property]{mo_*}} functions, the returned results are chosen based on their matching score using \code{\link[=mo_matching_score]{mo_matching_score()}}. This matching score \eqn{m}, ranging from 0 to 100\%, is calculated as: With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\link[=mo_property]{mo_*}} functions, the returned results are chosen based on their matching score using \code{\link[=mo_matching_score]{mo_matching_score()}}. This matching score \eqn{m}, is calculated as:
\deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )} \deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )}

View File

@ -126,7 +126,7 @@ If the unlying code needs breaking changes, they will occur gradually. For examp
\section{Matching score for microorganisms}{ \section{Matching score for microorganisms}{
With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\link[=mo_property]{mo_*}} functions, the returned results are chosen based on their matching score using \code{\link[=mo_matching_score]{mo_matching_score()}}. This matching score \eqn{m}, ranging from 0 to 100\%, is calculated as: With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\link[=mo_property]{mo_*}} functions, the returned results are chosen based on their matching score using \code{\link[=mo_matching_score]{mo_matching_score()}}. This matching score \eqn{m}, is calculated as:
\deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )} \deqn{m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}}{m(x, n) = ( l_n * min(l_n, lev(x, n) ) ) / ( l_n * p_n * k_n )}

View File

@ -93,11 +93,11 @@ test_that("proportions works", {
# check too low amount of isolates # check too low amount of isolates
expect_identical(suppressWarnings(proportion_R(example_isolates$AMX, minimum = nrow(example_isolates) + 1)), expect_identical(suppressWarnings(proportion_R(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
NA) NA_real_)
expect_identical(suppressWarnings(proportion_I(example_isolates$AMX, minimum = nrow(example_isolates) + 1)), expect_identical(suppressWarnings(proportion_I(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
NA) NA_real_)
expect_identical(suppressWarnings(proportion_S(example_isolates$AMX, minimum = nrow(example_isolates) + 1)), expect_identical(suppressWarnings(proportion_S(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
NA) NA_real_)
# warning for speed loss # warning for speed loss
expect_warning(proportion_R(as.character(example_isolates$GEN))) expect_warning(proportion_R(as.character(example_isolates$GEN)))