From 7d190603b9d7a778b7a6682aba5aee7f45f7ef85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sun, 30 Jun 2024 18:48:51 +0200 Subject: [PATCH 1/5] Create quosures in `tally_n()` --- R/count-tally.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/count-tally.R b/R/count-tally.R index f5c94c959f..75bd8378ba 100644 --- a/R/count-tally.R +++ b/R/count-tally.R @@ -213,9 +213,9 @@ tally_n <- function(x, wt) { } if (quo_is_null(wt)) { - expr(n()) + new_quosure(expr(n()), asNamespace("dplyr")) } else { - expr(sum(!!wt, na.rm = TRUE)) + new_quosure(expr(sum(!!wt, na.rm = TRUE)), quo_get_env(wt)) } } From f5ddcea8e1dc80eaf02b927178722a678376af5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 17 Nov 2025 22:26:38 +0100 Subject: [PATCH 2/5] Update R/count-tally.R --- R/count-tally.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/count-tally.R b/R/count-tally.R index 75bd8378ba..01c3900e60 100644 --- a/R/count-tally.R +++ b/R/count-tally.R @@ -215,7 +215,7 @@ tally_n <- function(x, wt) { if (quo_is_null(wt)) { new_quosure(expr(n()), asNamespace("dplyr")) } else { - new_quosure(expr(sum(!!wt, na.rm = TRUE)), quo_get_env(wt)) + new_quosure(expr(sum(!!wt, na.rm = TRUE)), baseenv()) } } From fb7fdf801668fe0e82d27e3c34b532c43215e50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 18 Nov 2025 00:00:38 +0100 Subject: [PATCH 3/5] Use simple expressions --- R/count-tally.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/count-tally.R b/R/count-tally.R index 01c3900e60..9078c28d17 100644 --- a/R/count-tally.R +++ b/R/count-tally.R @@ -213,9 +213,9 @@ tally_n <- function(x, wt) { } if (quo_is_null(wt)) { - new_quosure(expr(n()), asNamespace("dplyr")) + expr(dplyr::n()) } else { - new_quosure(expr(sum(!!wt, na.rm = TRUE)), baseenv()) + expr(base::sum(!!wt, na.rm = TRUE)) } } From a95d032a79d7fa7e9f5cc9b57f14350f0ce993b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 18 Nov 2025 00:29:23 +0100 Subject: [PATCH 4/5] Snapshots --- tests/testthat/_snaps/count-tally.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/_snaps/count-tally.md b/tests/testthat/_snaps/count-tally.md index a026cf0dcc..ad66d21743 100644 --- a/tests/testthat/_snaps/count-tally.md +++ b/tests/testthat/_snaps/count-tally.md @@ -55,7 +55,7 @@ Output Error in `count()`: - i In argument: `n = sum(1 + "", na.rm = TRUE)`. + i In argument: `n = base::sum(1 + "", na.rm = TRUE)`. Caused by error in `1 + ""`: ! non-numeric argument to binary operator @@ -84,7 +84,7 @@ Output Error in `tally()`: - i In argument: `n = sum(1 + "", na.rm = TRUE)`. + i In argument: `n = base::sum(1 + "", na.rm = TRUE)`. Caused by error in `1 + ""`: ! non-numeric argument to binary operator @@ -143,7 +143,7 @@ Output Error in `add_count()`: - i In argument: `n = sum(1 + "", na.rm = TRUE)`. + i In argument: `n = base::sum(1 + "", na.rm = TRUE)`. Caused by error in `1 + ""`: ! non-numeric argument to binary operator @@ -154,7 +154,7 @@ Output Error in `add_tally()`: - i In argument: `n = sum(1 + "", na.rm = TRUE)`. + i In argument: `n = base::sum(1 + "", na.rm = TRUE)`. Caused by error in `1 + ""`: ! non-numeric argument to binary operator From fd0f9876e8c02fd17525b982aad33b94d7fb989f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Tue, 18 Nov 2025 00:30:05 +0100 Subject: [PATCH 5/5] NEWS --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 1e63c1a2d1..9a97bc6839 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # dplyr (development version) +* `tally_n()` creates fully qualified funciton calls for duckplyr compatibility (#7046) + * `storms` has been updated to include 2023 and 2024 data (#7111, @tomalrussell). * Empty `rowwise()` list-column elements now resolve to `logical()` rather than a random logical of length 1 (#7710).