Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct SERREAS derivation in ael03 #284

Merged
merged 12 commits into from
Dec 2, 2024
27 changes: 18 additions & 9 deletions book/listings/adverse-events/ael03.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ library(dplyr)
library(rlistings)

adae <- random.cdisc.data::cadae
adae$AESCONG[which(adae$AESER == "Y")[seq(3)]] <- "Y" # To mimick correct possibility of overlap
Melkiades marked this conversation as resolved.
Show resolved Hide resolved

out <- adae %>%
filter(AESER == "Y") %>%
Expand All @@ -38,17 +39,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)
Melkiades marked this conversation as resolved.
Show resolved Hide resolved

out <- out %>%
select(CPID, ASR, TRT01A, AEDECOD, Date_First, ASTDY, Duration, AESEV, Related, Outcome, Treated, Action, SERREAS)

var_labels(out) <- c(
Expand Down Expand Up @@ -106,6 +113,7 @@ lsting <- as_listing(
head(lsting, 20)
```


Melkiades marked this conversation as resolved.
Show resolved Hide resolved
```{r include = FALSE}
webr_code_labels <- c("lsting")
```
Expand All @@ -118,6 +126,7 @@ webr_code_labels <- c("lsting")
```{r setup}
#| code-fold: show
```

Melkiades marked this conversation as resolved.
Show resolved Hide resolved
::::

{{< include ../../_utils/save_results.qmd >}}
Expand Down
Loading