Skip to contents

[Stable]

Helper function that merges ADSL and ADLB datasets so that missing lab test records are inserted in the output dataset.

Usage

h_adsl_adlb_merge_using_worst_flag(
  adsl,
  adlb,
  worst_flag = c(WGRHIFL = "Y"),
  by_visit = FALSE,
  no_fillin_visits = c("SCREENING", "BASELINE")
)

Arguments

adsl

(data frame) ADSL dataframe

adlb

(data frame) ADLB dataframe

worst_flag

(named vector) Worst post-baseline lab flag variable

by_visit

(logical) defaults to FALSE to generate worst grade per patient. If worst grade per patient per visit is specified for worst_flag, then by_visit should be TRUE to generate worst grade patient per visit.

no_fillin_visits

(named character) Visits that are not considered for post-baseline worst toxicity grade. Defaults to c("SCREENING", "BASELINE").

Value

df containing variables shared between adlb and adsl along with variables relevant for analysis: PARAM, PARAMCD, ATOXGR, and BTOXGR. Optionally AVISIT, AVISITN are included when by_visit = TRUE and no_fillin_visits = c("SCREENING", "BASELINE").

Details

In the result data missing records will be created for the following situations:

  • patients who are present in adsl but have no lab data in adlb (both baseline and post-baseline)

  • patients who do not have any post-baseline lab values

  • patients without any post-baseline values flagged as the worst

Examples

library(scda)
adlb <- synthetic_cdisc_data("latest")$adlb
adsl <- synthetic_cdisc_data("latest")$adsl

# `h_adsl_adlb_merge_using_worst_flag`
adlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl, adlb, worst_flag = c("WGRHIFL" = "Y"))

# `h_adsl_adlb_merge_using_worst_flag` by visit example
adlb_out_by_visit <- h_adsl_adlb_merge_using_worst_flag(
  adsl,
  adlb,
  worst_flag = c("WGRLOVFL" = "Y"),
  by_visit = TRUE
)