1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 11:51:59 +02:00

(v1.7.1.9037) dplyr grouping fix on windows?

This commit is contained in:
2021-08-31 17:06:44 +02:00
parent 953dfac9e5
commit bcab74fb6d
9 changed files with 38 additions and 49 deletions

View File

@ -728,18 +728,14 @@ meet_criteria <- function(object,
return(invisible())
}
get_current_data <- function(arg_name, call, requires_cur_data = FALSE) {
get_current_data <- function(arg_name, call) {
# try dplyr::cur_data_all() first to support dplyr groups
# only useful for e.g. dplyr::filter(), dplyr::mutate() and dplyr::summarise()
# not useful (throws error) with e.g. dplyr::select() - but that will be caught later in this function
cur_data_all <- import_fn("cur_data_all", "dplyr", error_on_fail = FALSE)
if (isTRUE(requires_cur_data)) {
print(cur_data_all())
}
if (!is.null(cur_data_all)) {
out <- tryCatch(cur_data_all(), error = function(e) NULL)
if (is.data.frame(out)) {
message("==> RETURNING cur_data_all()")
return(structure(out, type = "dplyr_cur_data_all"))
}
}
@ -752,17 +748,14 @@ get_current_data <- function(arg_name, call, requires_cur_data = FALSE) {
if (!is.null(env$`.data`) && is.data.frame(env$`.data`)) {
# an element `.data` will be in the environment when using `dplyr::select()`
# (but not when using `dplyr::filter()`, `dplyr::mutate()` or `dplyr::summarise()`)
message("==> RETURNING dplyr_selector")
return(structure(env$`.data`, type = "dplyr_selector"))
} else if (!is.null(env$xx) && is.data.frame(env$xx)) {
# an element `xx` will be in the environment for rows + cols, e.g. `example_isolates[c(1:3), carbapenems()]`
message("==> RETURNING base_R 1")
return(structure(env$xx, type = "base_R"))
} else if (!is.null(env$x) && is.data.frame(env$x)) {
# an element `x` will be in the environment for only cols, e.g. `example_isolates[, carbapenems()]`
message("==> RETURNING base_R 2")
return(structure(env$x, type = "base_R"))
}
}