One horizontal bar per subject showing time on treatment, with optional arrowheads for subjects still ongoing at the data cutoff — the standard patient-level timeline in oncology reporting.

geom_swimmer(
  mapping = NULL,
  data = NULL,
  bar_height = 0.6,
  arrow = TRUE,
  alpha = NULL
)

Arguments

mapping, data

Standard layer overrides. Map duration to x, the subject to y, and (optionally) response category to color. Map label to a logical "still ongoing" flag to draw arrowheads.

bar_height

Bar thickness in category-slot units.

arrow

Draw arrowheads for ongoing subjects.

alpha

Bar opacity.

Value

A Layer to add with +.

Examples

d <- data.frame(
  subject = paste0("S", 1:6),
  months = c(4, 9, 14, 6, 20, 11),
  response = c("PR", "CR", "CR", "SD", "PR", "SD"),
  ongoing = c(FALSE, FALSE, TRUE, FALSE, TRUE, FALSE)
)
ggnext(d, aes(months, subject, color = response, label = ongoing)) +
  geom_swimmer() +
  labs(title = "Time on treatment", x = "Months", y = NULL)
#> <ggnext plot>
#>   data:  6 x 4
#>   aes:   x = months, y = subject, color = response, label = ongoing
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static