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

Enhancement: Add labels to ADNCA #100

Open
5 tasks
Shaakon35 opened this issue Oct 24, 2024 · 1 comment
Open
5 tasks

Enhancement: Add labels to ADNCA #100

Shaakon35 opened this issue Oct 24, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Shaakon35
Copy link
Collaborator

Shaakon35 commented Oct 24, 2024

Description

When the user loads ADNCA, sometimes there could be some column labels, sometimes not (if csv, there are no labels, if rdata there may be labels).
What we need to do is to populate all the labels based on the ADNCA guidelines.
If the variable is in the list: populate the label, if not, populate by the name of the variables:
e.g. ADNCA$ASIAN does not have labels, then populate:
attr(ADNCA[["ASIAN"]], "label") = "ASIAN"

After the labels are populated, they need to be displayed in all column headings. See this page for examples of how to lay it out.

some code to start with:

# Set label list 
label_ADPC <- list(
   USUBJID = 'Subject ID',
   TRT01A  = 'Treatment Group',
   AVAL    = paste0('PK Concentration\n (', unique(data$adpc$AVALU), ')'),
   AVALC   = paste0('PK Concentration\n (', unique(data$adpc$AVALU), ')'),
   NRELTM1 = paste0('Nominal Time \nfrom First Dose (hr)'),
   ARELTM1 = paste0('Actual Time \nfrom First Dose (hr)'),
   NRELTM2 = paste0('Nominal Time \nfrom Most Recent Dose (hr)'),
   ARELTM2 = paste0('Actual Time \nfrom Most Recent Dose (hr)'),
   # NOMDOSE = 'Nominal Dose',
   AVISIT  = 'Visit'
)

# Apply manual labels
for (var in names(label_ADPC))
  if (var %in% colnames(data$adpc))
    attr(data$adpc[[var]], "label") <- label_ADPC[[var]]


as_factor_preserve_label <- function(x) {  
  label <- attr(x, "label")  
  x <- as.factor(x)  
  attr(x, "label") <- label  
  return(x)  
}  

has_label <- function(x) {  
  return(!is.null(attr(x, "label")))  
}  

set_empty_label <- function(x) {  
  if (is.null(attr(x, "label"))) {  
    attr(x, "label") <- ""  
  }  
  return(x)  
}  

aNCA_data_TLGs.xlsx
For now, please use ADNCA_Roche tab, to get the labels and the variables.

  • make sure that when you grepl the variable name, only one row is used
  • make sure to properly set the labels for the variables TRTxxA (Planned Treatment for Period xx) for example, xx has to be a number with two digits / or e.g. STRATwNM

Definition of Done

The requirements for the feature to be complete:

  • after loading a csv or rdata, make sure all variables do have a label
  • make sure that if a variable is a factor with levels, the levels are kept! please use as_factor_preserve_label function
  • Make sure all column headers in the app show the user the CDISC name and also the label.
@Shaakon35 Shaakon35 added the enhancement New feature or request label Oct 24, 2024
@Shaakon35 Shaakon35 moved this to Todo in aNCA Oct 24, 2024
@Gero1999
Copy link
Collaborator

I think this implementation will make more sense after #112 and will make things easier for any case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

2 participants