From 402ea7e1d2d706e324ddef59bdb29ea4d37e7836 Mon Sep 17 00:00:00 2001 From: mkoohafkan Date: Thu, 6 Apr 2023 16:50:02 -0700 Subject: [PATCH] replace as_tibble with new_tibble Make `ungroup()` handle attributes in a way that is consistent with other `dplyr` functions by using `new_tibble()` instead of `as_tibble()` This is also future-proof if it is later decided that `new_tibble()` should drop attributes. --- R/group-by.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/group-by.R b/R/group-by.R index b55e82b7fa..e9fa6670ab 100644 --- a/R/group-by.R +++ b/R/group-by.R @@ -156,7 +156,7 @@ ungroup <- function(x, ...) { #' @export ungroup.grouped_df <- function(x, ...) { if (missing(...)) { - as_tibble(x) + new_tibble(x, groups = NULL) } else { old_groups <- group_vars(x) to_remove <- tidyselect::eval_select( @@ -174,7 +174,7 @@ ungroup.grouped_df <- function(x, ...) { #' @export ungroup.rowwise_df <- function(x, ...) { check_dots_empty() - as_tibble(x) + new_tibble(x, groups = NULL) } #' @export