mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 02:03:04 +02:00
fix for scoped dplyr verbs
This commit is contained in:
@ -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`)
|
||||
}
|
||||
}
|
||||
|
@ -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(
|
||||
|
Reference in New Issue
Block a user