-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
Description
This is referring to dataframe/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.
sda030 and DanChaltiel