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). diff --git a/R/count-tally.R b/R/count-tally.R index de0f1546d2..e3d768cecd 100644 --- a/R/count-tally.R +++ b/R/count-tally.R @@ -236,9 +236,9 @@ add_tally <- function(x, wt = NULL, sort = FALSE, name = NULL) { tally_n <- function(x, wt) { if (quo_is_null(wt)) { - expr(n()) + expr(dplyr::n()) } else { - expr(sum(!!wt, na.rm = TRUE)) + expr(base::sum(!!wt, na.rm = TRUE)) } } 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