Skip to contents

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

Usage

swimmerplot1(
  data,
  patientID,
  start,
  end,
  event,
  timetype = "raw",
  timetypedata = "ymd",
  timetypeoutput = "months",
  startType = "relative",
  sortVariable,
  barHeight = 3,
  referenceLines = "none",
  customReferenceTime = 12,
  useggswim = FALSE,
  markerSize = 5,
  milestone1Name = "Surgery",
  milestone1Date,
  milestone2Name = "Treatment",
  milestone2Date,
  milestone3Name = "Recurrence",
  milestone3Date,
  milestone4Name = "Remission",
  milestone4Date,
  milestone5Name = "Death",
  milestone5Date
)

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

milestone1Name

Name for the first milestone event (e.g., Surgery)

milestone1Date

Date/time when milestone 1 occurred

milestone2Name

Name for the second milestone event (e.g., Treatment)

milestone2Date

Date/time when milestone 2 occurred

milestone3Name

Name for the third milestone event (e.g., Recurrence)

milestone3Date

Date/time when milestone 3 occurred

milestone4Name

Name for the fourth milestone event (e.g., Remission)

milestone4Date

Date/time when milestone 4 occurred

milestone5Name

Name for the fifth milestone event (e.g., Death)

milestone5Date

Date/time when milestone 5 occurred

Value

A results object containing:

results$todoa html
results$summarya table
results$plotan 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

# \donttest{
# 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"
)
#> Error in swimmerplot(data = data, patientID = "PatientID", start = "StartTime",     end = "EndTime", event = "Event", milestone1Name = "Surgery",     milestone1Date = "Surgery"): unused arguments (milestone1Name = "Surgery", milestone1Date = "Surgery")
# }