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

dplyr 1.1.0 ungroup() drops data frame attributes #1514

Closed
mkoohafkan opened this issue Mar 3, 2023 · 2 comments
Closed

dplyr 1.1.0 ungroup() drops data frame attributes #1514

mkoohafkan opened this issue Mar 3, 2023 · 2 comments

Comments

@mkoohafkan
Copy link

This is referring to tibble attributes, not tibble column attributes. The CRAN install of dplyr 1.1.0 sometimes drops attributes:

d = mtcars
attr(d, "foo") = "bar"
attr(d, "foo")
#> [1] "bar"

## preserved
d |> select(cyl) |> attr("foo")
#> [1] "bar"
d |> rename(cyl2 = cyl) |> attr("foo")
#> [1] "bar"
d |> arrange(cyl) |> attr("foo")
#> [1] "bar"
d |> group_by(cyl) |> attr("foo")
#> [1] "bar"
d |> mutate(mpg2 = mpg) |> attr("foo")
#> [1] "bar"
d |> transmute(mpg2 = mpg) |> attr("foo")
#> [1] "bar"
d |> filter(cyl == 1L) |> attr("foo")
#> [1] "bar"
d |> count(cyl) |> attr("foo") 
#> [1] "bar"
d |> bind_rows(d) |> attr("foo")
#> [1] "bar"
d |> bind_cols(select(d, cyl2 = cyl)) |> attr("foo")
#> [1] "bar"


## dropped
d |> group_by(cyl) |> ungroup() |> attr("foo")
#> NULL
d |> summarize(mpg = max(mpg)) |> attr("foo")
#> NULL

I can understand why it might make sense for summarize() to drop attributes (but then why does count() preserve them?), but I don't see why ungroup(group_by(...)) should drop attributes unilaterally. Given that almost all dplyr verbs preserve the attribute, I'm wondering if this is a bug/regression.

There are a variety of issues regarding attributes but they are all closed.

@mkoohafkan
Copy link
Author

ugh sorry, thought I was in the dplyr repo

@krlmlr
Copy link
Member

krlmlr commented Mar 4, 2023

Thanks. Can you please take this to the dplyr repo?

@krlmlr krlmlr closed this as completed Mar 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants