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

Feature Request: Add numeric decodes for COUNTRY #2388

Closed
jeffreyad opened this issue Mar 22, 2024 · 3 comments · Fixed by #2419
Closed

Feature Request: Add numeric decodes for COUNTRY #2388

jeffreyad opened this issue Mar 22, 2024 · 3 comments · Fixed by #2419
Assignees
Labels
enhancement New feature or request programming

Comments

@jeffreyad
Copy link
Collaborator

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

@jeffreyad jeffreyad added enhancement New feature or request programming labels Mar 22, 2024
@manciniedoardo
Copy link
Collaborator

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
Copy link
Collaborator

bms63 commented Mar 22, 2024

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
Copy link
Collaborator Author

@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).

@jeffreyad jeffreyad self-assigned this Apr 3, 2024
@jeffreyad jeffreyad linked a pull request Apr 25, 2024 that will close this issue
15 tasks
jeffreyad pushed a commit that referenced this issue May 23, 2024
bms63 added a commit that referenced this issue May 23, 2024
* Add country_code_lookup

* Add country_code_lookup

* Update country_code_lookup and NEWS

* Run styler

* Add test file

* Update codes and test

* Update NEWS.md

Co-authored-by: Edoardo Mancini <53403957+manciniedoardo@users.noreply.github.com>

* Update R/create_country_codes.R

Co-authored-by: Edoardo Mancini <53403957+manciniedoardo@users.noreply.github.com>

* Run styler on vignette and update Turkey name for non ascii characters

* Update documentation

* Remove non-ascii characters

* Calculate number by order

* Update NEWS.md

Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>

* Doc: #2388 Remove extra #'

---------

Co-authored-by: Jeffrey Dickinson <dickinson.jeffrey@gene.com>
Co-authored-by: Edoardo Mancini <53403957+manciniedoardo@users.noreply.github.com>
Co-authored-by: Ben Straub <ben.x.straub@gsk.com>
Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request programming
Development

Successfully merging a pull request may close this issue.

3 participants