From 056e713b654925f69bfb2310103430a08ad2d022 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Thu, 26 May 2022 10:00:01 -0400 Subject: [PATCH 1/2] Remove `tbl_sum()` reexport --- NAMESPACE | 3 +-- R/grouped-df.r | 1 + R/reexport-tibble.r | 4 ---- R/rowwise.r | 1 + man/reexports.Rd | 3 +-- tests/testthat/test-group-by.r | 2 +- 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 604ac80868..d1d4d398a2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -448,7 +448,6 @@ export(tbl) export(tbl_df) export(tbl_nongroup_vars) export(tbl_ptype) -export(tbl_sum) export(tbl_vars) export(tibble) export(top_frac) @@ -483,6 +482,7 @@ importFrom(lifecycle,deprecated) importFrom(magrittr,"%>%") importFrom(methods,is) importFrom(pillar,glimpse) +importFrom(pillar,tbl_sum) importFrom(pillar,type_sum) importFrom(stats,lag) importFrom(stats,setNames) @@ -494,7 +494,6 @@ importFrom(tibble,data_frame) importFrom(tibble,is_tibble) importFrom(tibble,lst) importFrom(tibble,new_tibble) -importFrom(tibble,tbl_sum) importFrom(tibble,tibble) importFrom(tibble,tribble) importFrom(tibble,view) diff --git a/R/grouped-df.r b/R/grouped-df.r index b0ffe29be4..0aaa53c465 100644 --- a/R/grouped-df.r +++ b/R/grouped-df.r @@ -190,6 +190,7 @@ group_sum <- function(x) { paste0(commas(group_vars(x)), " [", big_mark(grps), "]") } +#' @importFrom pillar tbl_sum #' @export tbl_sum.grouped_df <- function(x, ...) { c( diff --git a/R/reexport-tibble.r b/R/reexport-tibble.r index 6720bcd295..cbd52c34e5 100644 --- a/R/reexport-tibble.r +++ b/R/reexport-tibble.r @@ -28,7 +28,3 @@ tibble::as_tibble #' @importFrom tibble view tibble::view - -#' @importFrom tibble tbl_sum -#' @export -tibble::tbl_sum diff --git a/R/rowwise.r b/R/rowwise.r index 2682ae679d..a4661b5380 100644 --- a/R/rowwise.r +++ b/R/rowwise.r @@ -128,6 +128,7 @@ setOldClass(c("rowwise_df", "tbl_df", "tbl", "data.frame")) # methods ----------------------------------------------------------------- +#' @importFrom pillar tbl_sum #' @export tbl_sum.rowwise_df <- function(x, ...) { c( diff --git a/man/reexports.Rd b/man/reexports.Rd index b25d90e199..83a799491f 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -14,7 +14,6 @@ \alias{tibble} \alias{as_tibble} \alias{view} -\alias{tbl_sum} \alias{contains} \alias{select_helpers} \alias{ends_with} @@ -43,7 +42,7 @@ below to see their documentation. \item{pillar}{\code{\link[pillar]{type_sum}}} - \item{tibble}{\code{\link[tibble]{add_row}}, \code{\link[tibble:deprecated]{as_data_frame}}, \code{\link[tibble]{as_tibble}}, \code{\link[tibble:deprecated]{data_frame}}, \code{\link[tibble]{lst}}, \code{\link[tibble:reexports]{tbl_sum}}, \code{\link[tibble]{tibble}}, \code{\link[tibble]{tribble}}, \code{\link[tibble]{view}}} + \item{tibble}{\code{\link[tibble]{add_row}}, \code{\link[tibble:deprecated]{as_data_frame}}, \code{\link[tibble]{as_tibble}}, \code{\link[tibble:deprecated]{data_frame}}, \code{\link[tibble]{lst}}, \code{\link[tibble]{tibble}}, \code{\link[tibble]{tribble}}, \code{\link[tibble]{view}}} \item{tidyselect}{\code{\link[tidyselect]{all_of}}, \code{\link[tidyselect:all_of]{any_of}}, \code{\link[tidyselect:starts_with]{contains}}, \code{\link[tidyselect:starts_with]{ends_with}}, \code{\link[tidyselect]{everything}}, \code{\link[tidyselect:everything]{last_col}}, \code{\link[tidyselect:starts_with]{matches}}, \code{\link[tidyselect:starts_with]{num_range}}, \code{\link[tidyselect]{one_of}}, \code{\link[tidyselect]{starts_with}}} }} diff --git a/tests/testthat/test-group-by.r b/tests/testthat/test-group-by.r index 055482ca47..7da1d0bf0c 100644 --- a/tests/testthat/test-group-by.r +++ b/tests/testthat/test-group-by.r @@ -314,7 +314,7 @@ test_that("group_by() does not mutate for nothing when using the .data pronoun ( }) test_that("tbl_sum gets the right number of groups", { - res <- data.frame(x=c(1,1,2,2)) %>% group_by(x) %>% tbl_sum() + res <- data.frame(x=c(1,1,2,2)) %>% group_by(x) %>% pillar::tbl_sum() expect_equal(res, c("A tibble" = "4 x 1", "Groups" = "x [2]")) }) From 8e8c92e3e625bff72902ce08ba2bae1e0e55052a Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Thu, 26 May 2022 10:01:06 -0400 Subject: [PATCH 2/2] NEWS bullet --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index c521fceb93..4143c1ec24 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # dplyr (development version) +* `tbl_sum()` is no longer reexported from tibble (#6284). + * `slice_sample()` now gives a more informative error when `replace = FALSE` and the number of rows requested in the sample exceeds the number of rows in the data (#6271).