From a82552dd88c8a4a94fba84eac5694fa1d515d195 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Wed, 15 Feb 2023 17:37:49 +0100 Subject: [PATCH] fix for group selections --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/aa_helper_functions.R | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ca6e078b..11795c7c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.8.2.9129 +Version: 1.8.2.9130 Date: 2023-02-15 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index b6520b91..7bb3f380 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9129 +# AMR 1.8.2.9130 *(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)* diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index c01fe821..dcb5178f 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -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