(v1.7.1.9035) dplyr grouping fix on windows?

This commit is contained in:
dr. M.S. (Matthijs) Berends 2021-08-30 15:43:12 +02:00
parent af23f91e5c
commit 986bd826ee
9 changed files with 19 additions and 15 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 1.7.1.9033 Version: 1.7.1.9035
Date: 2021-08-30 Date: 2021-08-30
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)

View File

@ -1,4 +1,4 @@
# `AMR` 1.7.1.9033 # `AMR` 1.7.1.9035
## <small>Last updated: 30 August 2021</small> ## <small>Last updated: 30 August 2021</small>
### Breaking changes ### Breaking changes

View File

@ -298,7 +298,7 @@ stop_ifnot_installed <- function(package) {
pkg_is_available <- function(pkg, also_load = TRUE) { pkg_is_available <- function(pkg, also_load = TRUE) {
if (also_load == TRUE) { if (also_load == TRUE) {
out <- suppressWarnings(require(pkg, character.only = TRUE, warn.conflicts = FALSE, quietly = TRUE)) out <- suppressWarnings(require(pkg, character.only = TRUE, warn.conflicts = FALSE))
} else { } else {
out <- requireNamespace(pkg, quietly = TRUE) out <- requireNamespace(pkg, quietly = TRUE)
} }
@ -728,11 +728,14 @@ meet_criteria <- function(object,
return(invisible()) return(invisible())
} }
get_current_data <- function(arg_name, call) { get_current_data <- function(arg_name, call, requires_cur_data = FALSE) {
# try dplyr::cur_data_all() first to support dplyr groups # try dplyr::cur_data_all() first to support dplyr groups
# only useful for e.g. dplyr::filter(), dplyr::mutate() and dplyr::summarise() # 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 # 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) 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)) { if (!is.null(cur_data_all)) {
out <- tryCatch(cur_data_all(), error = function(e) NULL) out <- tryCatch(cur_data_all(), error = function(e) NULL)
if (is.data.frame(out)) { if (is.data.frame(out)) {

View File

@ -204,7 +204,7 @@ first_isolate <- function(x = NULL,
if (is_null_or_grouped_tbl(x)) { if (is_null_or_grouped_tbl(x)) {
# when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all())
# is also fix for using a grouped df as input (a dot as first argument) # is also fix for using a grouped df as input (a dot as first argument)
x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) x <- tryCatch(get_current_data(arg_name = "x", call = -2, requires_cur_data = list(...)$require_cur_data), error = function(e) x)
} }
meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0 meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0
meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x))

Binary file not shown.

View File

@ -44,7 +44,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9033</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9035</span>
</span> </span>
</div> </div>
@ -1256,7 +1256,7 @@ If you are reading this page from within R, please <a href="https://msberends.gi
<footer><div class="copyright"> <footer><div class="copyright">
<p></p> <p></p>
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/" class="external-link external-link">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/" class="external-link external-link">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/" class="external-link external-link">Alexander W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/" class="external-link external-link">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.j.albers/" class="external-link external-link">Casper J. Albers</a>, <a href="https://www.rug.nl/staff/c.glasner/" class="external-link external-link">Corinna Glasner</a>.</p> <p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/" class="external-link external-link">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/" class="external-link external-link">Christian F. Luz</a>.</p>
</div> </div>
<div class="pkgdown"> <div class="pkgdown">

View File

@ -92,7 +92,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9033</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9035</span>
</span> </span>
</div> </div>
@ -240,9 +240,9 @@
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small> <small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div> </div>
<div id="amr-1719033" class="section level1"> <div id="amr-1719035" class="section level1">
<h1 class="page-header" data-toc-text="1.7.1.9033"> <h1 class="page-header" data-toc-text="1.7.1.9035">
<a href="#amr-1719033" class="anchor" aria-hidden="true"></a><small> Unreleased </small><code>AMR</code> 1.7.1.9033</h1> <a href="#amr-1719035" class="anchor" aria-hidden="true"></a><small> Unreleased </small><code>AMR</code> 1.7.1.9035</h1>
<div id="last-updated-30-august-2021" class="section level2"> <div id="last-updated-30-august-2021" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
<a href="#last-updated-30-august-2021" class="anchor" aria-hidden="true"></a><small>Last updated: 30 August 2021</small> <a href="#last-updated-30-august-2021" class="anchor" aria-hidden="true"></a><small>Last updated: 30 August 2021</small>
@ -2044,7 +2044,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<footer> <footer>
<div class="copyright"> <div class="copyright">
<p><p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/" class="external-link">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/" class="external-link">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/" class="external-link">Alexander W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/" class="external-link">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.j.albers/" class="external-link">Casper J. Albers</a>, <a href="https://www.rug.nl/staff/c.glasner/" class="external-link">Corinna Glasner</a>.</p></p> <p><p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/" class="external-link">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/" class="external-link">Christian F. Luz</a>.</p></p>
</div> </div>
<div class="pkgdown"> <div class="pkgdown">

View File

@ -133,8 +133,8 @@ if (AMR:::pkg_is_available("dplyr")) {
first_isolate(info = TRUE)) first_isolate(info = TRUE))
# groups # groups
x <- example_isolates %>% group_by(ward_icu) %>% mutate(first = first_isolate()) x <- example_isolates %>% group_by(ward_icu) %>% mutate(first = first_isolate(require_cur_data = TRUE))
y <- example_isolates %>% group_by(ward_icu) %>% mutate(first = first_isolate(.)) y <- example_isolates %>% group_by(ward_icu) %>% mutate(first = first_isolate(., require_cur_data = TRUE))
expect_identical(x, y) expect_identical(x, y)
} }

View File

@ -29,11 +29,12 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) {
.libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths())) .libPaths(c(Sys.getenv("R_LIBS_USER_GH_ACTIONS"), .libPaths()))
if (AMR:::pkg_is_available("tinytest")) { if (AMR:::pkg_is_available("tinytest")) {
library(AMR) library(AMR)
out <- test_package("AMR", out <- test_package("AMR",
testdir = ifelse(AMR:::dir.exists("inst/tinytest"), testdir = ifelse(AMR:::dir.exists("inst/tinytest"),
"inst/tinytest", "inst/tinytest",
"tinytest"), "tinytest"),
verbose = 99, verbose = 99,
pattern = "first.*\\.[rR]$",
color = FALSE) color = FALSE)
cat("SUMMARY:\n") cat("SUMMARY:\n")
print(summary(out)) print(summary(out))