Skip to content

Commit

Permalink
use of roxy.shinylive (#1230)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pawelru and dependabot-preview[bot] authored Oct 4, 2024
1 parent f2895ee commit 92d03df
Show file tree
Hide file tree
Showing 78 changed files with 1,391 additions and 806 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ vignettes/*.R
coverage.*
tests/testthat/_snaps/**/*.new.md
tests/testthat/_snaps/**/*.new.svg
/doc/
/Meta/
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Suggests:
lubridate (>= 1.7.9),
nestcolor (>= 0.1.0),
pkgload,
roxy.shinylive,
rvest,
shinytest2,
styler,
Expand All @@ -90,12 +91,12 @@ Config/Needs/verdepcheck: insightsengineering/teal,
insightsengineering/teal.widgets, insightsengineering/tern.gee,
insightsengineering/tern.mmrm, shosaco/vistime, tidyverse/forcats,
yihui/knitr, tidyverse/lubridate, insightsengineering/nestcolor,
r-lib/pkgload, tidyverse/rvest, rstudio/shinytest2, r-lib/styler,
r-lib/pkgload, insightsengineering/roxy.shinylive, tidyverse/rvest, rstudio/shinytest2, r-lib/styler,
r-lib/testthat, r-lib/withr
Config/Needs/website: insightsengineering/nesttemplate
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
Roxygen: list(markdown = TRUE, packages = c("roxy.shinylive"))
RoxygenNote: 7.3.2
11 changes: 8 additions & 3 deletions R/tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,14 @@ template_a_gee <- function(output_table,
#'
#' @inherit module_arguments return seealso
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
#' {{ next_example }}
#'
#' @examples
#' library(dplyr)
#'
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl
Expand All @@ -152,9 +158,8 @@ template_a_gee <- function(output_table,
#' ) %>%
#' droplevels()
#' })
#' datanames <- c("ADSL", "ADQS")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' datanames(data) <- c("ADSL", "ADQS")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' app <- init(
#' data = data,
Expand Down
11 changes: 8 additions & 3 deletions R/tm_a_mmrm.R
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,14 @@ template_mmrm_plots <- function(fit_name,
#'
#' @inherit module_arguments return seealso
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
#' {{ next_example }}
#'
#' @examples
#' library(dplyr)
#'
#' arm_ref_comp <- list(
#' ARMCD = list(
#' ref = "ARM B",
Expand All @@ -485,10 +491,9 @@ template_mmrm_plots <- function(fit_name,
#' as.factor() #' making consecutive numeric factor
#' )
#' })
#' datanames(data) <- c("ADSL", "ADQS")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' datanames <- c("ADSL", "ADQS")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' app <- init(
#' data = data,
#' modules = modules(
Expand Down
33 changes: 19 additions & 14 deletions R/tm_g_barchart_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,31 @@
#'
#' @inherit module_arguments return seealso
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
#' {{ next_example }}
#'
#' @examples
#' library(nestcolor)
#' library(dplyr)
#'
#' ADSL <- tmc_ex_adsl %>%
#' mutate(ITTFL = factor("Y") %>%
#' with_label("Intent-To-Treat Population Flag"))
#' ADAE <- tmc_ex_adae %>%
#' filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")))
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl %>%
#' mutate(ITTFL = factor("Y") %>%
#' with_label("Intent-To-Treat Population Flag"))
#' ADAE <- tmc_ex_adae %>%
#' filter(!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X")))
#' })
#' datanames(data) <- c("ADSL", "ADAE")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' ADSL <- data[["ADSL"]]
#' ADAE <- data[["ADAE"]]
#'
#' app <- init(
#' data = cdisc_data(
#' ADSL = ADSL,
#' ADAE = ADAE,
#' code = "ADSL <- tmc_ex_adsl %>%
#' mutate(ITTFL = factor(\"Y\") %>%
#' with_label(\"Intent-To-Treat Population Flag\"))
#' ADAE <- tmc_ex_adae %>%
#' filter(!((AETOXGR == 1) & (AESEV == \"MILD\") & (ARM == \"A: Drug X\")))"
#' ),
#' data = data,
#' modules = modules(
#' tm_g_barchart_simple(
#' label = "ADAE Analysis",
Expand Down
30 changes: 16 additions & 14 deletions R/tm_g_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,27 @@ template_g_ci <- function(dataname,
#'
#' @inherit module_arguments return seealso
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
#' {{ next_example }}
#'
#' @examples
#' library(nestcolor)
#'
#' ADSL <- tmc_ex_adsl
#' ADLB <- tmc_ex_adlb
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl
#' ADLB <- tmc_ex_adlb
#' })
#' datanames(data) <- c("ADSL", "ADLB")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' ADSL <- data[["ADSL"]]
#' ADLB <- data[["ADLB"]]
#'
#' app <- init(
#' data = cdisc_data(
#' ADSL = ADSL,
#' ADLB = ADLB,
#' code = "
#' ADSL <- tmc_ex_adsl
#' ADLB <- tmc_ex_adlb
#' "
#' ),
#' data = data,
#' modules = modules(
#' tm_g_ci(
#' label = "Confidence Interval Plot",
Expand Down Expand Up @@ -253,10 +259,6 @@ template_g_ci <- function(dataname,
#' )
#' )
#' )
#' ),
#' header = "Example of Confidence Interval Plot",
#' footer = tags$p(
#' class = "text-muted", "Source: `teal.modules.clinical::tm_g_ci`"
#' )
#' )
#' if (interactive()) {
Expand Down
35 changes: 19 additions & 16 deletions R/tm_g_forest_rsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,28 @@ template_forest_rsp <- function(dataname = "ANL",
#'
#' @inherit module_arguments return seealso
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
#' {{ next_example }}
#'
#' @examples
#' library(nestcolor)
#' library(dplyr)
#'
#' ADSL <- tmc_ex_adsl
#' ADRS <- tmc_ex_adrs %>%
#' mutate(AVALC = d_onco_rsp_label(AVALC) %>%
#' with_label("Character Result/Finding")) %>%
#' filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl
#' ADRS <- tmc_ex_adrs %>%
#' mutate(AVALC = d_onco_rsp_label(AVALC) %>%
#' with_label("Character Result/Finding")) %>%
#' filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
#' })
#' datanames(data) <- c("ADSL", "ADRS")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' ADSL <- data[["ADSL"]]
#' ADRS <- data[["ADRS"]]
#'
#' arm_ref_comp <- list(
#' ARM = list(
Expand All @@ -265,17 +278,7 @@ template_forest_rsp <- function(dataname = "ANL",
#' )
#'
#' app <- init(
#' data = cdisc_data(
#' ADSL = ADSL,
#' ADRS = ADRS,
#' code = "
#' ADSL <- tmc_ex_adsl
#' ADRS <- tmc_ex_adrs %>%
#' mutate(AVALC = d_onco_rsp_label(AVALC) %>%
#' with_label(\"Character Result/Finding\")) %>%
#' filter(PARAMCD != \"OVRINV\" | AVISIT == \"FOLLOW UP\")
#' "
#' ),
#' data = data,
#' modules = modules(
#' tm_g_forest_rsp(
#' label = "Forest Response",
Expand Down
30 changes: 18 additions & 12 deletions R/tm_g_forest_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,26 @@ template_forest_tte <- function(dataname = "ANL",
#'
#' @inherit module_arguments return seealso
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
#' {{ next_example }}
#'
#' @examples
#' library(nestcolor)
#' library(dplyr)
#'
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl
#' ADTTE <- tmc_ex_adtte
#' ADSL$RACE <- droplevels(ADSL$RACE) %>% with_label("Race")
#' })
#' datanames(data) <- c("ADSL", "ADTTE")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' ADSL <- tmc_ex_adsl
#' ADTTE <- tmc_ex_adtte
#' ADSL$RACE <- droplevels(ADSL$RACE) %>% with_label("Race")
#' ADSL <- data[["ADSL"]]
#' ADTTE <- data[["ADTTE"]]
#'
#' arm_ref_comp <- list(
#' ARM = list(
Expand All @@ -262,15 +276,7 @@ template_forest_tte <- function(dataname = "ANL",
#' )
#'
#' app <- init(
#' data = cdisc_data(
#' ADSL = ADSL,
#' ADTTE = ADTTE,
#' code = "
#' ADSL <- tmc_ex_adsl
#' ADTTE <- tmc_ex_adtte
#' ADSL$RACE <- droplevels(ADSL$RACE) %>% with_label(\"Race\")
#' "
#' ),
#' data = data,
#' modules = modules(
#' tm_g_forest_tte(
#' label = "Forest Survival",
Expand Down
37 changes: 21 additions & 16 deletions R/tm_g_ipp.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,28 +179,33 @@ template_g_ipp <- function(dataname = "ANL",
#'
#' @inherit module_arguments return seealso
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
#' {{ next_example }}
#'
#' @examples
#' library(nestcolor)
#' library(dplyr)
#'
#' ADSL <- tmc_ex_adsl %>%
#' slice(1:20) %>%
#' df_explicit_na()
#' ADLB <- tmc_ex_adlb %>%
#' filter(USUBJID %in% ADSL$USUBJID) %>%
#' df_explicit_na() %>%
#' filter(AVISIT != "SCREENING")
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl %>%
#' slice(1:20) %>%
#' df_explicit_na()
#' ADLB <- tmc_ex_adlb %>%
#' filter(USUBJID %in% ADSL$USUBJID) %>%
#' df_explicit_na() %>%
#' filter(AVISIT != "SCREENING")
#' })
#' datanames(data) <- c("ADSL", "ADLB")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' ADSL <- data[["ADSL"]]
#' ADLB <- data[["ADLB"]]
#'
#' app <- init(
#' data = cdisc_data(
#' ADSL = ADSL,
#' ADLB = ADLB,
#' code = "
#' ADSL <- tmc_ex_adsl %>% slice(1:20) %>% df_explicit_na()
#' ADLB <- tmc_ex_adlb %>% filter(USUBJID %in% ADSL$USUBJID) %>%
#' df_explicit_na() %>% filter(AVISIT != \"SCREENING\")
#' "
#' ),
#' data = data,
#' modules = modules(
#' tm_g_ipp(
#' label = "Individual Patient Plot",
Expand Down
26 changes: 16 additions & 10 deletions R/tm_g_km.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,24 @@ template_g_km <- function(dataname = "ANL",
#'
#' @inherit module_arguments return seealso
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
#' {{ next_example }}
#'
#' @examples
#' library(nestcolor)
#'
#' ADSL <- tmc_ex_adsl
#' ADTTE <- tmc_ex_adtte
#' data <- teal_data()
#' data <- within(data, {
#' ADSL <- tmc_ex_adsl
#' ADTTE <- tmc_ex_adtte
#' })
#' datanames(data) <- c("ADSL", "ADTTE")
#' join_keys(data) <- default_cdisc_join_keys[datanames(data)]
#'
#' ADSL <- data[["ADSL"]]
#' ADTTE <- data[["ADTTE"]]
#'
#' arm_ref_comp <- list(
#' ACTARMCD = list(
Expand All @@ -289,14 +302,7 @@ template_g_km <- function(dataname = "ANL",
#' )
#'
#' app <- init(
#' data = cdisc_data(
#' ADSL = ADSL,
#' ADTTE = ADTTE,
#' code = "
#' ADSL <- tmc_ex_adsl
#' ADTTE <- tmc_ex_adtte
#' "
#' ),
#' data = data,
#' modules = modules(
#' tm_g_km(
#' label = "Kaplan-Meier Plot",
Expand Down
Loading

0 comments on commit 92d03df

Please sign in to comment.