pharmaverse / admiral

ADaM in R Asset Library
https://pharmaverse.github.io/admiral
Apache License 2.0
220 stars 61 forks source link

Feature Request: Add numeric decodes for COUNTRY #2388

Closed jeffreyad closed 3 months ago

jeffreyad commented 5 months ago

Feature Idea

ADPPK (Population PK) requires numeric decodes for covariates. COUNTRYN is the numeric decoded version of COUNTRY. Sometimes the list of decodes can be very long for large studies. One option that some sponsors may use is to use a number based on the ISO 3166-1 alpha-3 codes.

For example: Set to the country [ADSL.COUNTRY] using the code list which assigns the numerical representation of the standard-defined 249 countries after alphabetical sorting.

1 = ABW (ARUBA) 2 = AFG (AFGHANISTAN) 3 = AGO (ANGOLA) …

The 249 3-letter codes correspond to the ISO 3166-1 alpha-3 codes:

https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3

The decodes could be stored in function as below or in a tibble.

decode_country <- function(x) {
  y <- case_when(
    x == "ABW" ~ 1,
    x == "AFG" ~ 2,
    x == "AGO" ~ 3,
   ...
    x == "ZWE" ~ 249
   )
}

Relevant Input

No response

Relevant Output

No response

Reproducible Example/Pseudo Code

No response

manciniedoardo commented 5 months ago

This seems like a good idea for implementation. I wonder though ifi would be better to store the country codes in a small dataset provided with the package?

bms63 commented 5 months ago

This gets a bit in the realm of metadata. We've always tried to shy away from getting to much into that...but we have exceptions like lab grading.

How come this can't be fed in via a spec sheet and make use of metatools? Maybe a cool example for the examples site?

@pharmaverse/admiral and @pharmaverse/admiral_comm What do you think?

jeffreyad commented 5 months ago

@bms63 it would definitely be a candidate for metatools::create_var_from_codelist() if the codes were stored in Codelist. This is currently in examples for ADPPK: create_var_from_codelist(metacore, input_var = COUNTRY, out_var = COUNTRYN).