# 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 lines to the plot
swim_plot_with_lines <- swim_plot +
swimmer_lines(df_lines=ClinicalTrial.Response,id='id',start =
'Response_start',end='Response_end',name_col='Response',size=3)
# Add points to the start and end of the lines
swim_plot_with_lines_and_points <- swim_plot_with_lines+
swimmer_points_from_lines(df_lines=ClinicalTrial.Response,id='id',start =
'Response_start',end = 'Response_end', cont =
'Continued_response',name_col='Response',size=4)
# Add ggplot layers to improve the plot's aesthetic
swim_plot_with_lines_and_points +
ggplot2::scale_color_manual(name="Response",values=c("grey20","grey80"))+
ggplot2::scale_fill_manual(name="Treatment",values=c("#e41a1c", "#377eb8","#4daf4a"))+
ggplot2::ylab('Time (Days)')+
ggplot2::guides(fill = ggplot2::guide_legend(override.aes = list(shape =
NA)))+
ggplot2::scale_shape_manual(name='',values=c(17,15),breaks =
c('Response_start','Response_end'),labels=c('Response Start','Response End'))
# }
Run the code above in your browser using DataLab