swimmer_points {swimplot} | R Documentation |
Adding points to a swimmers plot
Description
This function allows you to add points to a swimmers plot created with swimmer_plot
Usage
swimmer_points(
df_points,
id = "id",
time = "time",
adj.y = 0,
name_shape = NULL,
name_col = NULL,
name_size = NULL,
name_fill = NULL,
name_stroke = NULL,
name_alpha = NULL,
...
)
Arguments
df_points |
a data frame |
id |
column name for id, default is 'id' |
time |
column name with the point locations |
adj.y |
amount to adjust the point within the box vertically (default is 0, point is in the centre of each bar) |
name_shape |
a column name to map the point shape |
name_col |
a column name to map the point colour |
name_size |
a column name to map the point size |
name_fill |
a column name to map the point fill |
name_stroke |
a column name to map the point stroke |
name_alpha |
a column name to map the point transparency |
... |
additional geom_point() arguments |
Value
a swimmer plot with points
See Also
swimmer_plot
swimmer_lines
swimmer_lines
swimmer_points_from_lines
swimmer_arrows
swimmer_text
Examples
#Start with a base swimmer plot
swim_plot <-
swimmer_plot(df=ClinicalTrial.Arm,id='id',end='End_trt',name_fill='Arm',col="black",id_order='Arm')
# Then add points to the plot
swim_plot_with_points <- swim_plot + swimmer_points(df_points=
ClinicalTrial.AE,id='id',time='time',name_shape =
'event',size=3,fill='white',col='black')
# Add ggplot layers to improve the plot's aesthetic
swim_plot_with_points + ggplot2::scale_shape_manual(name="Adverse
event",values=c(21,24,17),breaks=c('AE','SAE','Death'))+
ggplot2::scale_fill_manual(name="Treatment",values=c("#e41a1c", "#377eb8","#4daf4a"))+
ggplot2::ylab('Time (Days)')
##Another example with the colour and shape mapped to different columns
#Start with a base swimmer plot
swim_plot <-
swimmer_plot(df=ClinicalTrial.Arm,id='id',end='End_trt',name_fill='Arm',col="black",id_order='Arm')
swim_plot +
swimmer_points(df_points=ClinicalTrial.AE,id='id',time='time',name_shape =
'event',fill='white',name_col = 'Related',size=5)+
ggplot2::scale_shape_manual(name="Adverse event",values=c(16,17,18),breaks=c('AE','SAE','Death'))+
ggplot2::scale_fill_manual(name="Treatment",values=c("#e41a1c", "#377eb8","#4daf4a"))+
ggplot2::ylab('Time (Days)') +
ggplot2::scale_color_manual(name="Likelihood related to treatment",values=c(1,'grey52','grey90'))
[Package swimplot version 1.2.0 Index]