swimmerplot: Swimmer Plot

View source: R/swimmerplot.h.R

swimmerplotR Documentation

Swimmer Plot

Description

Creates a swimmer plot to visualize individual patient timelines and clinical events.

Usage

swimmerplot(
  data,
  patientID,
  start,
  end,
  event,
  timetype = "raw",
  timetypedata = "ymd",
  timetypeoutput = "months",
  startType = "relative",
  sortVariable,
  barHeight = 3,
  referenceLines = "none",
  customReferenceTime = 12,
  useggswim = FALSE,
  markerSize = 5
)

Arguments

data

The data as a data frame.

patientID

Variable containing patient identifiers.

start

Time/date when observation/treatment started.

end

Time/date when observation/treatment ended.

event

Optional variable for event types (e.g., CR, PR, PD).

timetype

Select whether time values are raw numbers or dates

timetypedata

Select the time format in your data

timetypeoutput

Select the time unit for display

startType

Choose whether to align all start times to 0 or use absolute start times

sortVariable

Variable to sort the patient timelines.

barHeight

Thickness of timeline bars

referenceLines

Add reference time lines to the plot

customReferenceTime

Custom time point to mark with a reference line

useggswim

.

markerSize

Size of event markers on the plot

Value

A results object containing:

results$todo a html
results$summary a table
results$plot an image

Tables can be converted to data frames with asDF or as.data.frame. For example:

results$summary$asDF

as.data.frame(results$summary)

Examples


# Example will show patient timelines
data <- data.frame(
    PatientID = paste0("PT", 1:10),
    StartTime = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
    EndTime = c(12, 8, 15, 6, 9, 11, 7, 14, 10, 5),
    Event = c("CR", "PD", "PR", "SD", "CR", "PD", "PR", "SD", "CR", "PD"),
    Surgery = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1)
)
swimmerplot(
    data = data,
    patientID = "PatientID",
    start = "StartTime",
    end = "EndTime",
    event = "Event",
    milestone1Name = "Surgery",
    milestone1Date = "Surgery"
)


sbalci/ClinicoPathJamoviModule documentation built on June 13, 2025, 9:34 a.m.