Skip to content

Commit

Permalink
generalise to enable faceting
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Nov 19, 2024
1 parent 70d0772 commit 2e49a7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions R/tm_p_swimlane.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ srv_p_swimlane <- function(id,
points_calls <- lapply(geom_specs, function(x) {
# todo: convert $geom, $data, and $mapping elements from character to language
# others can be kept as character
if (!is.null(x$mapping)) {
x$mapping <- as.call(c(as.name("aes"), x$mapping))
}
basic_call <- as.call(
c(
list(
x$geom,
mapping = as.call(c(as.name("aes"), x$mapping))
),
x[!names(x) %in% c("geom", "mapping")]
list(x$geom),
x[!names(x) %in% "geom"]
)
)
})
Expand Down
6 changes: 5 additions & 1 deletion inst/swimlane_poc.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data <- within(teal_data(), {
.possible_end_days <- c(50, 60, 70)

# Create sample data
synthetic_data <- tibble(subjid = c(1:15)) |>
synthetic_data <- tibble(subjid = c(1:15), strata = rep(c("category 1", "category 2"), length.out = 15)) |>
rowwise() |>
mutate(
max_study_day = sample(.possible_end_days, 1),
Expand Down Expand Up @@ -57,6 +57,10 @@ app <- init(
mapping = list(
y = quote(subjid), x = quote(study_day), color = quote(response_type), shape = quote(response_type)
)
),
list(
geom = quote(facet_wrap),
facets = quote(vars(strata))
)
),
title = "Swimlane Efficacy Plot"
Expand Down

0 comments on commit 2e49a7a

Please sign in to comment.