# NOT RUN {
#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'))
# }
Run the code above in your browser using DataLab