Skip to content

Commit 92d03df

Browse files
use of roxy.shinylive (#1230)
similar to insightsengineering/teal.modules.general#775 - add "Examples in Shinylive" section where appropriate - modify examples code to use `teal_data()` everywhere - add a new "Playground" section in the README with links to the shinylive - include shinylive iframe in the getting started vignette --------- Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
1 parent f2895ee commit 92d03df

File tree

78 files changed

+1391
-806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1391
-806
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ vignettes/*.R
2929
coverage.*
3030
tests/testthat/_snaps/**/*.new.md
3131
tests/testthat/_snaps/**/*.new.svg
32+
/doc/
33+
/Meta/

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Suggests:
7171
lubridate (>= 1.7.9),
7272
nestcolor (>= 0.1.0),
7373
pkgload,
74+
roxy.shinylive,
7475
rvest,
7576
shinytest2,
7677
styler,
@@ -90,12 +91,12 @@ Config/Needs/verdepcheck: insightsengineering/teal,
9091
insightsengineering/teal.widgets, insightsengineering/tern.gee,
9192
insightsengineering/tern.mmrm, shosaco/vistime, tidyverse/forcats,
9293
yihui/knitr, tidyverse/lubridate, insightsengineering/nestcolor,
93-
r-lib/pkgload, tidyverse/rvest, rstudio/shinytest2, r-lib/styler,
94+
r-lib/pkgload, insightsengineering/roxy.shinylive, tidyverse/rvest, rstudio/shinytest2, r-lib/styler,
9495
r-lib/testthat, r-lib/withr
9596
Config/Needs/website: insightsengineering/nesttemplate
9697
Config/testthat/edition: 3
9798
Encoding: UTF-8
9899
Language: en-US
99100
LazyData: true
100-
Roxygen: list(markdown = TRUE)
101+
Roxygen: list(markdown = TRUE, packages = c("roxy.shinylive"))
101102
RoxygenNote: 7.3.2

R/tm_a_gee.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,14 @@ template_a_gee <- function(output_table,
135135
#'
136136
#' @inherit module_arguments return seealso
137137
#'
138+
#' @examplesShinylive
139+
#' library(teal.modules.clinical)
140+
#' interactive <- function() TRUE
141+
#' {{ next_example }}
142+
#'
138143
#' @examples
139144
#' library(dplyr)
145+
#'
140146
#' data <- teal_data()
141147
#' data <- within(data, {
142148
#' ADSL <- tmc_ex_adsl
@@ -152,9 +158,8 @@ template_a_gee <- function(output_table,
152158
#' ) %>%
153159
#' droplevels()
154160
#' })
155-
#' datanames <- c("ADSL", "ADQS")
156-
#' datanames(data) <- datanames
157-
#' join_keys(data) <- default_cdisc_join_keys[datanames]
161+
#' datanames(data) <- c("ADSL", "ADQS")
162+
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
158163
#'
159164
#' app <- init(
160165
#' data = data,

R/tm_a_mmrm.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,14 @@ template_mmrm_plots <- function(fit_name,
462462
#'
463463
#' @inherit module_arguments return seealso
464464
#'
465+
#' @examplesShinylive
466+
#' library(teal.modules.clinical)
467+
#' interactive <- function() TRUE
468+
#' {{ next_example }}
469+
#'
465470
#' @examples
466471
#' library(dplyr)
472+
#'
467473
#' arm_ref_comp <- list(
468474
#' ARMCD = list(
469475
#' ref = "ARM B",
@@ -485,10 +491,9 @@ template_mmrm_plots <- function(fit_name,
485491
#' as.factor() #' making consecutive numeric factor
486492
#' )
487493
#' })
494+
#' datanames(data) <- c("ADSL", "ADQS")
495+
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
488496
#'
489-
#' datanames <- c("ADSL", "ADQS")
490-
#' datanames(data) <- datanames
491-
#' join_keys(data) <- default_cdisc_join_keys[datanames]
492497
#' app <- init(
493498
#' data = data,
494499
#' modules = modules(

R/tm_g_barchart_simple.R

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,31 @@
1515
#'
1616
#' @inherit module_arguments return seealso
1717
#'
18+
#' @examplesShinylive
19+
#' library(teal.modules.clinical)
20+
#' interactive <- function() TRUE
21+
#' {{ next_example }}
22+
#'
1823
#' @examples
1924
#' library(nestcolor)
2025
#' library(dplyr)
2126
#'
22-
#' ADSL <- tmc_ex_adsl %>%
23-
#' mutate(ITTFL = factor("Y") %>%
24-
#' with_label("Intent-To-Treat Population Flag"))
25-
#' ADAE <- tmc_ex_adae %>%
26-
#' filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")))
27+
#' data <- teal_data()
28+
#' data <- within(data, {
29+
#' ADSL <- tmc_ex_adsl %>%
30+
#' mutate(ITTFL = factor("Y") %>%
31+
#' with_label("Intent-To-Treat Population Flag"))
32+
#' ADAE <- tmc_ex_adae %>%
33+
#' filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")))
34+
#' })
35+
#' datanames(data) <- c("ADSL", "ADAE")
36+
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
37+
#'
38+
#' ADSL <- data[["ADSL"]]
39+
#' ADAE <- data[["ADAE"]]
2740
#'
2841
#' app <- init(
29-
#' data = cdisc_data(
30-
#' ADSL = ADSL,
31-
#' ADAE = ADAE,
32-
#' code = "ADSL <- tmc_ex_adsl %>%
33-
#' mutate(ITTFL = factor(\"Y\") %>%
34-
#' with_label(\"Intent-To-Treat Population Flag\"))
35-
#' ADAE <- tmc_ex_adae %>%
36-
#' filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))"
37-
#' ),
42+
#' data = data,
3843
#' modules = modules(
3944
#' tm_g_barchart_simple(
4045
#' label = "ADAE Analysis",

R/tm_g_ci.R

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,27 @@ template_g_ci <- function(dataname,
189189
#'
190190
#' @inherit module_arguments return seealso
191191
#'
192+
#' @examplesShinylive
193+
#' library(teal.modules.clinical)
194+
#' interactive <- function() TRUE
195+
#' {{ next_example }}
196+
#'
192197
#' @examples
193198
#' library(nestcolor)
194199
#'
195-
#' ADSL <- tmc_ex_adsl
196-
#' ADLB <- tmc_ex_adlb
200+
#' data <- teal_data()
201+
#' data <- within(data, {
202+
#' ADSL <- tmc_ex_adsl
203+
#' ADLB <- tmc_ex_adlb
204+
#' })
205+
#' datanames(data) <- c("ADSL", "ADLB")
206+
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
207+
#'
208+
#' ADSL <- data[["ADSL"]]
209+
#' ADLB <- data[["ADLB"]]
197210
#'
198211
#' app <- init(
199-
#' data = cdisc_data(
200-
#' ADSL = ADSL,
201-
#' ADLB = ADLB,
202-
#' code = "
203-
#' ADSL <- tmc_ex_adsl
204-
#' ADLB <- tmc_ex_adlb
205-
#' "
206-
#' ),
212+
#' data = data,
207213
#' modules = modules(
208214
#' tm_g_ci(
209215
#' label = "Confidence Interval Plot",
@@ -253,10 +259,6 @@ template_g_ci <- function(dataname,
253259
#' )
254260
#' )
255261
#' )
256-
#' ),
257-
#' header = "Example of Confidence Interval Plot",
258-
#' footer = tags$p(
259-
#' class = "text-muted", "Source: `teal.modules.clinical::tm_g_ci`"
260262
#' )
261263
#' )
262264
#' if (interactive()) {

R/tm_g_forest_rsp.R

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,28 @@ template_forest_rsp <- function(dataname = "ANL",
243243
#'
244244
#' @inherit module_arguments return seealso
245245
#'
246+
#' @examplesShinylive
247+
#' library(teal.modules.clinical)
248+
#' interactive <- function() TRUE
249+
#' {{ next_example }}
250+
#'
246251
#' @examples
247252
#' library(nestcolor)
248253
#' library(dplyr)
249254
#'
250-
#' ADSL <- tmc_ex_adsl
251-
#' ADRS <- tmc_ex_adrs %>%
252-
#' mutate(AVALC = d_onco_rsp_label(AVALC) %>%
253-
#' with_label("Character Result/Finding")) %>%
254-
#' filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
255+
#' data <- teal_data()
256+
#' data <- within(data, {
257+
#' ADSL <- tmc_ex_adsl
258+
#' ADRS <- tmc_ex_adrs %>%
259+
#' mutate(AVALC = d_onco_rsp_label(AVALC) %>%
260+
#' with_label("Character Result/Finding")) %>%
261+
#' filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
262+
#' })
263+
#' datanames(data) <- c("ADSL", "ADRS")
264+
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
265+
#'
266+
#' ADSL <- data[["ADSL"]]
267+
#' ADRS <- data[["ADRS"]]
255268
#'
256269
#' arm_ref_comp <- list(
257270
#' ARM = list(
@@ -265,17 +278,7 @@ template_forest_rsp <- function(dataname = "ANL",
265278
#' )
266279
#'
267280
#' app <- init(
268-
#' data = cdisc_data(
269-
#' ADSL = ADSL,
270-
#' ADRS = ADRS,
271-
#' code = "
272-
#' ADSL <- tmc_ex_adsl
273-
#' ADRS <- tmc_ex_adrs %>%
274-
#' mutate(AVALC = d_onco_rsp_label(AVALC) %>%
275-
#' with_label(\"Character Result/Finding\")) %>%
276-
#' filter(PARAMCD != \"OVRINV\" | AVISIT == \"FOLLOW UP\")
277-
#' "
278-
#' ),
281+
#' data = data,
279282
#' modules = modules(
280283
#' tm_g_forest_rsp(
281284
#' label = "Forest Response",

R/tm_g_forest_tte.R

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,26 @@ template_forest_tte <- function(dataname = "ANL",
243243
#'
244244
#' @inherit module_arguments return seealso
245245
#'
246+
#' @examplesShinylive
247+
#' library(teal.modules.clinical)
248+
#' interactive <- function() TRUE
249+
#' {{ next_example }}
250+
#'
246251
#' @examples
247252
#' library(nestcolor)
253+
#' library(dplyr)
254+
#'
255+
#' data <- teal_data()
256+
#' data <- within(data, {
257+
#' ADSL <- tmc_ex_adsl
258+
#' ADTTE <- tmc_ex_adtte
259+
#' ADSL$RACE <- droplevels(ADSL$RACE) %>% with_label("Race")
260+
#' })
261+
#' datanames(data) <- c("ADSL", "ADTTE")
262+
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
248263
#'
249-
#' ADSL <- tmc_ex_adsl
250-
#' ADTTE <- tmc_ex_adtte
251-
#' ADSL$RACE <- droplevels(ADSL$RACE) %>% with_label("Race")
264+
#' ADSL <- data[["ADSL"]]
265+
#' ADTTE <- data[["ADTTE"]]
252266
#'
253267
#' arm_ref_comp <- list(
254268
#' ARM = list(
@@ -262,15 +276,7 @@ template_forest_tte <- function(dataname = "ANL",
262276
#' )
263277
#'
264278
#' app <- init(
265-
#' data = cdisc_data(
266-
#' ADSL = ADSL,
267-
#' ADTTE = ADTTE,
268-
#' code = "
269-
#' ADSL <- tmc_ex_adsl
270-
#' ADTTE <- tmc_ex_adtte
271-
#' ADSL$RACE <- droplevels(ADSL$RACE) %>% with_label(\"Race\")
272-
#' "
273-
#' ),
279+
#' data = data,
274280
#' modules = modules(
275281
#' tm_g_forest_tte(
276282
#' label = "Forest Survival",

R/tm_g_ipp.R

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,28 +179,33 @@ template_g_ipp <- function(dataname = "ANL",
179179
#'
180180
#' @inherit module_arguments return seealso
181181
#'
182+
#' @examplesShinylive
183+
#' library(teal.modules.clinical)
184+
#' interactive <- function() TRUE
185+
#' {{ next_example }}
186+
#'
182187
#' @examples
183188
#' library(nestcolor)
184189
#' library(dplyr)
185190
#'
186-
#' ADSL <- tmc_ex_adsl %>%
187-
#' slice(1:20) %>%
188-
#' df_explicit_na()
189-
#' ADLB <- tmc_ex_adlb %>%
190-
#' filter(USUBJID %in% ADSL$USUBJID) %>%
191-
#' df_explicit_na() %>%
192-
#' filter(AVISIT != "SCREENING")
191+
#' data <- teal_data()
192+
#' data <- within(data, {
193+
#' ADSL <- tmc_ex_adsl %>%
194+
#' slice(1:20) %>%
195+
#' df_explicit_na()
196+
#' ADLB <- tmc_ex_adlb %>%
197+
#' filter(USUBJID %in% ADSL$USUBJID) %>%
198+
#' df_explicit_na() %>%
199+
#' filter(AVISIT != "SCREENING")
200+
#' })
201+
#' datanames(data) <- c("ADSL", "ADLB")
202+
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
203+
#'
204+
#' ADSL <- data[["ADSL"]]
205+
#' ADLB <- data[["ADLB"]]
193206
#'
194207
#' app <- init(
195-
#' data = cdisc_data(
196-
#' ADSL = ADSL,
197-
#' ADLB = ADLB,
198-
#' code = "
199-
#' ADSL <- tmc_ex_adsl %>% slice(1:20) %>% df_explicit_na()
200-
#' ADLB <- tmc_ex_adlb %>% filter(USUBJID %in% ADSL$USUBJID) %>%
201-
#' df_explicit_na() %>% filter(AVISIT != \"SCREENING\")
202-
#' "
203-
#' ),
208+
#' data = data,
204209
#' modules = modules(
205210
#' tm_g_ipp(
206211
#' label = "Individual Patient Plot",

R/tm_g_km.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,24 @@ template_g_km <- function(dataname = "ANL",
271271
#'
272272
#' @inherit module_arguments return seealso
273273
#'
274+
#' @examplesShinylive
275+
#' library(teal.modules.clinical)
276+
#' interactive <- function() TRUE
277+
#' {{ next_example }}
278+
#'
274279
#' @examples
275280
#' library(nestcolor)
276281
#'
277-
#' ADSL <- tmc_ex_adsl
278-
#' ADTTE <- tmc_ex_adtte
282+
#' data <- teal_data()
283+
#' data <- within(data, {
284+
#' ADSL <- tmc_ex_adsl
285+
#' ADTTE <- tmc_ex_adtte
286+
#' })
287+
#' datanames(data) <- c("ADSL", "ADTTE")
288+
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
289+
#'
290+
#' ADSL <- data[["ADSL"]]
291+
#' ADTTE <- data[["ADTTE"]]
279292
#'
280293
#' arm_ref_comp <- list(
281294
#' ACTARMCD = list(
@@ -289,14 +302,7 @@ template_g_km <- function(dataname = "ANL",
289302
#' )
290303
#'
291304
#' app <- init(
292-
#' data = cdisc_data(
293-
#' ADSL = ADSL,
294-
#' ADTTE = ADTTE,
295-
#' code = "
296-
#' ADSL <- tmc_ex_adsl
297-
#' ADTTE <- tmc_ex_adtte
298-
#' "
299-
#' ),
305+
#' data = data,
300306
#' modules = modules(
301307
#' tm_g_km(
302308
#' label = "Kaplan-Meier Plot",

0 commit comments

Comments
 (0)