(v3.0.1.9137) Add the guideline argument to count_df(), proportion_df(), sir_df(), ggplot_sir(), geom_sir(), and labels_sir_count(), so that with CLSI the 'I' category is merged with R, and describe in the documentation of get_AMR_locale() that LANG takes precedence over LANGUAGE

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2026-10-15 08:25:37 +02:00
1 parent 46f5de1d36
commit dbd95ffa46
17 files changed
+118 -40

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
Package: AMR
Version: 3.0.1.9136
Version: 3.0.1.9137
Date: 2026-10-15
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
+4 -2
View File
@@ -1,4 +1,4 @@
# AMR 3.0.1.9136
# AMR 3.0.1.9137
Planned as v3.1.0, mid October 2026.
@@ -25,6 +25,7 @@ Planned as v3.1.0, mid October 2026.
* Parallel computing in `as.sir()`, `antibiogram()`, and `wisca()` now uses the `future` and `future.apply` packages, which is faster. A non-sequential plan (e.g., `future::plan(future::multisession)`) must be active before using `parallel = TRUE` (#281).
* The options of `capped_mic_handling` in `as.sir()` have been redefined as `"none"`, `"conservative"`, `"standard"` (default), and `"lenient"`. The option `"inverse"` is no longer available (#243).
* `as.sir()` now returns WT/NWT (Wildtype/Non-wildtype) instead of S/R when using ECOFF-based interpretation with `breakpoint_type = "ECOFF"`. WT/NWT results are fully supported in all resistance and susceptibility functions and in all plots (#254).
* `count_df()`, `proportion_df()`, and `sir_df()` now follow the `AMR_guideline` option through their new `guideline` argument. With CLSI, `combine_SI = TRUE` merges 'I' with R into `"IR"` and returns `"S"` vs. `"IR"`, consistent with `count_susceptible()` and `susceptibility()`. Previously, these functions always merged 'I' with S, as with EUCAST. Use `guideline = "EUCAST"` for the old behaviour. This also applies to `ggplot_sir()`, `geom_sir()`, and `labels_sir_count()`, which got the same argument.
### New
* **Updated clinical breakpoints**
@@ -109,7 +110,7 @@ Planned as v3.1.0, mid October 2026.
* `wisca()` now follows Bielicki *et al.* (2016) more strictly by using $\text{Beta}(1, 9999)$ for intrinsically resistant pairs, forcing near-zero susceptibility regardless of observed data (based on EUCAST Expected Resistant Phenotypes)
* Fixed a bug where both functions failed without the `antimicrobials` argument if `tidyselect` was not available, e.g., for binary installations without `dplyr`
* Resistance and susceptibility calculation
* New argument `guideline` (default: EUCAST) in `susceptibility()` and `resistance()` to interpret the 'I' category correctly per guideline
* New argument `guideline` (default: EUCAST) in `susceptibility()`, `resistance()`, `count_df()`, `proportion_df()`, `sir_df()`, `ggplot_sir()`, `geom_sir()`, and `labels_sir_count()` to interpret the 'I' category correctly per guideline
* `count_*()` and `proportion_*()` now handle WT, NWT, NS, and NI results correctly (#321)
* MICs and disk diffusion
* New argument `round_to_next_log2` in `as.mic()` and `rescale_mic()` to round values up to the nearest log2 dilution level (#255)
@@ -141,6 +142,7 @@ Planned as v3.1.0, mid October 2026.
### Other
* Improved console messages with clickable links throughout the package, powered by `cli` if it is installed (#191, #265)
* The documentation of `get_AMR_locale()` now describes the actual order in which the language is determined: the `AMR_locale` option, then the `LANG` system variable, then `LANGUAGE` only if `LANG` is not set, and then the system locale
* Revamped console output of `interpretive_rules()`, with section headers, S/I/R values styled as in the printing of `sir` columns in tibbles, and the summary of edits sorted by SIR level, using `cli` if it is installed (#259)
* The printing of `custom_interpretive_rules()` and `custom_mdro_guideline()` now styles SIR values as in tibbles, i.e., the colour of `I` depends on the guideline. `WT`, `NWT`, and `NS` were previously shown as `SDD`, `I`, and `R`, and values other than `S` and `R` as `I`.
* The 'AMR for Python' vignette now contains sections on installation channels (stable from CRAN, or development from GitHub via `AMR.beta`) and on using `enforce_method` in `as_sir()` from Python
+4 -2
View File
@@ -267,7 +267,8 @@ n_sir <- count_all
count_df <- function(data,
translate_ab = "name",
language = get_AMR_locale(),
combine_SI = TRUE) {
combine_SI = TRUE,
guideline = getOption("AMR_guideline", "EUCAST")) {
tryCatch(
sir_calc_df(
type = "count",
@@ -275,7 +276,8 @@ count_df <- function(data,
translate_ab = translate_ab,
language = language,
combine_SI = combine_SI,
confidence_level = 0.95 # doesn't matter, will be removed
confidence_level = 0.95, # doesn't matter, will be removed
guideline = guideline
),
error = function(e) stop_(gsub("in sir_calc_df(): ", "", conditionMessage(e), fixed = TRUE), call = -5)
)
+6 -2
View File
@@ -174,6 +174,7 @@ ggplot_sir <- function(data,
combine_SI = TRUE,
minimum = 30,
language = get_AMR_locale(),
guideline = getOption("AMR_guideline", "EUCAST"),
nrow = NULL,
colours = c(
S = "#3CAEA3",
@@ -242,7 +243,7 @@ ggplot_sir <- function(data,
geom_sir(
position = position, x = x, fill = fill, translate_ab = translate_ab,
minimum = minimum, language = language,
combine_SI = combine_SI, ...
combine_SI = combine_SI, guideline = guideline, ...
) +
theme_sir()
@@ -263,6 +264,7 @@ ggplot_sir <- function(data,
minimum = minimum,
language = language,
combine_SI = combine_SI,
guideline = guideline,
datalabels.size = datalabels.size,
datalabels.colour = datalabels.colour
)
@@ -292,6 +294,7 @@ geom_sir <- function(position = NULL,
minimum = 30,
language = get_AMR_locale(),
combine_SI = TRUE,
guideline = getOption("AMR_guideline", "EUCAST"),
...) {
x <- x[1]
stop_ifnot_installed("ggplot2")
@@ -334,7 +337,8 @@ geom_sir <- function(position = NULL,
translate_ab = translate_ab,
language = language,
minimum = minimum,
combine_SI = combine_SI
combine_SI = combine_SI,
guideline = guideline
)
},
mapping = utils::modifyList(ggplot2::aes(), list(x = str2lang(x), y = str2lang(y), fill = str2lang(fill))),
+3 -1
View File
@@ -1554,6 +1554,7 @@ labels_sir_count <- function(position = NULL,
minimum = 30,
language = get_AMR_locale(),
combine_SI = TRUE,
guideline = getOption("AMR_guideline", "EUCAST"),
datalabels.size = 3,
datalabels.colour = "grey15") {
stop_ifnot_installed("ggplot2")
@@ -1587,7 +1588,8 @@ labels_sir_count <- function(position = NULL,
translate_ab = translate_ab,
combine_SI = combine_SI,
minimum = minimum,
language = language
language = language,
guideline = guideline
)
transformed$gr <- transformed[, x_name, drop = TRUE]
transformed %pm>%
+6 -4
View File
@@ -42,9 +42,9 @@
#' * EUCAST: [susceptibility()] \eqn{= \%S + \%I}, [resistance()] \eqn{= \%R}
#' * CLSI: [susceptibility()] \eqn{= \%S + \%SDD}, [resistance()] \eqn{= \%I + \%R}
#'
#' You can also use e.g. [proportion_R()] or [proportion_S()] instead, to be explicit.
#' You can also use e.g. [proportion_R()] or [proportion_S()] instead, to be explicit. For [proportion_df()], [count_df()], and [sir_df()], the guideline determines how 'I' is merged when `combine_SI = TRUE`.
#' @inheritParams ab_property
#' @param combine_SI A [logical] to indicate whether all values of S, SDD, and I must be merged into one, so the output only consists of S+SDD+I vs. R (susceptible vs. resistant) - the default is `TRUE`.
#' @param combine_SI A [logical] to indicate whether the 'I' category must be merged with another category, so the output only consists of susceptible vs. resistant - the default is `TRUE`. Following the `guideline` argument, the output then consists of `"SI"` (S+SDD+I) vs. `"R"` with EUCAST, and of `"S"` (S+SDD) vs. `"IR"` (I+R) with CLSI.
#' @param ab_result Antibiotic results to test against, must be one or more values of "S", "SDD", "I", or "R".
#' @param confidence_level The confidence level for the returned confidence interval. For the calculation, the number of S or SI isolates, and R isolates are compared with the total number of available isolates with R, S, or I by using [binom.test()], i.e., the Clopper-Pearson method.
#' @param side The side of the confidence interval to return. The default is `"both"` for a length 2 vector, but can also be (abbreviated as) `"min"`/`"left"`/`"lower"`/`"less"` or `"max"`/`"right"`/`"higher"`/`"greater"`.
@@ -431,7 +431,8 @@ proportion_df <- function(data,
minimum = 30,
as_percent = FALSE,
combine_SI = TRUE,
confidence_level = 0.95) {
confidence_level = 0.95,
guideline = getOption("AMR_guideline", "EUCAST")) {
tryCatch(
sir_calc_df(
type = "proportion",
@@ -441,7 +442,8 @@ proportion_df <- function(data,
minimum = minimum,
as_percent = as_percent,
combine_SI = combine_SI,
confidence_level = confidence_level
confidence_level = confidence_level,
guideline = guideline
),
error = function(e) stop_(gsub("in sir_calc_df(): ", "", conditionMessage(e), fixed = TRUE), call = -5)
)
+17 -5
View File
@@ -220,7 +220,8 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
minimum = 30,
as_percent = FALSE,
combine_SI = TRUE,
confidence_level = 0.95) {
confidence_level = 0.95,
guideline = getOption("AMR_guideline", "EUCAST")) {
meet_criteria(type, is_in = c("proportion", "count", "both"), has_length = 1)
meet_criteria(data, allow_class = "data.frame")
data <- ascertain_sir_classes(data, "data")
@@ -230,6 +231,15 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
meet_criteria(as_percent, allow_class = "logical", has_length = 1)
meet_criteria(combine_SI, allow_class = "logical", has_length = 1)
meet_criteria(confidence_level, allow_class = "numeric", has_length = 1)
meet_criteria(guideline, allow_class = "character", has_length = 1)
if (guideline %like% "EUCAST") {
guideline <- "EUCAST"
} else if (guideline %like% "CLSI") {
guideline <- "CLSI"
}
meet_criteria(guideline, allow_class = "character", is_in = c("EUCAST", "CLSI"), has_length = 1)
# with EUCAST, 'I' is merged with S into 'SI', with CLSI, 'I' is merged with R into 'IR'
combined_levels <- if (identical(guideline, "CLSI")) c("S", "IR") else c("SI", "R")
translate_ab <- get_translate_ab(translate_ab)
@@ -252,10 +262,12 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
data[, i] <- as.character(as.sir(data[, i, drop = TRUE]))
data[which(data[, i, drop = TRUE] %in% c("S", "SDD", "WT")), i] <- "S"
data[which(data[, i, drop = TRUE] %in% c("R", "NWT", "NS")), i] <- "R"
if (isTRUE(combine_SI)) {
if (isTRUE(combine_SI) && identical(guideline, "CLSI")) {
data[which(data[, i, drop = TRUE] %in% c("I", "R")), i] <- "IR"
} else if (isTRUE(combine_SI)) {
data[which(data[, i, drop = TRUE] %in% c("I", "S")), i] <- "SI"
}
data[which(!data[, i, drop = TRUE] %in% c("S", "SI", "I", "R")), i] <- NA_character_
data[which(!data[, i, drop = TRUE] %in% c("S", "SI", "I", "IR", "R")), i] <- NA_character_
}
}
@@ -277,7 +289,7 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
for (i in seq_len(ncol(.data))) {
values <- .data[, i, drop = TRUE]
if (isTRUE(combine_SI)) {
values <- factor(values, levels = c("SI", "R", "NI"), ordered = TRUE)
values <- factor(values, levels = c(combined_levels, "NI"), ordered = TRUE)
} else {
values <- factor(values, levels = c("S", "SDD", "I", "R", "NI"), ordered = TRUE)
}
@@ -352,7 +364,7 @@ sir_calc_df <- function(type, # "proportion", "count" or "both"
# apply factors for right sorting in interpretation
if (isTRUE(combine_SI)) {
out$interpretation <- factor(out$interpretation, levels = c("SI", "R"), ordered = TRUE)
out$interpretation <- factor(out$interpretation, levels = combined_levels, ordered = TRUE)
} else {
# don't use as.sir() here, as it would add the class 'sir' and we would like
# the same data structure as output, regardless of input
+4 -2
View File
@@ -35,7 +35,8 @@ sir_df <- function(data,
minimum = 30,
as_percent = FALSE,
combine_SI = TRUE,
confidence_level = 0.95) {
confidence_level = 0.95,
guideline = getOption("AMR_guideline", "EUCAST")) {
tryCatch(
sir_calc_df(
type = "both",
@@ -45,7 +46,8 @@ sir_df <- function(data,
minimum = minimum,
as_percent = as_percent,
combine_SI = combine_SI,
confidence_level = confidence_level
confidence_level = confidence_level,
guideline = guideline
),
error = function(e) stop_(gsub("in sir_calc_df(): ", "", conditionMessage(e), fixed = TRUE), call = -5)
)
+7 -5
View File
@@ -49,14 +49,16 @@
#' Please read about adding or updating a language in [our Wiki](https://github.com/msberends/AMR/wiki/).
#'
#' ### Changing the Default Language
#' The system language will be used at default (as returned by `Sys.getenv("LANG")` or, if `LANG` is not set, [`Sys.getlocale("LC_COLLATE")`][Sys.getlocale()]), if that language is supported. But the language to be used can be overwritten in two ways and will be checked in this order:
#' The system language will be used at default, if that language is supported. The language to be used is determined in this order:
#'
#' 1. Setting the package option [`AMR_locale`][AMR-options], either by using e.g. `set_AMR_locale("German")` or by running e.g. `options(AMR_locale = "German")`.
#' 1. The package option [`AMR_locale`][AMR-options], set by using e.g. `set_AMR_locale("German")` or by running e.g. `options(AMR_locale = "German")`.
#'
#' Note that setting an \R option only works in the same session. Save the command `options(AMR_locale = "(your language)")` to your `.Rprofile` file to apply it for every session. Run `utils::file.edit("~/.Rprofile")` to edit your `.Rprofile` file.
#' 2. Setting the system variable `LANGUAGE` or `LANG`, e.g. by adding `LANGUAGE="de_DE.utf8"` to your `.Renviron` file in your home directory.
#' 2. The system variable `LANG`, as returned by `Sys.getenv("LANG")`, e.g. set by adding `LANG="de_DE.utf8"` to your `.Renviron` file in your home directory.
#' 3. The system variable `LANGUAGE`, but only if `LANG` is not set. Note that `LANG` is set on most Linux and macOS systems, in which case `LANGUAGE` has no effect.
#' 4. The system locale, as returned by [`Sys.getlocale("LC_COLLATE")`][Sys.getlocale()], if neither `LANG` nor `LANGUAGE` is set.
#'
#' Thus, if the package option [`AMR_locale`][AMR-options] is set, the system variables `LANGUAGE` and `LANG` will be ignored.
#' Thus, if the package option [`AMR_locale`][AMR-options] is set, the system variables `LANG` and `LANGUAGE` will be ignored.
#' @rdname translate
#' @name translate
#' @export
@@ -90,7 +92,7 @@ get_AMR_locale <- function() {
return(validate_language(getOption("AMR_locale"), extra_txt = "set with `options(AMR_locale = ...)`"))
}
lang <- ""
# now check the LANGUAGE system variable - return it if set
# now check the system variables, of which LANG takes precedence over LANGUAGE
if (!identical("", Sys.getenv("LANGUAGE"))) {
lang <- Sys.getenv("LANGUAGE")
}
+3 -2
View File
@@ -44,7 +44,8 @@ count_df(
data,
translate_ab = "name",
language = get_AMR_locale(),
combine_SI = TRUE
combine_SI = TRUE,
guideline = getOption("AMR_guideline", "EUCAST")
)
}
\arguments{
@@ -66,7 +67,7 @@ You can also use e.g. \code{\link[=count_R]{count_R()}} or \code{\link[=count_S]
\item{language}{Language of the returned text - the default is the current system language (see \code{\link[=get_AMR_locale]{get_AMR_locale()}}) and can also be set with the package option \code{\link[=AMR-options]{AMR_locale}}. Use \code{language = NULL} or \code{language = ""} to prevent translation.}
\item{combine_SI}{A \link{logical} to indicate whether all values of S, SDD, and I must be merged into one, so the output only consists of S+SDD+I vs. R (susceptible vs. resistant) - the default is \code{TRUE}.}
\item{combine_SI}{A \link{logical} to indicate whether the 'I' category must be merged with another category, so the output only consists of susceptible vs. resistant - the default is \code{TRUE}. Following the \code{guideline} argument, the output then consists of \code{"SI"} (S+SDD+I) vs. \code{"R"} with EUCAST, and of \code{"S"} (S+SDD) vs. \code{"IR"} (I+R) with CLSI.}
}
\value{
An \link{integer}
+11 -1
View File
@@ -17,6 +17,7 @@ ggplot_sir(
combine_SI = TRUE,
minimum = 30,
language = get_AMR_locale(),
guideline = getOption("AMR_guideline", "EUCAST"),
nrow = NULL,
colours = c(S = "#3CAEA3", SDD = "#8FD6C4", SI = "#3CAEA3", I = "#F6D55C", IR =
"#ED553B", R = "#ED553B"),
@@ -39,6 +40,7 @@ geom_sir(
minimum = 30,
language = get_AMR_locale(),
combine_SI = TRUE,
guideline = getOption("AMR_guideline", "EUCAST"),
...
)
}
@@ -59,12 +61,20 @@ geom_sir(
\item{translate_ab}{A column name of the \link{antimicrobials} data set to translate the antibiotic abbreviations to, using \code{\link[=ab_property]{ab_property()}}.}
\item{combine_SI}{A \link{logical} to indicate whether all values of S, SDD, and I must be merged into one, so the output only consists of S+SDD+I vs. R (susceptible vs. resistant) - the default is \code{TRUE}.}
\item{combine_SI}{A \link{logical} to indicate whether the 'I' category must be merged with another category, so the output only consists of susceptible vs. resistant - the default is \code{TRUE}. Following the \code{guideline} argument, the output then consists of \code{"SI"} (S+SDD+I) vs. \code{"R"} with EUCAST, and of \code{"S"} (S+SDD) vs. \code{"IR"} (I+R) with CLSI.}
\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 \emph{Source}.}
\item{language}{Language of the returned text - the default is the current system language (see \code{\link[=get_AMR_locale]{get_AMR_locale()}}) and can also be set with the package option \code{\link[=AMR-options]{AMR_locale}}. Use \code{language = NULL} or \code{language = ""} to prevent translation.}
\item{guideline}{Either \code{"EUCAST"} (default) or \code{"CLSI"}. With EUCAST, the 'I' category will be considered as susceptible (see \href{https://www.eucast.org/bacteria/clinical-breakpoints-and-interpretation/definition-of-s-i-and-r/}{EUCAST website}), but with with CLSI, it will be considered resistant. Therefore:
\itemize{
\item EUCAST: \code{\link[=susceptibility]{susceptibility()}} \eqn{= \%S + \%I}, \code{\link[=resistance]{resistance()}} \eqn{= \%R}
\item CLSI: \code{\link[=susceptibility]{susceptibility()}} \eqn{= \%S + \%SDD}, \code{\link[=resistance]{resistance()}} \eqn{= \%I + \%R}
}
You can also use e.g. \code{\link[=proportion_R]{proportion_R()}} or \code{\link[=proportion_S]{proportion_S()}} instead, to be explicit. For \code{\link[=proportion_df]{proportion_df()}}, \code{\link[=count_df]{count_df()}}, and \code{\link[=sir_df]{sir_df()}}, the guideline determines how 'I' is merged when \code{combine_SI = TRUE}.}
\item{nrow}{(when using \code{facet}) number of rows.}
\item{colours}{A named vactor with colour to be used for filling. The default colours are colour-blind friendly.}
+2 -1
View File
@@ -159,6 +159,7 @@ labels_sir_count(
minimum = 30,
language = get_AMR_locale(),
combine_SI = TRUE,
guideline = getOption("AMR_guideline", "EUCAST"),
datalabels.size = 3,
datalabels.colour = "grey15"
)
@@ -210,7 +211,7 @@ labels_sir_count(
\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 \emph{Source}.}
\item{combine_SI}{A \link{logical} to indicate whether all values of S, SDD, and I must be merged into one, so the output only consists of S+SDD+I vs. R (susceptible vs. resistant) - the default is \code{TRUE}.}
\item{combine_SI}{A \link{logical} to indicate whether the 'I' category must be merged with another category, so the output only consists of susceptible vs. resistant - the default is \code{TRUE}. Following the \code{guideline} argument, the output then consists of \code{"SI"} (S+SDD+I) vs. \code{"R"} with EUCAST, and of \code{"S"} (S+SDD) vs. \code{"IR"} (I+R) with CLSI.}
\item{datalabels.size}{Size of the datalabels.}
+6 -4
View File
@@ -59,7 +59,8 @@ proportion_df(
minimum = 30,
as_percent = FALSE,
combine_SI = TRUE,
confidence_level = 0.95
confidence_level = 0.95,
guideline = getOption("AMR_guideline", "EUCAST")
)
sir_df(
@@ -69,7 +70,8 @@ sir_df(
minimum = 30,
as_percent = FALSE,
combine_SI = TRUE,
confidence_level = 0.95
confidence_level = 0.95,
guideline = getOption("AMR_guideline", "EUCAST")
)
}
\arguments{
@@ -87,7 +89,7 @@ sir_df(
\item CLSI: \code{\link[=susceptibility]{susceptibility()}} \eqn{= \%S + \%SDD}, \code{\link[=resistance]{resistance()}} \eqn{= \%I + \%R}
}
You can also use e.g. \code{\link[=proportion_R]{proportion_R()}} or \code{\link[=proportion_S]{proportion_S()}} instead, to be explicit.}
You can also use e.g. \code{\link[=proportion_R]{proportion_R()}} or \code{\link[=proportion_S]{proportion_S()}} instead, to be explicit. For \code{\link[=proportion_df]{proportion_df()}}, \code{\link[=count_df]{count_df()}}, and \code{\link[=sir_df]{sir_df()}}, the guideline determines how 'I' is merged when \code{combine_SI = TRUE}.}
\item{ab_result}{Antibiotic results to test against, must be one or more values of "S", "SDD", "I", or "R".}
@@ -103,7 +105,7 @@ You can also use e.g. \code{\link[=proportion_R]{proportion_R()}} or \code{\link
\item{language}{Language of the returned text - the default is the current system language (see \code{\link[=get_AMR_locale]{get_AMR_locale()}}) and can also be set with the package option \code{\link[=AMR-options]{AMR_locale}}. Use \code{language = NULL} or \code{language = ""} to prevent translation.}
\item{combine_SI}{A \link{logical} to indicate whether all values of S, SDD, and I must be merged into one, so the output only consists of S+SDD+I vs. R (susceptible vs. resistant) - the default is \code{TRUE}.}
\item{combine_SI}{A \link{logical} to indicate whether the 'I' category must be merged with another category, so the output only consists of susceptible vs. resistant - the default is \code{TRUE}. Following the \code{guideline} argument, the output then consists of \code{"SI"} (S+SDD+I) vs. \code{"R"} with EUCAST, and of \code{"S"} (S+SDD) vs. \code{"IR"} (I+R) with CLSI.}
}
\value{
A \link{double} or, when \code{as_percent = TRUE}, a \link{character}.
+6 -4
View File
@@ -41,15 +41,17 @@ And then save the file.
Please read about adding or updating a language in \href{https://github.com/msberends/AMR/wiki/}{our Wiki}.
\subsection{Changing the Default Language}{
The system language will be used at default (as returned by \code{Sys.getenv("LANG")} or, if \code{LANG} is not set, \code{\link[=Sys.getlocale]{Sys.getlocale("LC_COLLATE")}}), if that language is supported. But the language to be used can be overwritten in two ways and will be checked in this order:
The system language will be used at default, if that language is supported. The language to be used is determined in this order:
\enumerate{
\item Setting the package option \code{\link[=AMR-options]{AMR_locale}}, either by using e.g. \code{set_AMR_locale("German")} or by running e.g. \code{options(AMR_locale = "German")}.
\item The package option \code{\link[=AMR-options]{AMR_locale}}, set by using e.g. \code{set_AMR_locale("German")} or by running e.g. \code{options(AMR_locale = "German")}.
Note that setting an \R option only works in the same session. Save the command \code{options(AMR_locale = "(your language)")} to your \code{.Rprofile} file to apply it for every session. Run \code{utils::file.edit("~/.Rprofile")} to edit your \code{.Rprofile} file.
\item Setting the system variable \code{LANGUAGE} or \code{LANG}, e.g. by adding \code{LANGUAGE="de_DE.utf8"} to your \code{.Renviron} file in your home directory.
\item The system variable \code{LANG}, as returned by \code{Sys.getenv("LANG")}, e.g. set by adding \code{LANG="de_DE.utf8"} to your \code{.Renviron} file in your home directory.
\item The system variable \code{LANGUAGE}, but only if \code{LANG} is not set. Note that \code{LANG} is set on most Linux and macOS systems, in which case \code{LANGUAGE} has no effect.
\item The system locale, as returned by \code{\link[=Sys.getlocale]{Sys.getlocale("LC_COLLATE")}}, if neither \code{LANG} nor \code{LANGUAGE} is set.
}
Thus, if the package option \code{\link[=AMR-options]{AMR_locale}} is set, the system variables \code{LANGUAGE} and \code{LANG} will be ignored.
Thus, if the package option \code{\link[=AMR-options]{AMR_locale}} is set, the system variables \code{LANG} and \code{LANGUAGE} will be ignored.
}
}
\examples{
+16 -2
View File
@@ -89,14 +89,28 @@ test_that("test-count.R", {
c(946, 428, 94)
)
# count_df, which always combines S and I, as with EUCAST
# count_df, which combines 'I' with S for EUCAST and with R for CLSI
expect_equal(
example_isolates %>% select(AMX) %>% count_df() %>% pull(value),
example_isolates %>% select(AMX) %>% count_df(guideline = "EUCAST") %>% pull(value),
c(
example_isolates$AMX %>% count_susceptible(guideline = "EUCAST"),
example_isolates$AMX %>% count_resistant(guideline = "EUCAST")
)
)
expect_equal(
example_isolates %>% select(AMX) %>% count_df(guideline = "CLSI") %>% pull(value),
c(
example_isolates$AMX %>% count_susceptible(guideline = "CLSI"),
example_isolates$AMX %>% count_resistant(guideline = "CLSI")
)
)
expect_identical(
levels(count_df(example_isolates[, "AMX"], guideline = "CLSI")$interpretation),
c("S", "IR")
)
old_opts <- options(AMR_guideline = "CLSI")
expect_identical(count_df(example_isolates[, "AMX"]), count_df(example_isolates[, "AMX"], guideline = "CLSI"))
options(old_opts)
expect_equal(
example_isolates %>% select(AMX) %>% count_df(combine_SI = FALSE) %>% pull(value),
c(
+6
View File
@@ -96,6 +96,12 @@ test_that("test-ggplot_sir.R", {
as.double()
)
# the 'I' category is merged with R for CLSI
expect_identical(
levels(ggplot_sir(example_isolates[, c("AMC", "CIP")], guideline = "CLSI")$layers[[1]]$data(example_isolates[, c("AMC", "CIP")])$interpretation),
c("S", "IR")
)
# support for scale_type ab and mo
expect_inherits(
(data.frame(
+16 -2
View File
@@ -99,14 +99,28 @@ test_that("test-proportion.R", {
c(1181, 577, 116)
)
# proportion_df
# proportion_df, which combines 'I' with S for EUCAST and with R for CLSI
expect_equal(
example_isolates %>% select(AMX) %>% proportion_df() %>% pull(value),
example_isolates %>% select(AMX) %>% proportion_df(guideline = "EUCAST") %>% pull(value),
c(
example_isolates$AMX %>% proportion_SI(),
example_isolates$AMX %>% proportion_R()
)
)
expect_equal(
example_isolates %>% select(AMX) %>% proportion_df(guideline = "CLSI") %>% pull(value),
c(
example_isolates$AMX %>% proportion_S(),
example_isolates$AMX %>% proportion_IR()
)
)
expect_equal(
example_isolates %>% select(AMX) %>% sir_df(guideline = "CLSI") %>% pull(isolates),
c(
example_isolates$AMX %>% count_S(),
example_isolates$AMX %>% count_IR()
)
)
expect_equal(
example_isolates %>% select(AMX) %>% proportion_df(combine_SI = FALSE) %>% pull(value),
c(