R function for SDTM

Can someone help me to setup a function to add supplemental domain into main domain in sdtm
this is my initial code
#merge ae with suppae
temp1 <- supp_ae %>%
pivot_wider(id_cols=c(USUBJID, IDVARVAL), names_from = QNAM, values_from=QVAL, values_fill = NULL) %>%
AESEQ = as.numeric(IDVARVAL)
ae1 <- ae %>%
left_join(temp1, by=join_by(USUBJID,AESEQ)) %>%

below is my function, it does not work, I do not know how to fix it
add_supp <- function(domain){
domain_name <- str_to_upper(substitute(domain))
xxseq <- paste0(domain_name,'SEQ')
temp2 <- eval(parse(text=paste0("SUPP_", domain_name)))
temp2_t <- temp2 %>% pivot_wider(id_cols=c(USUBJID, IDVARVAL), names_from = QNAM, values_from=QVAL) %>%
xxseq = as.numeric(IDVARVAL)
left_join(temp2_t, by=join_by(USUBJID, xxseq )) %>%
AE1 <- add_supp(AE)

if I want to merge CM so I can do
CM1 <- add_supp(CM)


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.