Variable labels can be created using ff_label. Some functions strip variable labels (variable attributes), e.g. forcats::fct_recode. Use this function to create a vector of variable labels from a data frame. Then use ff_relabel to relabel variables in data frame.

extract_variable_label(.data)

Arguments

.data

Dataframe containing labelled variables.

Examples

colon_s %>%
  extract_variable_label
#>                    id                    rx                   sex 
#>                  "id"                  "rx"                 "sex" 
#>                   age              obstruct                perfor 
#>         "Age (years)"            "obstruct"              "perfor" 
#>                adhere                 nodes                status 
#>              "adhere"               "nodes"              "status" 
#>                differ                extent                  surg 
#>              "differ"              "extent"                "surg" 
#>                 node4                  time            sex.factor 
#>               "node4"                "time"                 "Sex" 
#>             rx.factor       obstruct.factor         perfor.factor 
#>           "Treatment"         "Obstruction"         "Perforation" 
#>         adhere.factor         differ.factor         extent.factor 
#>           "Adherence"     "Differentiation"    "Extent of spread" 
#>           surg.factor          node4.factor         status.factor 
#>   "Time from surgery"   ">4 positive nodes"              "Status" 
#>            age.factor               loccomp        loccomp.factor 
#>                 "Age"             "loccomp" "Local complications" 
#>            time.years              mort_5yr                age.10 
#>        "Time (years)"    "Mortality 5 year"              "age.10" 
#>          mort_5yr.num              hospital 
#>        "mort_5yr.num"            "hospital"