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

filter() removes labels from glue variables #7630

Open
d-morrison opened this issue Jan 29, 2025 · 1 comment
Open

filter() removes labels from glue variables #7630

d-morrison opened this issue Jan 29, 2025 · 1 comment

Comments

@d-morrison
Copy link

Here's a reprex:

library(labelled)
library(glue)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
test = tibble(
  a = 1 |> set_label_attribute("a1"),
  b = glue::glue("two") |> set_label_attribute("b2")
)
test$b |> get_label_attribute()
#> [1] "b2"

# filter() strips the variable label from column `b`
dplyr::filter(test)$b |> get_label_attribute()
#> NULL

# filter() doesn't strip the label from column `a`
dplyr::filter(test)$a |> get_label_attribute()
#> [1] "a1"

Created on 2025-01-28 with reprex v2.1.1

I expected column b to keep its label attribute. Not sure if this is ultimately an issue with dplyr, glue, or labelled, but seems like it's in dplyr?

@d-morrison
Copy link
Author

(tested with dplyr 1.1.4.9000, glue 1.8.0, labelled 2.14.0, and R 4.4.2 on windows 11)

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

No branches or pull requests

1 participant