Skip to content

Make labels persistant during data manipulation #108

@DanChaltiel

Description

@DanChaltiel

Changes in vctrs made attributes unstable, making labels disappear in classed vectors during filtering for instant.

library(tidyverse)
library(crosstable)
x = tibble(a = 1, 
           b = today() - today()) %>% 
  apply_labels(a="A num", b="A difftime")

x %>% get_label()
#>            a            b 
#>      "A num" "A difftime"
x %>% filter(T) %>% get_label()
#>       a       b 
#> "A num"     "b"

Created on 2025-12-10 with reprex v2.1.1

Solution in package labelled:
During set_label() : add_class(c("haven_labelled", "vctrs_vctr")

(it seems like vctrs_vctr is sufficient)

On hold, waiting for: https://github.com/tidyverse/dplyr/issues/ 7787

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions