From 5ac8b878634af5833a9d8d6d2f38a427f798603f Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Mon, 7 Dec 2020 15:22:32 +0100 Subject: [PATCH] call the dplyr::count.data.frame() method if it exists instead of the generic from dplyr. closes #36 --- R/tally.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/R/tally.R b/R/tally.R index 603708a..76a7829 100644 --- a/R/tally.R +++ b/R/tally.R @@ -375,11 +375,18 @@ count <- function(x, ...) { UseMethod("count") } +ns_dplyr <- rlang::ns_env("dplyr") + #' @export count.data.frame <- function( x, ...) { - dplyr::count(x, ...) + + if (exists("count.data.frame", ns_dplyr)) { + get("count.data.frame", ns_dplyr)(x, ...) + } else { + dplyr::count(x, ...) + } } #' @export