The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

library(swimplot)

Sample data

A sample dataset displaying three types of toxicity for 5 patients over the course of a study

d1 <- data.frame(pat=c('a','b','c','d','e'),end=c(3.26,15.45,14.84,3.51,7.44))

Nausea <- data.frame(pat=c('a','b','c','c','e'),tox="Nausea",grade=as.character(c(1,3,2,2,3)),time=c(2,1,8,10,1.5))
Fever <- data.frame(pat=c('d','e','e','c','c'),tox="Fever",grade=as.character(c(1,2,2,1,2)), time=c(1.5,3,6,2,6.5))
Anemia <- data.frame(pat=c('d','e','e','c','c'),tox="Anemia",grade=as.character(c(1,1,2,1,3)), time=c(1.5,3,5,2,6))

Below are three different examples of ways to represent this data in a swimmers plot

Example 1

Using numbers to represent the grade of the toxicity, and colour for the type


swimmer_plot(df=d1,id='pat',end='end',col="black",fill='white')+
  swimmer_points(df_points=Nausea,id='pat',time='time',adj.y = 0.3,size=4,name_shape = 'grade',name_col = 'tox',stroke=3)+
  swimmer_points(df_points=Fever,id='pat',time='time',adj.y = 0,size=4,name_shape = 'grade',name_col = 'tox',stroke=3)+
  swimmer_points(df_points=Anemia,id='pat',time='time',adj.y = -0.3,size=4,name_shape = 'grade',name_col = 'tox',stroke=3)+
  ggplot2::scale_shape_manual(values=c("1","2","3")) + ggplot2::guides(shape=FALSE)+
  ggplot2::scale_color_brewer(palette = "Dark2")

Example 2

Using colour to represent the grade of the toxicity, and shape for the type


swimmer_plot(df=d1,id='pat',end='end',col="black",fill='white')+
  swimmer_points(df_points=Nausea,id='pat',time='time',adj.y = 0.3,size=4,name_col = 'grade',name_shape = 'tox',stroke=3)+
  swimmer_points(df_points=Fever,id='pat',time='time',adj.y = 0,size=4,name_col = 'grade',name_shape = 'tox',stroke=3)+
  swimmer_points(df_points=Anemia,id='pat',time='time',adj.y = -0.3,size=4,name_col = 'grade',name_shape = 'tox',stroke=3)+ 
  ggplot2::scale_color_manual(name="Grade",values=c("coral2","red3","orangered4"))

Example 3

Using colour and shape to represent the grade of the toxicity, and adding text to represent the type

textdf1 <- data.frame(pat=unique(d1$pat),label="Nausea")
textdf2 <- data.frame(pat=unique(d1$pat),label="Fever")
textdf3 <- data.frame(pat=unique(d1$pat),label="Anemia")

swimmer_plot(df=d1,id='pat',end='end',col="black",fill='white')+
  swimmer_points(df_points=Nausea,id='pat',time='time',adj.y = 0.2,size=4,name_col = 'grade',name_shape = 'grade',stroke=3)+
  swimmer_points(df_points=Fever,id='pat',time='time',adj.y = 0,size=4,name_col = 'grade',name_shape = 'grade',stroke=3)+
  swimmer_points(df_points=Anemia,id='pat',time='time',adj.y = -0.2,size=4,name_col = 'grade',name_shape = 'grade',stroke=3)+ 
  ggplot2::scale_color_manual(name="Grade",values=c("coral2","red3","orangered4")) + ggplot2::labs(shape="Grade")+
  swimmer_text(df_text = textdf1,id='pat',label = 'label',adj.x = -2.2,adj.y = 0.2)+
  swimmer_text(df_text = textdf2,id='pat',label = 'label',adj.x = -2.2,adj.y = 0)+
  swimmer_text(df_text = textdf3,id='pat',label = 'label',adj.x = -2.2,adj.y = -0.2)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.