1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 18:01:50 +02:00

fix for group selections

This commit is contained in:
2023-02-15 17:37:49 +01:00
parent ef716f6ee3
commit a82552dd88
3 changed files with 7 additions and 5 deletions

View File

@ -900,12 +900,14 @@ get_current_data <- function(arg_name, call) {
# e.g. for `example_isolates %>% group_by(ward) %>% mutate(first = first_isolate(.))`
if (valid_df(env$data)) {
# support for dplyr 1.1.x
return(env$data[env$mask$current_rows(), , drop = FALSE])
df <- env$data
} else {
# support for dplyr 1.0.x
return(env$`.data`[env$mask$current_rows(), , drop = FALSE])
df <- env$`.data`
}
rows <- tryCatch(env$mask$current_rows(), error = function(e) seq_len(NROW(df)))
return(df[rows, , drop = FALSE])
# base R support ----
} else if (!is.null(env$`.Generic`)) {
# don't check `".Generic" %in% names(env)`, because in R < 3.2, `names(env)` is always NULL