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

Bug: Outputting issues with variables in every domain #128

Closed
bms63 opened this issue May 18, 2023 · 4 comments · Fixed by #146
Closed

Bug: Outputting issues with variables in every domain #128

bms63 opened this issue May 18, 2023 · 4 comments · Fixed by #146
Assignees
Milestone

Comments

@bms63
Copy link
Collaborator

bms63 commented May 18, 2023

Look in 84-deepdive branch for data and specs

library(dplyr)
library(xportr)

spec_loc <- here::here("example_data_specs", "TDF_ADaM_Pilot3.xlsx")

var_spec <- readxl::read_xlsx(spec_loc, sheet = "Variables") %>% 
  mutate(Label = if_else(Variable == "TRTSDT", 
                         "Date of First Exposure to Treatment Date of First Exposure to Treatment", Label))

adsl_loc <- here::here("example_data_specs", "adsl.xpt")

adsl <- haven::read_xpt(adsl_loc) %>% 
  metatools::remove_labels() 

adsl_lbl <- xportr_label(adsl, var_spec, "ADSL", verbose = "warn")

Should just be one TRTSDT

Image

If time given, then look into other xportr functions

@bms63 bms63 moved this to Priority in xportr 0.3.0 May 18, 2023
@bms63 bms63 self-assigned this May 18, 2023
@bms63 bms63 added this to the xportr 0.3.0 milestone May 18, 2023
@averissimo
Copy link
Collaborator

averissimo commented May 23, 2023

This is a problem when the spec has column names in Snake case: Variable instead of variable, as xportr is not case insensitive.

It just assumes there's no domain in the spec, hence appearing multiple times.

I have 3 suggestions:

  • Case insensitive search:: either convert everything needed to lowercase or use case insensitive compares
  • Guide the user, but keep functionality:: Check if there are duplicate variables in the spec and message/warn for this issue
  • Keep it as is

edit: added the 3rd suggestion

@averissimo
Copy link
Collaborator

This also risks the functions themselves as it might not be able to find the column with the metadata (example: No label column in xportr_label)

Example of spec file from pilot 3

image

Default values

image

@cpiraux
Copy link
Collaborator

cpiraux commented May 24, 2023

In addition to the column names case in metadata, we could check the mapping between the metadata and the expected metadata structure.

The column names in the specifications file may differ depending on the template used for the specifications.

It would be valuable to provide guidance to the user regarding which part of the metadata does not align with the expected metadata structure, what is the expected structure, and how to update the metadata to conform to the expected structure.

For instance, in the P21C template, the column name is 'Data Type,' whereas the expected value is 'type.'

@bms63
Copy link
Collaborator Author

bms63 commented May 24, 2023

I think xportr.options is supposed to allow us to change variable to Variable. I was using this in my vignette, but honestly I find it a little confusing to use.

@bms63 bms63 moved this from Priority to In Progress in xportr 0.3.0 Jun 8, 2023
@bms63 bms63 moved this from In Progress to In Review in xportr 0.3.0 Jun 13, 2023
elimillera added a commit that referenced this issue Jun 14, 2023
…omain

Closes #128 Add warning message when `xportr.*` column names don't match metadata
@github-project-automation github-project-automation bot moved this from In Review to Done in xportr 0.3.0 Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
4 participants