`build_from_derived()` produces unexpected results if unnecessary dataset is in `ds_list`
Opened this issue · 0 comments
kaz462 commented
below example is using spec from R/Pharma 2022 - Clinical Reporting In R workshop
adae
predecessor variables are from ae
and adsl
(not dm
) per spec, but if I add "dm" = dm
in ds_list
, the output contains two AESEQ
columns AESEQ.x
, AESEQ.y
. would you help check? what do you think of adding warning messages if unnecessary dataset is in ds_list
?
ae <- haven::read_xpt("datasets/SDTM/ae.xpt") %>% mutate(AESPROT = "") # AESPROT not in ae.xpt, but needed for adae
dm <- haven::read_xpt("datasets/SDTM/ae.xpt") %>% mutate(AGE = "")
adsl <- haven::read_xpt("datasets/ADAM/adsl.xpt")
metacore <- spec_to_metacore("specs/specs.xlsx", where_sep_sheet = FALSE)
adae_spec <- metacore %>% select_dataset("ADAE")
adae_pred <- build_from_derived(adae_spec,
ds_list = list(
"ae" = ae,
"dm" = dm,
"adsl" = adsl
)
)
names(adae_pred)
[1] "STUDYID" "USUBJID" "AGE" "AGEGR1" "ACOUNTRY" "SEX" "RACE" "TRT01P" "TRT01PN" "TRT01A"
[11] "TRT01AN" "AESTDTC" "AESEQ.x" "AEENDTC" "AEBODSYS" "AETERM" "AEDECOD" "AESPROT" "AESEV" "AEOUT"
[21] "AESER" "AESEQ.y"