diff --git a/DESCRIPTION b/DESCRIPTION index 36139086..4a904a32 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 2.1.1.9112 -Date: 2024-12-06 +Version: 2.1.1.9116 +Date: 2024-12-13 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by diff --git a/NEWS.md b/NEWS.md index af6e7a80..5e1b7049 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9112 +# AMR 2.1.1.9116 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)* @@ -47,7 +47,8 @@ This package now supports not only tools for AMR data analysis in clinical setti * Added Amorolfine (`AMO`, D01AE16), which is now also part of the `antifungals()` selector * Antibiotic selectors * Added selectors `nitrofurans()` and `rifamycins()` - * When using antibiotic selectors such as `aminoglycosides()` that exclude non-treatable drugs like gentamicin-high, the function now always returns a warning that these can be included using `only_treatable = FALSE` + * When using antibiotic selectors (such as `aminoglycosides()`) that exclude non-treatable drugs (such as gentamicin-high), the function now always returns a warning that these can be included using `only_treatable = FALSE` + * All selectors can now be run as a separate command to retrieve a vector of all possible antimicrobials that the selector can select * MICs * Added as valid levels: 4096, 6 powers of 0.0625, and 5 powers of 192 (192, 384, 576, 768, 960) * Added new argument `keep_operators` to `as.mic()`. This can be `"all"` (default), `"none"`, or `"edges"`. This argument is also available in the new `rescale_mic()` and `scale_*_mic()` functions. @@ -71,6 +72,7 @@ This package now supports not only tools for AMR data analysis in clinical setti * Fixed a bug for `sir_confidence_interval()` when there are no isolates available * Updated the prevalence calculation to include genera from the World Health Organization's (WHO) Priority Pathogen List * Improved algorithm of `first_isolate()` when using the phenotype-based method, to prioritise records with the highest availability of SIR values +* `scale_y_percent()` can now cope with ranges outside the 0-100% range ## Other * Greatly improved `vctrs` integration, a Tidyverse package working in the background for many Tidyverse functions. For users, this means that functions such as `dplyr`'s `bind_rows()`, `rowwise()` and `c_across()` are now supported for e.g. columns of class `mic`. Despite this, this `AMR` package is still zero-dependent on any other package, including `dplyr` and `vctrs`. diff --git a/PythonPackage/AMR/AMR.egg-info/PKG-INFO b/PythonPackage/AMR/AMR.egg-info/PKG-INFO index 14498aa4..d75f069a 100644 --- a/PythonPackage/AMR/AMR.egg-info/PKG-INFO +++ b/PythonPackage/AMR/AMR.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: AMR -Version: 2.1.1.9112 +Version: 2.1.1.9116 Summary: A Python wrapper for the AMR R package Home-page: https://github.com/msberends/AMR Author: Dr. Matthijs Berends diff --git a/PythonPackage/AMR/dist/AMR-2.1.1.9112-py3-none-any.whl b/PythonPackage/AMR/dist/AMR-2.1.1.9116-py3-none-any.whl similarity index 85% rename from PythonPackage/AMR/dist/AMR-2.1.1.9112-py3-none-any.whl rename to PythonPackage/AMR/dist/AMR-2.1.1.9116-py3-none-any.whl index b60c2f6c..cc0760d7 100644 Binary files a/PythonPackage/AMR/dist/AMR-2.1.1.9112-py3-none-any.whl and b/PythonPackage/AMR/dist/AMR-2.1.1.9116-py3-none-any.whl differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9112.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9112.tar.gz deleted file mode 100644 index e15b5b2c..00000000 Binary files a/PythonPackage/AMR/dist/amr-2.1.1.9112.tar.gz and /dev/null differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9116.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9116.tar.gz new file mode 100644 index 00000000..f81d6d4d Binary files /dev/null and b/PythonPackage/AMR/dist/amr-2.1.1.9116.tar.gz differ diff --git a/PythonPackage/AMR/setup.py b/PythonPackage/AMR/setup.py index aa7158fc..d9dbf54e 100644 --- a/PythonPackage/AMR/setup.py +++ b/PythonPackage/AMR/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='AMR', - version='2.1.1.9112', + version='2.1.1.9116', packages=find_packages(), install_requires=[ 'rpy2', diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 742ec486..7cea3406 100644 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -1036,6 +1036,7 @@ get_current_data <- function(arg_name, call) { ", e.g.:\n", " ", AMR_env$bullet_icon, " your_data %>% select(", fn, "())\n", " ", AMR_env$bullet_icon, " your_data %>% select(column_a, column_b, ", fn, "())\n", + " ", AMR_env$bullet_icon, " your_data %>% filter(any(", fn, "() == \"R\"))\n", " ", AMR_env$bullet_icon, " your_data[, ", fn, "()]\n", " ", AMR_env$bullet_icon, " your_data[, c(\"column_a\", \"column_b\", ", fn, "())]" ) diff --git a/R/ab_selectors.R b/R/ab_selectors.R index f75a2587..8a4332b8 100755 --- a/R/ab_selectors.R +++ b/R/ab_selectors.R @@ -48,7 +48,7 @@ #' `r paste0(" * ", na.omit(sapply(DEFINED_AB_GROUPS, function(ab) ifelse(tolower(gsub("^AB_", "", ab)) %in% ls(envir = asNamespace("AMR")), paste0("[", tolower(gsub("^AB_", "", ab)), "()] can select: \\cr ", vector_and(paste0(ab_name(eval(parse(text = ab), envir = asNamespace("AMR")), language = NULL, tolower = TRUE), " (", eval(parse(text = ab), envir = asNamespace("AMR")), ")"), quotes = FALSE, sort = TRUE)), character(0)), USE.NAMES = FALSE)), "\n", collapse = "")` #' @rdname antibiotic_class_selectors #' @name antibiotic_class_selectors -#' @return (internally) a [character] vector of column names, with additional class `"ab_selector"` +#' @return When used inside selecting or filtering, this returns a [character] vector of column names, with additional class `"ab_selector"`. When used individually, this returns an ['ab' vector][as.ab()] with all possible antimicrobial that the function would be able to select or filter. #' @export #' @inheritSection AMR Reference Data Publicly Available #' @examples @@ -57,9 +57,15 @@ #' example_isolates #' #' +#' # you can use the selectors separately to retrieve all possible antimicrobials: +#' carbapenems() +#' +#' +#' # Though they are primarily intended to use for selections and filters. #' # Examples sections below are split into 'dplyr', 'base R', and 'data.table': #' #' \donttest{ +#' \dontrun{ #' # dplyr ------------------------------------------------------------------- #' #' library(dplyr, warn.conflicts = FALSE) @@ -145,7 +151,7 @@ #' z <- example_isolates %>% filter(if_all(carbapenems(), ~ .x == "R")) #' identical(x, y) && identical(y, z) #' -#' +#' } #' # base R ------------------------------------------------------------------ #' #' # select columns 'IPM' (imipenem) and 'MEM' (meropenem) @@ -589,15 +595,16 @@ ab_select_exec <- function(function_name, ab_class_args = NULL) { # get_current_data() has to run each time, for cases where e.g., filter() and select() are used in same call # it only takes a couple of milliseconds, so no problem - vars_df <- get_current_data(arg_name = NA, call = -3) + vars_df <- tryCatch(get_current_data(arg_name = NA, call = -3), error = function(e) NULL) # to improve speed, get_column_abx() will only run once when e.g. in a select or group call - ab_in_data <- get_column_abx(vars_df, - info = FALSE, only_sir_columns = only_sir_columns, - sort = FALSE, fn = function_name - ) - + if (!is.null(vars_df)) { + ab_in_data <- get_column_abx(vars_df, + info = FALSE, only_sir_columns = only_sir_columns, + sort = FALSE, fn = function_name) + } + # untreatable drugs - if (only_treatable == TRUE) { + if (!is.null(vars_df) && only_treatable == TRUE) { untreatable <- AMR_env$AB_lookup[which(AMR_env$AB_lookup$name %like% "(-high|EDTA|polysorbate|macromethod|screening|nacubactam)"), "ab", drop = TRUE] if (any(untreatable %in% names(ab_in_data))) { if (message_not_thrown_before(function_name, "ab_class", "untreatable")) { @@ -617,7 +624,7 @@ ab_select_exec <- function(function_name, } } - if (length(ab_in_data) == 0) { + if (!is.null(vars_df) && length(ab_in_data) == 0) { message_("No antimicrobial drugs found in the data.") return(NULL) } @@ -666,6 +673,21 @@ ab_select_exec <- function(function_name, function_name <- "ab_class" examples <- paste0(" (such as ", find_ab_names(ab_class_args, 2), ")") } + + if (is.null(vars_df)) { + # no data found, no antimicrobials, so no input. Can happen if users run e.g. `aminoglycosides()` as a separate command. + examples <- paste0( + ", e.g.:\n", + " ", AMR_env$bullet_icon, " your_data %>% select(", function_name, "())\n", + " ", AMR_env$bullet_icon, " your_data %>% select(column_a, column_b, ", function_name, "())\n", + " ", AMR_env$bullet_icon, " your_data %>% filter(any(", function_name, "() == \"R\"))\n", + " ", AMR_env$bullet_icon, " your_data[, ", function_name, "()]\n", + " ", AMR_env$bullet_icon, " your_data[, c(\"column_a\", \"column_b\", ", function_name, "())]" + ) + message_("The function `" , function_name, "()` should be used inside a `dplyr` verb or `data.frame` call", + examples, "\n\nNow returning a vector of all possible antimicrobials that `" , function_name, "()` can select.") + return(sort(abx)) + } # get the columns with a group names in the chosen ab class agents <- ab_in_data[names(ab_in_data) %in% abx] diff --git a/R/ggplot_sir.R b/R/ggplot_sir.R index bd75b3e7..fb30bde8 100755 --- a/R/ggplot_sir.R +++ b/R/ggplot_sir.R @@ -373,17 +373,17 @@ facet_sir <- function(facet = c("interpretation", "antibiotic"), nrow = NULL) { #' @rdname ggplot_sir #' @export -scale_y_percent <- function(breaks = seq(0, 1, 0.1), limits = NULL) { +scale_y_percent <- function(breaks = function(x) seq(0, max(x, na.rm = TRUE), 0.1), limits = NULL) { stop_ifnot_installed("ggplot2") - meet_criteria(breaks, allow_class = c("numeric", "integer")) + meet_criteria(breaks, allow_class = c("numeric", "integer", "function")) meet_criteria(limits, allow_class = c("numeric", "integer"), has_length = 2, allow_NULL = TRUE, allow_NA = TRUE) - if (all(breaks[breaks != 0] > 1)) { + if (!is.function(breaks) && all(breaks[breaks != 0] > 1)) { breaks <- breaks / 100 } ggplot2::scale_y_continuous( breaks = breaks, - labels = percentage(breaks), + labels = if (is.function(breaks)) function(x) percentage(breaks(x)) else percentage(breaks), limits = limits ) } diff --git a/R/sysdata.rda b/R/sysdata.rda index ff4c32aa..121700d3 100755 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/gpt_training_text_v2.1.1.9112.txt b/data-raw/gpt_training_text_v2.1.1.9116.txt similarity index 99% rename from data-raw/gpt_training_text_v2.1.1.9112.txt rename to data-raw/gpt_training_text_v2.1.1.9116.txt index f09488d8..06be6b57 100644 --- a/data-raw/gpt_training_text_v2.1.1.9112.txt +++ b/data-raw/gpt_training_text_v2.1.1.9116.txt @@ -1,5 +1,5 @@ This files contains all context you must know about the AMR package for R. -First and foremost, you are trained on version 2.1.1.9112. Remember this whenever someone asks which AMR package version you’re at. +First and foremost, you are trained on version 2.1.1.9116. Remember this whenever someone asks which AMR package version you’re at. -------------------------------- THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'NAMESPACE': @@ -811,29 +811,29 @@ Authors: Other contributors: \itemize{ - \item Casper J. Albers (\href{https://orcid.org/0000-0002-9213-6743}{ORCID}) [thesis advisor] - \item Larisse Bolton (\href{https://orcid.org/0000-0001-7879-2173}{ORCID}) [contributor] - \item Peter Dutey-Magni (\href{https://orcid.org/0000-0002-8942-9836}{ORCID}) [contributor] - \item Judith M. Fonville [contributor] - \item Alex W. Friedrich (\href{https://orcid.org/0000-0003-4881-038X}{ORCID}) [thesis advisor] - \item Corinna Glasner (\href{https://orcid.org/0000-0003-1241-1328}{ORCID}) [thesis advisor] + \item Andrew P. Norgan (\href{https://orcid.org/0000-0002-2955-2066}{ORCID}) [contributor] + \item Anita Williams (\href{https://orcid.org/0000-0002-5295-8451}{ORCID}) [contributor] + \item Annick Lenglet (\href{https://orcid.org/0000-0003-2013-8405}{ORCID}) [contributor] + \item Anthony Underwood (\href{https://orcid.org/0000-0002-8547-4277}{ORCID}) [contributor] + \item Anton Mymrikov [contributor] + \item Bart C. Meijer [contributor] + \item Christian F. Luz (\href{https://orcid.org/0000-0001-5809-5995}{ORCID}) [contributor] + \item Dmytro Mykhailenko [contributor] \item Eric H. L. C. M. Hazenberg [contributor] \item Gwen Knight (\href{https://orcid.org/0000-0002-7263-9896}{ORCID}) [contributor] - \item Annick Lenglet (\href{https://orcid.org/0000-0003-2013-8405}{ORCID}) [contributor] - \item Christian F. Luz (\href{https://orcid.org/0000-0001-5809-5995}{ORCID}) [contributor] - \item Bart C. Meijer [contributor] - \item Dmytro Mykhailenko [contributor] - \item Anton Mymrikov [contributor] - \item Andrew P. Norgan (\href{https://orcid.org/0000-0002-2955-2066}{ORCID}) [contributor] - \item Sofia Ny (\href{https://orcid.org/0000-0002-2017-1363}{ORCID}) [contributor] - \item Matthew Saab [contributor] - \item Jonas Salm [contributor] - \item Javier Sanchez (\href{https://orcid.org/0000-0003-2605-8094}{ORCID}) [contributor] - \item Rogier P. Schade [contributor] - \item Bhanu N. M. Sinha (\href{https://orcid.org/0000-0003-1634-0010}{ORCID}) [thesis advisor] \item Jason Stull (\href{https://orcid.org/0000-0002-9028-8153}{ORCID}) [contributor] - \item Anthony Underwood (\href{https://orcid.org/0000-0002-8547-4277}{ORCID}) [contributor] - \item Anita Williams (\href{https://orcid.org/0000-0002-5295-8451}{ORCID}) [contributor] + \item Javier Sanchez (\href{https://orcid.org/0000-0003-2605-8094}{ORCID}) [contributor] + \item Jonas Salm [contributor] + \item Judith M. Fonville [contributor] + \item Larisse Bolton (\href{https://orcid.org/0000-0001-7879-2173}{ORCID}) [contributor] + \item Matthew Saab [contributor] + \item Peter Dutey-Magni (\href{https://orcid.org/0000-0002-8942-9836}{ORCID}) [contributor] + \item Rogier P. Schade [contributor] + \item Sofia Ny (\href{https://orcid.org/0000-0002-2017-1363}{ORCID}) [contributor] + \item Alex W. Friedrich (\href{https://orcid.org/0000-0003-4881-038X}{ORCID}) [thesis advisor] + \item Bhanu N. M. Sinha (\href{https://orcid.org/0000-0003-1634-0010}{ORCID}) [thesis advisor] + \item Casper J. Albers (\href{https://orcid.org/0000-0002-9213-6743}{ORCID}) [thesis advisor] + \item Corinna Glasner (\href{https://orcid.org/0000-0003-1241-1328}{ORCID}) [thesis advisor] } } @@ -2051,7 +2051,7 @@ not_intrinsic_resistant( \item{version_expertrules}{the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be "3.3", "3.2", or "3.1".} } \value{ -(internally) a \link{character} vector of column names, with additional class \code{"ab_selector"} +When used inside selecting or filtering, this returns a \link{character} vector of column names, with additional class \code{"ab_selector"}. When used individually, this returns an \link[=as.ab]{'ab' vector} with all possible antimicrobial that the function would be able to select or filter. } \description{ These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class or group (according to the \link{antibiotics} data set), without the need to define the columns or antibiotic abbreviations. @@ -2116,9 +2116,15 @@ All data sets in this \code{AMR} package (about microorganisms, antibiotics, SIR example_isolates +# you can use the selectors separately to retrieve all possible antimicrobials: +carbapenems() + + +# Though they are primarily intended to use for selections and filters. # Examples sections below are split into 'dplyr', 'base R', and 'data.table': \donttest{ +\dontrun{ # dplyr ------------------------------------------------------------------- library(dplyr, warn.conflicts = FALSE) @@ -2204,7 +2210,7 @@ y <- example_isolates \%>\% filter(carbapenems() == "R") z <- example_isolates \%>\% filter(if_all(carbapenems(), ~ .x == "R")) identical(x, y) && identical(y, z) - +} # base R ------------------------------------------------------------------ # select columns 'IPM' (imipenem) and 'MEM' (meropenem) @@ -5405,7 +5411,10 @@ geom_sir( facet_sir(facet = c("interpretation", "antibiotic"), nrow = NULL) -scale_y_percent(breaks = seq(0, 1, 0.1), limits = NULL) +scale_y_percent( + breaks = function(x) seq(0, max(x, na.rm = TRUE), 0.1), + limits = NULL +) scale_sir_colours(..., aesthetics = "fill") diff --git a/inst/tinytest/test-ab_selectors.R b/inst/tinytest/test-ab_selectors.R index 82de17bc..2ac03f18 100644 --- a/inst/tinytest/test-ab_selectors.R +++ b/inst/tinytest/test-ab_selectors.R @@ -53,6 +53,9 @@ expect_equal(ncol(example_isolates[, tetracyclines(), drop = FALSE]), 3, toleran expect_equal(ncol(example_isolates[, trimethoprims(), drop = FALSE]), 2, tolerance = 0.5) expect_equal(ncol(example_isolates[, ureidopenicillins(), drop = FALSE]), 1, tolerance = 0.5) +expect_message(carbapenems()) +expect_error(administrable_per_os()) + # Examples: # select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB' diff --git a/man/AMR.Rd b/man/AMR.Rd index 7f3fe4a3..eab3aabe 100644 --- a/man/AMR.Rd +++ b/man/AMR.Rd @@ -61,29 +61,29 @@ Authors: Other contributors: \itemize{ - \item Casper J. Albers (\href{https://orcid.org/0000-0002-9213-6743}{ORCID}) [thesis advisor] - \item Larisse Bolton (\href{https://orcid.org/0000-0001-7879-2173}{ORCID}) [contributor] - \item Peter Dutey-Magni (\href{https://orcid.org/0000-0002-8942-9836}{ORCID}) [contributor] - \item Judith M. Fonville [contributor] - \item Alex W. Friedrich (\href{https://orcid.org/0000-0003-4881-038X}{ORCID}) [thesis advisor] - \item Corinna Glasner (\href{https://orcid.org/0000-0003-1241-1328}{ORCID}) [thesis advisor] + \item Andrew P. Norgan (\href{https://orcid.org/0000-0002-2955-2066}{ORCID}) [contributor] + \item Anita Williams (\href{https://orcid.org/0000-0002-5295-8451}{ORCID}) [contributor] + \item Annick Lenglet (\href{https://orcid.org/0000-0003-2013-8405}{ORCID}) [contributor] + \item Anthony Underwood (\href{https://orcid.org/0000-0002-8547-4277}{ORCID}) [contributor] + \item Anton Mymrikov [contributor] + \item Bart C. Meijer [contributor] + \item Christian F. Luz (\href{https://orcid.org/0000-0001-5809-5995}{ORCID}) [contributor] + \item Dmytro Mykhailenko [contributor] \item Eric H. L. C. M. Hazenberg [contributor] \item Gwen Knight (\href{https://orcid.org/0000-0002-7263-9896}{ORCID}) [contributor] - \item Annick Lenglet (\href{https://orcid.org/0000-0003-2013-8405}{ORCID}) [contributor] - \item Christian F. Luz (\href{https://orcid.org/0000-0001-5809-5995}{ORCID}) [contributor] - \item Bart C. Meijer [contributor] - \item Dmytro Mykhailenko [contributor] - \item Anton Mymrikov [contributor] - \item Andrew P. Norgan (\href{https://orcid.org/0000-0002-2955-2066}{ORCID}) [contributor] - \item Sofia Ny (\href{https://orcid.org/0000-0002-2017-1363}{ORCID}) [contributor] - \item Matthew Saab [contributor] - \item Jonas Salm [contributor] - \item Javier Sanchez (\href{https://orcid.org/0000-0003-2605-8094}{ORCID}) [contributor] - \item Rogier P. Schade [contributor] - \item Bhanu N. M. Sinha (\href{https://orcid.org/0000-0003-1634-0010}{ORCID}) [thesis advisor] \item Jason Stull (\href{https://orcid.org/0000-0002-9028-8153}{ORCID}) [contributor] - \item Anthony Underwood (\href{https://orcid.org/0000-0002-8547-4277}{ORCID}) [contributor] - \item Anita Williams (\href{https://orcid.org/0000-0002-5295-8451}{ORCID}) [contributor] + \item Javier Sanchez (\href{https://orcid.org/0000-0003-2605-8094}{ORCID}) [contributor] + \item Jonas Salm [contributor] + \item Judith M. Fonville [contributor] + \item Larisse Bolton (\href{https://orcid.org/0000-0001-7879-2173}{ORCID}) [contributor] + \item Matthew Saab [contributor] + \item Peter Dutey-Magni (\href{https://orcid.org/0000-0002-8942-9836}{ORCID}) [contributor] + \item Rogier P. Schade [contributor] + \item Sofia Ny (\href{https://orcid.org/0000-0002-2017-1363}{ORCID}) [contributor] + \item Alex W. Friedrich (\href{https://orcid.org/0000-0003-4881-038X}{ORCID}) [thesis advisor] + \item Bhanu N. M. Sinha (\href{https://orcid.org/0000-0003-1634-0010}{ORCID}) [thesis advisor] + \item Casper J. Albers (\href{https://orcid.org/0000-0002-9213-6743}{ORCID}) [thesis advisor] + \item Corinna Glasner (\href{https://orcid.org/0000-0003-1241-1328}{ORCID}) [thesis advisor] } } diff --git a/man/antibiotic_class_selectors.Rd b/man/antibiotic_class_selectors.Rd index cd57e338..ffd48e25 100644 --- a/man/antibiotic_class_selectors.Rd +++ b/man/antibiotic_class_selectors.Rd @@ -124,7 +124,7 @@ not_intrinsic_resistant( \item{version_expertrules}{the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be "3.3", "3.2", or "3.1".} } \value{ -(internally) a \link{character} vector of column names, with additional class \code{"ab_selector"} +When used inside selecting or filtering, this returns a \link{character} vector of column names, with additional class \code{"ab_selector"}. When used individually, this returns an \link[=as.ab]{'ab' vector} with all possible antimicrobial that the function would be able to select or filter. } \description{ These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class or group (according to the \link{antibiotics} data set), without the need to define the columns or antibiotic abbreviations. @@ -189,9 +189,15 @@ All data sets in this \code{AMR} package (about microorganisms, antibiotics, SIR example_isolates +# you can use the selectors separately to retrieve all possible antimicrobials: +carbapenems() + + +# Though they are primarily intended to use for selections and filters. # Examples sections below are split into 'dplyr', 'base R', and 'data.table': \donttest{ +\dontrun{ # dplyr ------------------------------------------------------------------- library(dplyr, warn.conflicts = FALSE) @@ -277,7 +283,7 @@ y <- example_isolates \%>\% filter(carbapenems() == "R") z <- example_isolates \%>\% filter(if_all(carbapenems(), ~ .x == "R")) identical(x, y) && identical(y, z) - +} # base R ------------------------------------------------------------------ # select columns 'IPM' (imipenem) and 'MEM' (meropenem) diff --git a/man/ggplot_sir.Rd b/man/ggplot_sir.Rd index 052a2bb9..56b805d3 100644 --- a/man/ggplot_sir.Rd +++ b/man/ggplot_sir.Rd @@ -49,7 +49,10 @@ geom_sir( facet_sir(facet = c("interpretation", "antibiotic"), nrow = NULL) -scale_y_percent(breaks = seq(0, 1, 0.1), limits = NULL) +scale_y_percent( + breaks = function(x) seq(0, max(x, na.rm = TRUE), 0.1), + limits = NULL +) scale_sir_colours(..., aesthetics = "fill")