diff --git a/DESCRIPTION b/DESCRIPTION index 6aa8d876..4dd863a2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.8.2.9024 -Date: 2022-10-20 +Version: 1.8.2.9027 +Date: 2022-10-21 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 470a1530..0bcd4481 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9024 +# AMR 1.8.2.9027 This version will eventually become v2.0! We're happy to reach a new major milestone soon! @@ -27,7 +27,7 @@ This version will eventually become v2.0! We're happy to reach a new major miles * Support for the following languages: Chinese, Greek, Japanese, Polish, Turkish and Ukrainian. We are very grateful for the valuable input by our colleagues from other countries. The `AMR` package is now available in 16 languages. The automatic language determination will give a note at start-up on systems in supported languages. * Our data sets are now also continually exported to Apache Feather and Apache Parquet formats. You can find more info [in this article on our website](https://msberends.github.io/AMR/articles/datasets.html). * Added confidence intervals in AMR calculation. This is now included in `rsi_df()` and `proportion_df()` and manually available as `rsi_confidence_interval()` -* Support for using antibiotic selectors in `dplyr::vars()`, such as in: `... %>% summarise_at(vars(aminoglycosides()), resistance)` +* Support for using antibiotic selectors in scoped `dplyr` verbs (worh or without `vars()`), such as in: `... %>% summarise_at(aminoglycosides(), resistance)` ### Changed * Fix for using `as.rsi()` on certain EUCAST breakpoints for MIC values diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index b1a456c3..478c2371 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -882,9 +882,9 @@ get_current_data <- function(arg_name, call) { return(env$x) } - } else if (!is.null(names(env)) && all(c(".tbl", ".vars", ".env") %in% names(env), na.rm = TRUE) && valid_df(env$`.tbl`)) { - # an element `.tbl` will be in the environment when using `dplyr::vars()` - # (e.g. in `dplyr::summarise_at()` or `dplyr::mutate_at()`) + } else if (!is.null(names(env)) && all(c(".tbl", ".vars", ".cols") %in% names(env), na.rm = TRUE) && valid_df(env$`.tbl`)) { + # an element `.tbl` will be in the environment when using scoped dplyr variants, with or without `dplyr::vars()` + # (e.g. `dplyr::summarise_at()` or `dplyr::mutate_at()`) return(env$`.tbl`) } } diff --git a/R/proportion.R b/R/proportion.R index ece78e0a..920fb89a 100755 --- a/R/proportion.R +++ b/R/proportion.R @@ -143,6 +143,18 @@ #' } #' if (require("dplyr")) { #' +#' # scoped dplyr verbs with antibiotic selectors +#' # (you could also use across() of course) +#' example_isolates %>% +#' group_by(ward) %>% +#' summarise_at( +#' c(aminoglycosides(), carbapenems()), +#' resistance +#' ) +#' +#' } +#' if (require("dplyr")) { +#' #' example_isolates %>% #' group_by(ward) %>% #' summarise( diff --git a/man/proportion.Rd b/man/proportion.Rd index 09c8b735..7b2a5df8 100644 --- a/man/proportion.Rd +++ b/man/proportion.Rd @@ -201,6 +201,18 @@ if (require("dplyr")) { ci_max = rsi_confidence_interval(CIP, side = "max"), ) +} +if (require("dplyr")) { + + # scoped dplyr verbs with antibiotic selectors + # (you could also use across() of course) + example_isolates \%>\% + group_by(ward) \%>\% + summarise_at( + c(aminoglycosides(), carbapenems()), + resistance + ) + } if (require("dplyr")) {