R/map_variable_names.R
map_variable_names.Rd
This function - specific to this analysis - changes coded variable names to be human readable using a predefined look-up.
map_variable_names(df)
df | A dataframe with a variable field. |
---|
A datafame with human readable variable entries.
## Code map_variable_names#> function (df) #> { #> dplyr::mutate(df, variable = case_when(variable %in% "year" ~ #> "Year", variable %in% "sex" ~ "Sex", variable %in% "age" ~ #> "Age", variable %in% "phec" ~ "Public Health England Centre", #> variable %in% "occat" ~ "Occupation", variable %in% "ethgrp" ~ #> "Ethnic group", variable %in% "ukborn" ~ "UK birth status", #> variable %in% "timesinceent" ~ "Time since entry", variable %in% #> "symptonset" ~ "Date of symptom onset", variable %in% #> "datediag" ~ "Date of diagnosis", variable %in% "startedtreat" ~ #> "Started treatment", variable %in% "starttreatdate" ~ #> "Date of starting treatment", variable %in% "txenddate" ~ #> "Treatment end date", variable %in% "pulmextrapulm" ~ #> "Pulmonary or extra-pulmonary TB", variable %in% #> "culture" ~ "Culture", variable %in% "startedtreat" ~ #> "Started treatment", variable %in% "sputsmear" ~ #> "Sputum smear status", variable %in% "anyres" ~ "Drug resistance", #> variable %in% "prevdiag" ~ "Previous diagnosis", variable %in% #> "bcgvacc" ~ "BCG status", variable %in% "bcgvaccyr" ~ #> "Year of BCG vaccination", variable %in% "overalloutcome" ~ #> "Overall outcome", variable %in% "tomdeathrelat" ~ #> "Cause of death", variable %in% "natquintile" ~ "Socio-economic status (quintiles)", #> variable %in% "dateofdeath" ~ "Date of death", variable %in% #> "caserepdate" ~ "Date of notification", )) #> } #> <bytecode: 0x55630c657a58> #> <environment: namespace:ETSMissing>