diff --git a/book/listings/adverse-events/ael03.qmd b/book/listings/adverse-events/ael03.qmd index ec6cbec0da..6aaba36fd4 100644 --- a/book/listings/adverse-events/ael03.qmd +++ b/book/listings/adverse-events/ael03.qmd @@ -7,13 +7,13 @@ subtitle: Listing of Serious Adverse Events {{< include ../../_utils/envir_hook.qmd >}} -:::: {.panel-tabset} - +::: panel-tabset ```{r setup, echo = FALSE} library(dplyr) library(rlistings) adae <- random.cdisc.data::cadae +adae$AESCONG[which(adae$AESER == "Y")[seq(3)]] <- "Y" # To mimick correct possibility of overlap out <- adae %>% filter(AESER == "Y") %>% @@ -40,17 +40,23 @@ out <- adae %>% AEACN == "DRUG WITHDRAWN" ~ 5, AEACN == "NOT APPLICABLE" | AEACN == "NOT EVALUABLE" ~ 6, AEACN == "UNKNOWN" ~ 7 - ), - SERREAS = case_when( - AESDTH == "Y" ~ "1", - AESLIFE == "Y" ~ "2", - AESHOSP == "Y" ~ "3", - AESDISAB == "Y" ~ "4", - AESCONG == "Y" ~ "5", - AESMIE == "Y" ~ "6", - TRUE ~ " " ) ) %>% + rowwise() %>% + mutate( + SERREAS = paste( + which( + c(AESDTH, AESLIFE, AESHOSP, AESDISAB, AESCONG, AESMIE) == "Y" + ), + collapse = ", " + ) + ) %>% + ungroup() + +# Check correct derivation of SERREAS +# out |> select(AESDTH, AESLIFE, AESHOSP, AESDISAB, AESCONG, AESMIE, SERREAS) + +out <- out %>% select(CPID, ASR, TRT01A, AEDECOD, Date_First, ASTDY, Duration, AESEV, Related, Outcome, Treated, Action, SERREAS) var_labels(out) <- c( @@ -99,8 +105,7 @@ lsting <- as_listing( head(lsting, 20) ``` -`r webr_code_labels <- c("setup", "lsting")` -{{< include ../../_utils/webr.qmd >}} +`r webr_code_labels <- c("setup", "lsting")` {{< include ../../_utils/webr.qmd >}} ::: ## Data Setup @@ -108,8 +113,7 @@ head(lsting, 20) ```{r setup} #| code-fold: show ``` - -:::: +::: {{< include ../../_utils/save_results.qmd >}}