Skip to content

Commit ea559d3

Browse files
committed
fix: filter using teal.slice and not during data creation
1 parent 780924c commit ea559d3

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

inst/poc_osprey.R

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@ data <- within(teal_data(), {
66
library(dplyr)
77
library(osprey)
88

9-
ADSL <- osprey::rADSL[1:20, ]
10-
ADRS <- filter(rADRS, PARAMCD == "OVRINV")
9+
ADSL <- osprey::rADSL |>
10+
mutate(x_val = as.integer(TRTEDTM - TRTSDTM))
11+
ADRS <- osprey::rADRS
1112
})
1213

14+
join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADRS")]
15+
1316
plotly_specs <- list(
1417
list(
1518
"plotly::add_bars",
1619
data = quote(ADSL),
17-
x = ~ as.integer(TRTEDTM - TRTSDTM), y = ~USUBJID, color = ~ARM,
20+
x = ~x_val, y = ~USUBJID, color = ~ARM,
1821
colors = c("A: Drug X" = "#343CFF", "B: Placebo" = "#FF484B", "C: Combination" = "#222222")
1922
),
2023
list(
2124
"plotly::add_markers",
22-
data = quote(left_join(ADSL, ADRS)),
25+
data = quote(ADRS),
2326
x = ~ADY, y = ~USUBJID, symbol = ~AVALC,
2427
marker = list(
2528
size = 10,
@@ -30,6 +33,18 @@ plotly_specs <- list(
3033

3134
app <- init(
3235
data = data,
36+
filter = teal_slices(
37+
teal_slice(
38+
"ADSL",
39+
"AGE",
40+
selected = c(20, 23)
41+
),
42+
teal_slice(
43+
"ADRS",
44+
"PARAMCD",
45+
selected = "OVRINV"
46+
)
47+
),
3348
modules = modules(
3449
tm_data_table(),
3550
tm_p_swimlane2(

0 commit comments

Comments
 (0)