Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace as_tibble with new_tibble in ungroup() #6817

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkoohafkan
Copy link

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.

Fixes #6774 without affecting discussion in tidyverse/tibble#769

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.
@mkoohafkan mkoohafkan changed the title replace as_tibble with new_tibble replace as_tibble with new_tibble in ingroup() Apr 7, 2023
@mkoohafkan mkoohafkan changed the title replace as_tibble with new_tibble in ingroup() replace as_tibble with new_tibble in ungroup() Apr 7, 2023
Copy link
Member

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good to me. It seems that other attributes are preserved here:

tibble::new_tibble(
  structure(list(a = 1), foo = "bar", let_it = "go"),
  let_it = NULL
) |>
  attributes()
#> $class
#> [1] "tbl_df"     "tbl"        "data.frame"
#> 
#> $row.names
#> [1] 1
#> 
#> $names
#> [1] "a"
#> 
#> $foo
#> [1] "bar"

Created on 2023-08-23 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ungroup() drops data frame attributes
2 participants