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
)A Layer to add with +.
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