fix for scoped dplyr verbs

This commit is contained in:
dr. M.S. (Matthijs) Berends 2022-10-21 15:13:19 +02:00
parent 3102beb241
commit 4bebba3610
5 changed files with 31 additions and 7 deletions

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 1.8.2.9024 Version: 1.8.2.9027
Date: 2022-10-20 Date: 2022-10-21
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)
data analysis and to work with microbial and antimicrobial properties by data analysis and to work with microbial and antimicrobial properties by

View File

@ -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! 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. * 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). * 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()` * 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 ### Changed
* Fix for using `as.rsi()` on certain EUCAST breakpoints for MIC values * Fix for using `as.rsi()` on certain EUCAST breakpoints for MIC values

View File

@ -882,9 +882,9 @@ get_current_data <- function(arg_name, call) {
return(env$x) return(env$x)
} }
} else if (!is.null(names(env)) && all(c(".tbl", ".vars", ".env") %in% names(env), na.rm = TRUE) && valid_df(env$`.tbl`)) { } 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 `dplyr::vars()` # an element `.tbl` will be in the environment when using scoped dplyr variants, with or without `dplyr::vars()`
# (e.g. in `dplyr::summarise_at()` or `dplyr::mutate_at()`) # (e.g. `dplyr::summarise_at()` or `dplyr::mutate_at()`)
return(env$`.tbl`) return(env$`.tbl`)
} }
} }

View File

@ -143,6 +143,18 @@
#' } #' }
#' if (require("dplyr")) { #' 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 %>% #' example_isolates %>%
#' group_by(ward) %>% #' group_by(ward) %>%
#' summarise( #' summarise(

View File

@ -201,6 +201,18 @@ if (require("dplyr")) {
ci_max = rsi_confidence_interval(CIP, side = "max"), 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")) { if (require("dplyr")) {