insightsengineering / teal.data

Data model for teal applications
https://insightsengineering.github.io/teal.data/
Other
8 stars 7 forks source link

Fix bug in `col_labels` for named labels #300

Closed edelarua closed 6 months ago

edelarua commented 6 months ago

Currently, for datasets with named labels, when col_labels is applied the list is flattened and labels are repeated (i.e. ARM.ARM). This occurs in some cases where labels are reassigned via formatters::var_labels (such as in TMC).

Example:

ADSL <- scda::synthetic_cdisc_dataset("latest", "adsl")
adsl_labels <- formatters::var_labels(ADSL)
formatters::var_labels(ADSL) <- adsl_labels

attr(ADSL$STUDYID, "label")
#>            STUDYID 
#> "Study Identifier"

teal.data::col_labels(ADSL)[1:5]
#>                    STUDYID.STUDYID                    USUBJID.USUBJID 
#>                 "Study Identifier"        "Unique Subject Identifier" 
#>                      SUBJID.SUBJID                      SITEID.SITEID 
#> "Subject Identifier for the Study"            "Study Site Identifier" 
#>                            AGE.AGE 
#>                              "Age"

Created on 2024-02-26 with reprex v2.1.0