Skip to content

Commit 2e49a7a

Browse files
committed
generalise to enable faceting
1 parent 70d0772 commit 2e49a7a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

R/tm_p_swimlane.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ srv_p_swimlane <- function(id,
3838
points_calls <- lapply(geom_specs, function(x) {
3939
# todo: convert $geom, $data, and $mapping elements from character to language
4040
# others can be kept as character
41+
if (!is.null(x$mapping)) {
42+
x$mapping <- as.call(c(as.name("aes"), x$mapping))
43+
}
4144
basic_call <- as.call(
4245
c(
43-
list(
44-
x$geom,
45-
mapping = as.call(c(as.name("aes"), x$mapping))
46-
),
47-
x[!names(x) %in% c("geom", "mapping")]
46+
list(x$geom),
47+
x[!names(x) %in% "geom"]
4848
)
4949
)
5050
})

inst/swimlane_poc.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ data <- within(teal_data(), {
1212
.possible_end_days <- c(50, 60, 70)
1313

1414
# Create sample data
15-
synthetic_data <- tibble(subjid = c(1:15)) |>
15+
synthetic_data <- tibble(subjid = c(1:15), strata = rep(c("category 1", "category 2"), length.out = 15)) |>
1616
rowwise() |>
1717
mutate(
1818
max_study_day = sample(.possible_end_days, 1),
@@ -57,6 +57,10 @@ app <- init(
5757
mapping = list(
5858
y = quote(subjid), x = quote(study_day), color = quote(response_type), shape = quote(response_type)
5959
)
60+
),
61+
list(
62+
geom = quote(facet_wrap),
63+
facets = quote(vars(strata))
6064
)
6165
),
6266
title = "Swimlane Efficacy Plot"

0 commit comments

Comments
 (0)