library(dplyr)
<- readRDS("data/dm.rds")
dm <- readRDS("data/ae.rds") ae
8 summarizing data exercises
8.1 Setup
8.2 Exercise 1
Count the number of overall adverse events per subject and sort the output such that the subject with the highest overall number of adverse events appears first.
Show solution
%>%
ae group_by(USUBJID) %>%
summarise(n_ae = n()) %>%
arrange(desc(n_ae))
# A tibble: 225 × 2
USUBJID n_ae
<chr> <int>
1 01-701-1302 23
2 01-717-1004 19
3 01-704-1266 16
4 01-709-1029 16
5 01-718-1427 16
6 01-701-1192 15
7 01-701-1275 15
8 01-709-1309 15
9 01-713-1179 15
10 01-711-1143 14
# … with 215 more rows
8.3 Exercise 2
Count the overall number of serious adverse events per treatment arm (ACTARM
).
Show solution
%>%
ae filter(AESER == "Y") %>%
group_by(ACTARM) %>%
summarise(n = n())
# A tibble: 2 × 2
ACTARM n
<chr> <int>
1 Xanomeline High Dose 1
2 Xanomeline Low Dose 2
8.4 Exercise 3
Find the lowest and highest AGE
per treatment arm.
Show solution
%>%
dm group_by(ARM) %>%
summarise(youngest = min(AGE, na.rm = TRUE), oldest = max(AGE, na.rm = TRUE))
# A tibble: 4 × 3
ARM youngest oldest
<chr> <int> <int>
1 Placebo 52 89
2 Screen Failure 50 89
3 Xanomeline High Dose 56 88
4 Xanomeline Low Dose 51 88