This PR closes #4. It was determined that instead of having dedicated outlines or some other visual representation for groups, it is better to just allow users to add faceting or other standard options like patchwork for group subsetting. Since the output of ggswim() is a ggplot object, this is easy to do. for example, the below code with faceting and an additional group column (treatment_group) can be seen nicely:
However, this PR does introduce a number of optimizations and lays out the ground work for more. It relies heavily on programmatic outputs from ggplot2::gplot_build() for legend support, converts geom_line() to geom_bar() and expands on our legend capabilities.
This PR closes #4. It was determined that instead of having dedicated outlines or some other visual representation for groups, it is better to just allow users to add faceting or other standard options like
patchwork
for group subsetting. Since the output ofggswim()
is a ggplot object, this is easy to do. for example, the below code with faceting and an additional group column (treatment_group
) can be seen nicely:Click Here for Code
```r df <- tibble::tribble( ~subject_id, ~time, ~event, ~treatment_group, 1, 0, "Infusion", "Cohort A", 1, 2, "CRS Grade 1", "Cohort A", 1, 3, "CRS Grade 2", "Cohort A", 1, 4, "CRS Grade 1", "Cohort A", 1, 5, "No CRS", "Cohort A", 1, 6, "Last Follow Up", "Cohort A", 2, 0, "Infusion", "Cohort A", 2, 1, "CRS Grade 1", "Cohort A", 2, 4, "CRS Grade 2", "Cohort A", 2, 7, "CRS Grade 1", "Cohort A", 2, 8, "No CRS", "Cohort A", 2, 9, "Last Follow Up", "Cohort A", 3, 0, "Infusion", "Cohort B", 3, 1, "CRS Grade 1", "Cohort B", 3, 2, "CRS Grade 2", "Cohort B", 3, 3, "CRS Grade 4", "Cohort B", 3, 7, "CRS Grade 5", "Cohort B", 3, 10, "Death", "Cohort B" ) lanes = list( "No CRS" = "gray", "CRS Grade 1" = "yellow", "CRS Grade 2" = "orange", "CRS Grade 3" = "pink", "CRS Grade 4" = "red", "CRS Grade 5" = "black" ) markers_emoji <- list( "Last Follow Up" = "👤", "Death" = "❌", "Infusion" = "🏥" ) df |> ggswim(id = subject_id, time = time, events = event, reference_event = "Infusion", markers = markers_emoji, lanes = lanes, legend_title = c("My Lanes Legend", "My Markers Legend")) + ggplot2::labs(title = "My Swim Plot", x = "Time", y = "Subject ID") + ggplot2::theme_minimal() + ggplot2::facet_wrap("treatment_group", nrow = 2, scales = "free") ```However, this PR does introduce a number of optimizations and lays out the ground work for more. It relies heavily on programmatic outputs from
ggplot2::gplot_build()
for legend support, convertsgeom_line()
togeom_bar()
and expands on our legend capabilities.