View source: R/swimmerplot2.h.R
swimmerplot2 | R Documentation |
Creates a swimmer plot to visualize subject response data over time.
swimmerplot2(
data,
patientID,
startTime,
endTime,
status,
markerData = FALSE,
markerVar,
markerTime,
showArrows = FALSE,
arrowFilter,
sortSubjects = "id",
laneWidth = 2,
markerSize = 5,
useDarkTheme = FALSE,
customTitle = "Swimmer Plot",
xLabel = "Time",
yLabel = "Subject ID"
)
data |
The data as a data frame in long format where each row represents a time segment. |
patientID |
Variable containing subject/patient identifiers. |
startTime |
Start time variable for each lane segment (also used as marker position by default). |
endTime |
End time variable for each lane segment. |
status |
Response or status variable to color lanes. |
markerData |
Whether to include event markers at the start time of each segment. |
markerVar |
Variable indicating the type of event to be displayed as markers. |
markerTime |
Optional separate time variable for marker positions. If not specified, start time is used. |
showArrows |
Show arrows at the end of lanes to indicate ongoing status. |
arrowFilter |
Boolean variable indicating which subjects should have arrows (TRUE = show arrow). |
sortSubjects |
How to sort subjects in the plot. |
laneWidth |
. |
markerSize |
. |
useDarkTheme |
. |
customTitle |
. |
xLabel |
. |
yLabel |
. |
A results object containing:
results$todo | a html | ||||
results$summary | a table | ||||
results$mydataview | a preformatted | ||||
results$dataView | a preformatted | ||||
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)
data <- data.frame(
patient_id = c("PT001", "PT001", "PT002", "PT002"),
start_time = c(0, 3, 0, 4),
end_time = c(3, 7, 4, 8),
event_type = c("Treatment Start", "Dose Modification", "Treatment Start", "Follow-up"),
response_status = c("PR", "CR", "SD", "PR"),
on_study = c(FALSE, TRUE, FALSE, TRUE)
)
swimmerplot2(
data = data,
patientID = "patient_id",
startTime = "start_time",
endTime = "end_time",
status = "response_status",
markerData = TRUE,
markerVar = "event_type"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.