We use the following R datasets: ClinicalTrial.Arm
and
ClinicalTrial.AE
, contained in the swimplot
package.
Data should be in the long format (each row is one time
point per subject).
ClinicalTrial.Arm |
ClinicalTrial.AE |
---|---|
id Patient ID |
id Patient ID |
Arm Treatment Arm |
time Time of an adverse event (AE) |
End_trt Time since enrollment to the end
of treatment, in months |
event Type of adverse event (AE) |
Continued_treatment Continued treatment
past end of follow up |
Sex Patient Sex |
Sex Patient Sex |
Age Age of patient at trial entry
date |
Age Age of patient at trial entry
date |
Related Likelihood the treatment is
related to the adverse event |
id | Arm | End_trt | Continued_treatment | Sex | Age |
---|---|---|---|---|---|
1 | Arm A | 3.26 | NA | F | >=65 |
2 | Arm A | 2.00 | NA | F | <65 |
2 | Off Treatment | 10.00 | NA | F | <65 |
2 | Arm A | 15.45 | NA | F | <65 |
3 | Arm B | 5.00 | NA | F | >=65 |
3 | Arm A | 14.84 | NA | F | >=65 |
4 | Arm B | 3.51 | NA | F | <65 |
5 | Arm B | 6.00 | NA | F | >=65 |
id | time | event | Related | Sex | Age |
---|---|---|---|---|---|
33 | 2.20 | AE | Likely | M | >=65 |
14 | 1.00 | SAE | Possibly | F | <65 |
14 | 3.67 | Death | Not Likely | F | <65 |
3 | 14.58 | AE | Likely | F | >=65 |
29 | 5.44 | SAE | Possibly | M | >=65 |
21 | 0.50 | AE | Possibly | M | >=65 |
10 | 5.00 | SAE | Not Likely | F | <65 |
10 | 6.06 | SAE | Possibly | F | <65 |
swimmer_plot(
df,
a data frame
id = "id",
column name for id
end = "end",
column name with the bar
lengths (or bar end positions if bars change colour)
start = "start",
column name with the bar start positions
(only required when there are gaps between sections of bars, or bars
which do not start at zero)
col,
color of the border
of the bars
name_fill = NULL,
a column name to map the
bar fill
name_col = NULL,
a column
name to map the bar colour
name_alpha = NULL,
a column name to map the bar
transparency
increasing = TRUE,
increasing
order (Default is TRUE)
id_order = NULL,
order of the
bars by id, can input a column name to sort by, or the ids in order
stratify = FALSE,
a list of column names to stratify by
base_size = 11,
the base size for the plot, default is
11
identifiers = TRUE,
binary to specify patient
identifiers are included in the y axis (default is TRUE)
...
)
This document is a work of the statistics team in the Biostatistics and Medical Information Department at Saint-Louis Hospital in Paris (SBIM).
Based on The R Graph Gallery by Yan Holtz.