Merck / Merck/metalite

Cause an error when non-existing columns are selected in `collect_observation_record(var=...)`

Open
#181 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
18
Forks
8
PR merge metrics
No merged PRs in 30d

Description

The following code returns an error because "AGEU" is not included in meta$data_observation. It would be better to raise an error message for this situation.

library(metalite)
library(forestly)
adsl <- forestly_adsl
adae <- forestly_adae
adsl$TRTA <- factor(adsl$TRTA, levels = c("Placebo", "Xanomeline Low Dose"))
adae$TRTA <- factor(adae$TRTA, levels = c("Placebo", "Xanomeline Low Dose"))


meta <- meta_adam(population = adsl, observation = adae) |>
  define_plan(plan = plan(analysis = "ae_forest_plot",
                          population = "apat",
                          observation = "oapat",
                          parameter = "any-AE"           
  )) |>
  define_population(name = "apat",
                    group = "TRTA",
                    subset = SAFFL == "Y" ,
                    label = "All Participants as Treated Population",
                    var = c("USUBJID", "TRTA", "RACE", "SEX", "AGE", "AGEU")) |>
  define_observation(name = "oapat",
                     group = "TRTA",
                     subset = SAFFL == "Y" ,
                     label = "All Participants as Treated Population") |>
  define_analysis(name = "ae_forest_plot",
                  label = "Interactive AE Forest Plot") |>
  define_parameter(name = "any-AE",
                   subset = SAFFL == "Y",
                   label = "Any AEs",
                   var = "AEDECOD", soc = "AEBODSYS", term1 = "", term2 = "") |>
  meta_build()

collect_observation_record(meta, "apat", "oapat", "any-AE", var = c("USUBJID", "TRTA", **"AGEU"**))

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the collect_observation_record() entry point and trace how the var argument is checked against the observation metadata. Reproduce the example with AGEU, then add coverage for a missing column and verify that the function raises a clear error identifying the unavailable variable.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.