swimmer_text.Rd
This function allows you to add text to a swimmers plot created with swimmer_plot
swimmer_text(
df_text,
id = "id",
start = "start",
label = "label",
name_col = NULL,
name_size = NULL,
name_alpha = NULL,
name_fontface = NULL,
adj.y = 0,
adj.x = 0,
...
)
a data frame
column name for id, default is 'id'
column name with the text start locations (if there is no start column will default 0 for all text)
a column with the text to be added to the plot
a column name to map the text colour
a column name to map the text size
a column name to map the text transparency
a column name to map the text fontface ("plain", "bold", "italic", "bold.italic" can all be used)
amount to adjust the text within the box vertically (default is 0, text is in the centre of each bar)
amount to adjust the text within the box horizontally (default is 0, text starts at the origin)
additional geom_text() arguments
a swimmer plot with text on the bars
#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',alpha=0.6)
# Then add text to the plot
swim_plot_with_text <- swim_plot + swimmer_text(df_text =
ClinicalTrial.Stage,label = 'Stage',size=3,
fontface=ifelse(ClinicalTrial.Stage$Stage=="Early Stage","bold","plain"))
# Add ggplot layers to improve the plot's aesthetic
swim_plot_with_text +
ggplot2::scale_fill_manual(name="Treatment",values=c("#e41a1c", "#377eb8","#4daf4a"))+
ggplot2::ylab('Time (Days)')