From afc325c31466825ecac9f8ff459fe6614f3619e2 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Sun, 27 Dec 2020 20:32:40 +0100 Subject: [PATCH] (v1.4.0.9050) ab selectors base R --- DESCRIPTION | 2 +- NEWS.md | 3 ++- R/ab_class_selectors.R | 23 +++++++++++++------ R/first_isolate.R | 4 ++-- R/key_antibiotics.R | 4 ++-- R/mdro.R | 4 ++-- R/mo.R | 2 +- R/mo_property.R | 2 +- R/mo_source.R | 4 ++-- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 9 ++++---- docs/pkgdown.yml | 2 +- .../reference/antibiotic_class_selectors.html | 17 ++++++++++---- docs/reference/eucast_rules.html | 2 +- docs/reference/first_isolate.html | 10 ++++---- docs/reference/get_episode.html | 2 +- docs/reference/index.html | 2 +- docs/reference/key_antibiotics.html | 6 ++--- docs/reference/mdro.html | 6 ++--- docs/reference/mo_property.html | 4 ++-- docs/reference/resistance_predict.html | 4 ++-- docs/survey.html | 2 +- man/antibiotic_class_selectors.Rd | 12 +++++++--- man/first_isolate.Rd | 4 ++-- man/key_antibiotics.Rd | 4 ++-- man/mdro.Rd | 4 ++-- man/mo_property.Rd | 2 +- man/resistance_predict.Rd | 2 +- tests/testthat/test-zzz.R | 1 - 33 files changed, 88 insertions(+), 65 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7165b5215..39b438197 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.4.0.9049 +Version: 1.4.0.9050 Date: 2020-12-27 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 24bcf4673..d16b725b2 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.4.0.9049 +# AMR 1.4.0.9050 ## Last updated: 27 December 2020 ### New @@ -47,6 +47,7 @@ * Fix for printing class in tibbles when all values are `NA` * Fix for `mo_shortname()` when the input contains `NA` * If `as.mo()` takes more than 30 seconds, some suggestions will be done to improve speed +* Lost dependency on the `tidyselect` package for using antibiotic selectors such as `carbapenems()` and `aminoglycosides()` ### Other * All messages and warnings thrown by this package now break sentences on whole words diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R index caa9aead0..af4849640 100644 --- a/R/ab_class_selectors.R +++ b/R/ab_class_selectors.R @@ -25,11 +25,9 @@ #' Antibiotic class selectors #' -#' Use these selection helpers inside any function that allows [Tidyverse selection helpers](https://tidyselect.r-lib.org/reference/language.html), such as [`select()`][dplyr::select()] and [`pivot_longer()`][tidyr::pivot_longer()]. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. +#' These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. #' @inheritParams filter_ab_class #' @details All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the [antibiotics] data set. This means that a selector like e.g. [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. -#' -#' **N.B. These functions require the `tidyselect` package to be installed**, that comes with the `dplyr` package. An error will be thrown if the `tidyselect` package is not installed, or if the functions are used outside a function that allows [Tidyverse selection helpers](https://tidyselect.r-lib.org/reference/language.html) such as [`select()`][dplyr::select()] and [`pivot_longer()`][tidyr::pivot_longer()]`. #' @rdname antibiotic_class_selectors #' @seealso [filter_ab_class()] for the `filter()` equivalent. #' @name antibiotic_class_selectors @@ -37,6 +35,14 @@ #' @inheritSection AMR Reference data publicly available #' @inheritSection AMR Read more on our website! #' @examples +#' # `example_isolates` is a dataset available in the AMR package. +#' # See ?example_isolates. +#' +#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): +#' example_isolates[, c(carbapenems())] +#' # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB': +#' example_isolates[, c("mo", aminoglycosides())] +#' #' if (require("dplyr")) { #' #' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): @@ -151,10 +157,13 @@ ab_selector <- function(ab_class, function_name) { meet_criteria(ab_class, allow_class = "character", has_length = 1, .call_depth = 1) meet_criteria(function_name, allow_class = "character", has_length = 1, .call_depth = 1) - peek_vars_tidyselect <- import_fn("peek_vars", "tidyselect") - vars_vct <- peek_vars_tidyselect(fn = function_name) - vars_df <- data.frame(as.list(vars_vct), stringsAsFactors = FALSE)[1, , drop = FALSE] - colnames(vars_df) <- vars_vct + for (i in seq_len(length(sys.frames()))) { + vars_df <- sys.frames()[[i]]$x + if (!is.null(vars_df) && is.data.frame(vars_df)) { + break + } + } + stop_ifnot(is.data.frame(vars_df), "the ", function_name, "() function must be used inside dplyr verbs or a data.frame call.") ab_in_data <- get_column_abx(vars_df, info = FALSE) if (length(ab_in_data) == 0) { diff --git a/R/first_isolate.R b/R/first_isolate.R index 1037d3af8..950f345fd 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -27,7 +27,7 @@ #' #' Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use [is_new_episode()] that also supports grouping with the `dplyr` package. #' @inheritSection lifecycle Stable lifecycle -#' @param x a [data.frame] containing isolates. Can be omitted when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()]. +#' @param x a [data.frame] containing isolates. Can be left blank when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()]. #' @param col_date column name of the result date (or date that is was received on the lab), defaults to the first column with a date class #' @param col_patient_id column name of the unique IDs of the patients, defaults to the first column that starts with 'patient' or 'patid' (case insensitive) #' @param col_mo column name of the IDs of the microorganisms (see [as.mo()]), defaults to the first column of class [`mo`]. Values will be coerced using [as.mo()]. @@ -46,7 +46,7 @@ #' @param include_unknown logical to determine whether 'unknown' microorganisms should be included too, i.e. microbial code `"UNKNOWN"`, which defaults to `FALSE`. For WHONET users, this means that all records with organism code `"con"` (*contamination*) will be excluded at default. Isolates with a microbial ID of `NA` will always be excluded as first isolate. #' @param ... arguments passed on to [first_isolate()] when using [filter_first_isolate()], or arguments passed on to [key_antibiotics()] when using [filter_first_weighted_isolate()] #' @details -#' These functions are context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be omitted, please see *Examples*. +#' These functions are context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be left blank, please see *Examples*. #' #' The [first_isolate()] function is a wrapper around the [is_new_episode()] function, but more efficient for data sets containing microorganism codes or names. #' diff --git a/R/key_antibiotics.R b/R/key_antibiotics.R index 7cfe13a4f..37cc1667c 100755 --- a/R/key_antibiotics.R +++ b/R/key_antibiotics.R @@ -27,7 +27,7 @@ #' #' These function can be used to determine first isolates (see [first_isolate()]). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first *weighted* isolates. #' @inheritSection lifecycle Stable lifecycle -#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be omitted when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. +#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. #' @param y,z character vectors to compare #' @inheritParams first_isolate #' @param universal_1,universal_2,universal_3,universal_4,universal_5,universal_6 column names of **broad-spectrum** antibiotics, case-insensitive. See details for which antibiotics will be used at default (which are guessed with [guess_ab_col()]). @@ -36,7 +36,7 @@ #' @param warnings give a warning about missing antibiotic columns (they will be ignored) #' @param ... other arguments passed on to functions #' @details -#' The [key_antibiotics()] function is context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be omitted, please see *Examples*. +#' The [key_antibiotics()] function is context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be left blank, please see *Examples*. #' #' The function [key_antibiotics()] returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using [key_antibiotics_equal()], to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (`"."`) by [key_antibiotics()] and ignored by [key_antibiotics_equal()]. #' diff --git a/R/mdro.R b/R/mdro.R index 6c035d2fb..5b0388b5e 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -27,7 +27,7 @@ #' #' Determine which isolates are multidrug-resistant organisms (MDRO) according to international and national guidelines. #' @inheritSection lifecycle Stable lifecycle -#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be omitted when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()]. +#' @param x a [data.frame] with antibiotics columns, like `AMX` or `amox`. Can be left blank when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()]. #' @param guideline a specific guideline to follow. When left empty, the publication by Magiorakos *et al.* (2012, Clinical Microbiology and Infection) will be followed, please see *Details*. #' @inheritParams eucast_rules #' @param pct_required_classes minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for *S. aureus*. Setting this `pct_required_classes` argument to `0.5` (default) means that for every *S. aureus* isolate at least 8 different classes must be available. Any lower number of available classes will return `NA` for that isolate. @@ -35,7 +35,7 @@ #' @param verbose a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not. #' @inheritSection eucast_rules Antibiotics #' @details -#' These functions are context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be omitted, please see *Examples*. +#' These functions are context-aware when used inside `dplyr` verbs, such as `filter()`, `mutate()` and `summarise()`. This means that then the `x` argument can be left blank, please see *Examples*. #' #' For the `pct_required_classes` argument, values above 1 will be divided by 100. This is to support both fractions (`0.75` or `3/4`) and percentages (`75`). #' diff --git a/R/mo.R b/R/mo.R index 05c798e58..b90954a00 100755 --- a/R/mo.R +++ b/R/mo.R @@ -438,7 +438,7 @@ exec_as.mo <- function(x, strip_whitespace <- function(x, dyslexia_mode) { # all whitespaces (tab, new lines, etc.) should be one space - # and spaces before and after should be omitted + # and spaces before and after should be left blank trimmed <- trimws2(x) # also, make sure the trailing and leading characters are a-z or 0-9 # in case of non-regex diff --git a/R/mo_property.R b/R/mo_property.R index 9b6509e2c..6599ca3d9 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -27,7 +27,7 @@ #' #' Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. Please see *Examples*. #' @inheritSection lifecycle Stable lifecycle -#' @param x any character (vector) that can be coerced to a valid microorganism code with [as.mo()]. Can be omitted for auto-guessing the column containing microorganism codes when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()], please see *Examples*. +#' @param x any character (vector) that can be coerced to a valid microorganism code with [as.mo()]. Can be left blank for auto-guessing the column containing microorganism codes when used inside `dplyr` verbs, such as [`filter()`][dplyr::filter()], [`mutate()`][dplyr::mutate()] and [`summarise()`][dplyr::summarise()], please see *Examples*. #' @param property one of the column names of the [microorganisms] data set: `r paste0('"``', colnames(microorganisms), '\``"', collapse = ", ")`, or must be `"shortname"` #' @param language language of the returned text, defaults to system language (see [get_locale()]) and can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`, see [translate]. Also used to translate text like "no growth". Use `language = NULL` or `language = ""` to prevent translation. #' @param ... other arguments passed on to [as.mo()], such as 'allow_uncertain' and 'ignore_pattern' diff --git a/R/mo_source.R b/R/mo_source.R index 6c9cacf68..5f0e2eca4 100644 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -149,8 +149,8 @@ set_mo_source <- function(path, destination = getOption("AMR_mo_source", "~/mo_s } else if (path %like% "[.]xlsx?$") { # is Excel file (old or new) - read_excel <- import_fn("read_excel", "readxl") - df <- read_excel(path) + stop_ifnot_installed("readxl") + df <- readxl::read_excel(path) } else if (path %like% "[.]tsv$") { df <- utils::read.table(header = TRUE, sep = "\t", stringsAsFactors = FALSE) diff --git a/docs/404.html b/docs/404.html index 2fcd8e667..88d51b119 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9049 + 1.4.0.9050 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 0ebd4ab28..079f10abb 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9049 + 1.4.0.9050 diff --git a/docs/articles/index.html b/docs/articles/index.html index eb22e1876..46a278da0 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9049 + 1.4.0.9050 diff --git a/docs/authors.html b/docs/authors.html index 691261d55..9b0624c40 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9049 + 1.4.0.9050 diff --git a/docs/index.html b/docs/index.html index 849cadace..4ff7f4f59 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.4.0.9049 + 1.4.0.9050 diff --git a/docs/news/index.html b/docs/news/index.html index 35b24adff..f85a23324 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9049 + 1.4.0.9050 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

-AMR 1.4.0.9049 Unreleased +
+

+AMR 1.4.0.9050 Unreleased

@@ -306,6 +306,7 @@
  • Fix for printing class in tibbles when all values are NA

  • Fix for mo_shortname() when the input contains NA

  • If as.mo() takes more than 30 seconds, some suggestions will be done to improve speed

  • +
  • Lost dependency on the tidyselect package for using antibiotic selectors such as carbapenems() and aminoglycosides()

  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 709059a9a..d48e1c1d7 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2020-12-27T14:06Z +last_built: 2020-12-27T19:32Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/antibiotic_class_selectors.html b/docs/reference/antibiotic_class_selectors.html index cff9656ca..cf10b3a55 100644 --- a/docs/reference/antibiotic_class_selectors.html +++ b/docs/reference/antibiotic_class_selectors.html @@ -49,7 +49,7 @@ - + @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9046 + 1.4.0.9050
    @@ -239,7 +239,7 @@
    -

    Use these selection helpers inside any function that allows Tidyverse selection helpers, such as select() and pivot_longer(). They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.

    +

    These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.

    ab_class(ab_class)
    @@ -282,7 +282,6 @@
         

    Details

    All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the antibiotics data set. This means that a selector like e.g. aminoglycosides() will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.

    -

    N.B. These functions require the tidyselect package to be installed, that comes with the dplyr package. An error will be thrown if the tidyselect package is not installed, or if the functions are used outside a function that allows Tidyverse selection helpers such as select() and pivot_longer()`.

    Reference data publicly available

    @@ -298,7 +297,15 @@

    filter_ab_class() for the filter() equivalent.

    Examples

    -
    if (require("dplyr")) {
    +    
    # `example_isolates` is a dataset available in the AMR package.
    +# See ?example_isolates.
    +
    +# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
    +example_isolates[, c(carbapenems())]
    +# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
    +example_isolates[, c("mo", aminoglycosides())]
    +
    +if (require("dplyr")) {
     
       # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
       example_isolates %>% 
    diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html
    index a8c2e1405..ea173fc78 100644
    --- a/docs/reference/eucast_rules.html
    +++ b/docs/reference/eucast_rules.html
    @@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
           
           
             AMR (for R)
    -        1.4.0.9048
    +        1.4.0.9050
           
         

    diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 8e8e11b98..e1dc82be1 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9046 + 1.4.0.9050 @@ -239,7 +239,7 @@
    -

    Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use is_new_episode() that also supports grouping with the dplyr package.

    +

    Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use is_new_episode() that also supports grouping with the dplyr package.

    first_isolate(
    @@ -285,7 +285,7 @@
         
         
           x
    -      

    a data.frame containing isolates. Can be omitted when used inside dplyr verbs, such as filter(), mutate() and summarise().

    +

    a data.frame containing isolates. Can be left blank when used inside dplyr verbs, such as filter(), mutate() and summarise().

    col_date @@ -366,8 +366,8 @@

    A logical vector

    Details

    -

    These functions are context-aware when used inside dplyr verbs, such as filter(), mutate() and summarise(). This means that then the x argument can be omitted, please see Examples.

    -

    The first_isolate() function is a wrapper around the is_new_episode() function, but more efficient for data sets containing microorganism codes or names.

    +

    These functions are context-aware when used inside dplyr verbs, such as filter(), mutate() and summarise(). This means that then the x argument can be left blank, please see Examples.

    +

    The first_isolate() function is a wrapper around the is_new_episode() function, but more efficient for data sets containing microorganism codes or names.

    All isolates with a microbial ID of NA will be excluded as first isolate.

    Why this is so important

    diff --git a/docs/reference/get_episode.html b/docs/reference/get_episode.html index 2c7c1684e..f780af553 100644 --- a/docs/reference/get_episode.html +++ b/docs/reference/get_episode.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9048 + 1.4.0.9050 diff --git a/docs/reference/index.html b/docs/reference/index.html index a338ac6b5..85b27cb87 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9049 + 1.4.0.9050 diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 93209875f..6e95e09b4 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9046 + 1.4.0.9050 @@ -281,7 +281,7 @@ x -

    a data.frame with antibiotics columns, like AMX or amox. Can be omitted when used inside dplyr verbs, such as filter(), mutate() and summarise().

    +

    a data.frame with antibiotics columns, like AMX or amox. Can be left blank when used inside dplyr verbs, such as filter(), mutate() and summarise().

    col_mo @@ -331,7 +331,7 @@

    Details

    -

    The key_antibiotics() function is context-aware when used inside dplyr verbs, such as filter(), mutate() and summarise(). This means that then the x argument can be omitted, please see Examples.

    +

    The key_antibiotics() function is context-aware when used inside dplyr verbs, such as filter(), mutate() and summarise(). This means that then the x argument can be left blank, please see Examples.

    The function key_antibiotics() returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using key_antibiotics_equal(), to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (".") by key_antibiotics() and ignored by key_antibiotics_equal().

    The first_isolate() function only uses this function on the same microbial species from the same patient. Using this, e.g. an MRSA will be included after a susceptible S. aureus (MSSA) is found within the same patient episode. Without key antibiotic comparison it would not. See first_isolate() for more info.

    At default, the antibiotics that are used for Gram-positive bacteria are:

      diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index c30c713a0..0bd0d11a1 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9046 + 1.4.0.9050 @@ -268,7 +268,7 @@ x -

      a data.frame with antibiotics columns, like AMX or amox. Can be omitted when used inside dplyr verbs, such as filter(), mutate() and summarise().

      +

      a data.frame with antibiotics columns, like AMX or amox. Can be left blank when used inside dplyr verbs, such as filter(), mutate() and summarise().

      guideline @@ -319,7 +319,7 @@ Ordered factor with levels Details -

      These functions are context-aware when used inside dplyr verbs, such as filter(), mutate() and summarise(). This means that then the x argument can be omitted, please see Examples.

      +

      These functions are context-aware when used inside dplyr verbs, such as filter(), mutate() and summarise(). This means that then the x argument can be left blank, please see Examples.

      For the pct_required_classes argument, values above 1 will be divided by 100. This is to support both fractions (0.75 or 3/4) and percentages (75).

      Currently supported guidelines are (case-insensitive):

      • guideline = "CMI2012" (default)

        diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index 79617975d..766dda357 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9046 + 1.4.0.9050 @@ -301,7 +301,7 @@ x -

        any character (vector) that can be coerced to a valid microorganism code with as.mo(). Can be omitted for auto-guessing the column containing microorganism codes when used inside dplyr verbs, such as filter(), mutate() and summarise(), please see Examples.

        +

        any character (vector) that can be coerced to a valid microorganism code with as.mo(). Can be left blank for auto-guessing the column containing microorganism codes when used inside dplyr verbs, such as filter(), mutate() and summarise(), please see Examples.

        language diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index 31fdd23ad..637bfe719 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9046 + 1.4.0.9050 @@ -287,7 +287,7 @@ x -

        a data.frame containing isolates. Can be omitted when used inside dplyr verbs, such as filter(), mutate() and summarise().

        +

        a data.frame containing isolates. Can be left blank when used inside dplyr verbs, such as filter(), mutate() and summarise().

        col_ab diff --git a/docs/survey.html b/docs/survey.html index 56eb72526..37f991a22 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9049 + 1.4.0.9050 diff --git a/man/antibiotic_class_selectors.Rd b/man/antibiotic_class_selectors.Rd index 89a8ab852..97f6d0a7b 100644 --- a/man/antibiotic_class_selectors.Rd +++ b/man/antibiotic_class_selectors.Rd @@ -50,12 +50,10 @@ tetracyclines() \item{ab_class}{an antimicrobial class, like \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.} } \description{ -Use these selection helpers inside any function that allows \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selection helpers}, such as \code{\link[dplyr:select]{select()}} and \code{\link[tidyr:pivot_longer]{pivot_longer()}}. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. +These functions help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. } \details{ All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.) in the \link{antibiotics} data set. This means that a selector like e.g. \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc. - -\strong{N.B. These functions require the \code{tidyselect} package to be installed}, that comes with the \code{dplyr} package. An error will be thrown if the \code{tidyselect} package is not installed, or if the functions are used outside a function that allows \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selection helpers} such as \code{\link[dplyr:select]{select()}} and \code{\link[tidyr:pivot_longer]{pivot_longer()}}`. } \section{Reference data publicly available}{ @@ -68,6 +66,14 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/ } \examples{ +# `example_isolates` is a dataset available in the AMR package. +# See ?example_isolates. + +# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): +example_isolates[, c(carbapenems())] +# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB': +example_isolates[, c("mo", aminoglycosides())] + if (require("dplyr")) { # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem): diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index 80de1d672..b2a7bc87c 100755 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -50,7 +50,7 @@ filter_first_weighted_isolate( ) } \arguments{ -\item{x}{a \link{data.frame} containing isolates. Can be omitted when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} +\item{x}{a \link{data.frame} containing isolates. Can be left blank when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} \item{col_date}{column name of the result date (or date that is was received on the lab), defaults to the first column with a date class} @@ -93,7 +93,7 @@ A \code{\link{logical}} vector Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use \code{\link[=is_new_episode]{is_new_episode()}} that also supports grouping with the \code{dplyr} package. } \details{ -These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be omitted, please see \emph{Examples}. +These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be left blank, please see \emph{Examples}. The \code{\link[=first_isolate]{first_isolate()}} function is a wrapper around the \code{\link[=is_new_episode]{is_new_episode()}} function, but more efficient for data sets containing microorganism codes or names. diff --git a/man/key_antibiotics.Rd b/man/key_antibiotics.Rd index aedeebf36..4ada8def3 100755 --- a/man/key_antibiotics.Rd +++ b/man/key_antibiotics.Rd @@ -40,7 +40,7 @@ key_antibiotics_equal( ) } \arguments{ -\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be omitted when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}.} +\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be left blank when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}.} \item{col_mo}{column name of the IDs of the microorganisms (see \code{\link[=as.mo]{as.mo()}}), defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.} @@ -68,7 +68,7 @@ key_antibiotics_equal( These function can be used to determine first isolates (see \code{\link[=first_isolate]{first_isolate()}}). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first \emph{weighted} isolates. } \details{ -The \code{\link[=key_antibiotics]{key_antibiotics()}} function is context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be omitted, please see \emph{Examples}. +The \code{\link[=key_antibiotics]{key_antibiotics()}} function is context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be left blank, please see \emph{Examples}. The function \code{\link[=key_antibiotics]{key_antibiotics()}} returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using \code{\link[=key_antibiotics_equal]{key_antibiotics_equal()}}, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (\code{"."}) by \code{\link[=key_antibiotics]{key_antibiotics()}} and ignored by \code{\link[=key_antibiotics_equal]{key_antibiotics_equal()}}. diff --git a/man/mdro.Rd b/man/mdro.Rd index 0bc70dd81..01f056efe 100644 --- a/man/mdro.Rd +++ b/man/mdro.Rd @@ -40,7 +40,7 @@ mdr_cmi2012(x, guideline = "CMI2012", ...) eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...) } \arguments{ -\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be omitted when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} +\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be left blank when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} \item{guideline}{a specific guideline to follow. When left empty, the publication by Magiorakos \emph{et al.} (2012, Clinical Microbiology and Infection) will be followed, please see \emph{Details}.} @@ -72,7 +72,7 @@ Ordered \link{factor} with levels \code{Negative} < \verb{Positive, unconfirmed} Determine which isolates are multidrug-resistant organisms (MDRO) according to international and national guidelines. } \details{ -These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be omitted, please see \emph{Examples}. +These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} argument can be left blank, please see \emph{Examples}. For the \code{pct_required_classes} argument, values above 1 will be divided by 100. This is to support both fractions (\code{0.75} or \code{3/4}) and percentages (\code{75}). diff --git a/man/mo_property.Rd b/man/mo_property.Rd index 42b6cf333..8dd1cb03d 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -85,7 +85,7 @@ mo_url(x, open = FALSE, language = get_locale(), ...) mo_property(x, property = "fullname", language = get_locale(), ...) } \arguments{ -\item{x}{any character (vector) that can be coerced to a valid microorganism code with \code{\link[=as.mo]{as.mo()}}. Can be omitted for auto-guessing the column containing microorganism codes when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}, please see \emph{Examples}.} +\item{x}{any character (vector) that can be coerced to a valid microorganism code with \code{\link[=as.mo]{as.mo()}}. Can be left blank for auto-guessing the column containing microorganism codes when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}, please see \emph{Examples}.} \item{language}{language of the returned text, defaults to system language (see \code{\link[=get_locale]{get_locale()}}) and can be overwritten by setting the option \code{AMR_locale}, e.g. \code{options(AMR_locale = "de")}, see \link{translate}. Also used to translate text like "no growth". Use \code{language = NULL} or \code{language = ""} to prevent translation.} diff --git a/man/resistance_predict.Rd b/man/resistance_predict.Rd index 6fec8877f..00bce8887 100644 --- a/man/resistance_predict.Rd +++ b/man/resistance_predict.Rd @@ -47,7 +47,7 @@ ggplot_rsi_predict( ) } \arguments{ -\item{x}{a \link{data.frame} containing isolates. Can be omitted when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} +\item{x}{a \link{data.frame} containing isolates. Can be left blank when used inside \code{dplyr} verbs, such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.} \item{col_ab}{column name of \code{x} containing antimicrobial interpretations (\code{"R"}, \code{"I"} and \code{"S"})} diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index a62f707f5..30500af12 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -51,7 +51,6 @@ test_that("imports work", { "insertText" = "rstudioapi", "left_join" = "dplyr", "new_pillar_shaft_simple" = "pillar", - "peek_vars" = "tidyselect", "read_excel" = "readxl", "read_html" = "xml2", "right_join" = "dplyr",