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

Include and expose value and variable labels #32

Open
Moohan opened this issue Apr 5, 2022 · 1 comment
Open

Include and expose value and variable labels #32

Moohan opened this issue Apr 5, 2022 · 1 comment
Labels
feature a feature request or enhancement

Comments

@Moohan
Copy link
Member

Moohan commented Apr 5, 2022

Have value labels stored somehow, then have functions for people to use this easily. One idea is to store them as JSON, with get functions:

vars = list(gender = list(
  description = "Patient's gender",
  values = list("1" = "Female", "2" = "Male", "9" = "Unknown"),
  type = "integer"
)) %>% 
  jsonlite::toJSON()

get_values <- function(variable) {
  json <- jsonlite::fromJSON(vars)
  
  return(json[[variable]][["values"]])
}

get_values("gender")

Could also have functions that would 'swap out' values for labels (to be used for plots etc.) mutate(gender = slf_factor_labels(gender))

@Moohan Moohan added the feature a feature request or enhancement label Jun 2, 2022
@Moohan
Copy link
Member Author

Moohan commented Dec 8, 2022

@Public-Health-Scotland/source-linkage-files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant