Skip to content

Instantly share code, notes, and snippets.

@kpagacz
Created September 29, 2025 09:41
Show Gist options
  • Save kpagacz/67d2bbf31e1d9537947303fd982bc822 to your computer and use it in GitHub Desktop.
Save kpagacz/67d2bbf31e1d9537947303fd982bc822 to your computer and use it in GitHub Desktop.
shinylive snippet from bookmarking.qmd chunk 1
library(teal)
library(teal.modules.general)
library(teal.data)
library(pharmaverseadam)
# Enhanced bookmarking example with multiple modules
data("adsl", package = "pharmaverseadam")
data("adae", package = "pharmaverseadam")
data("advs", package = "pharmaverseadam")
# Create comprehensive dataset
bookmark_demo_data <- teal_data()
bookmark_demo_data <- within(bookmark_demo_data, {
ADSL <- adsl
ADAE <- adae
ADVS <- advs
})
# Configure join keys
join_keys(bookmark_demo_data) <- default_cdisc_join_keys[names(bookmark_demo_data)]
# Application with rich functionality for bookmarking
comprehensive_app <- teal::init(
data = bookmark_demo_data,
modules = teal::modules(
# Data exploration module
tm_data_table(
label = "Data Explorer",
dataname = "ADSL"
),
# Statistical analysis modules
teal::modules(
label = "Statistical Analysis",
tm_g_distribution(
label = "Distribution Analysis",
dataname = "ADSL",
dist_var = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(bookmark_demo_data[["ADSL"]], c("AGE", "BMRKR1", "BMRKR2")),
selected = "AGE",
multiple = FALSE
)
),
strata_var = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(bookmark_demo_data[["ADSL"]], c("ARM", "SEX", "RACE")),
selected = NULL,
multiple = FALSE
)
)
),
tm_g_scatterplot(
label = "Correlation Analysis",
dataname = "ADSL",
x = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(bookmark_demo_data[["ADSL"]], c("AGE", "BMRKR1", "BMRKR2")),
selected = "AGE",
multiple = FALSE
)
),
y = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(bookmark_demo_data[["ADSL"]], c("BMRKR1", "BMRKR2")),
selected = "BMRKR1",
multiple = FALSE
)
),
color_by = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(bookmark_demo_data[["ADSL"]], c("ARM", "SEX")),
selected = NULL,
multiple = FALSE
)
)
)
),
# Safety analysis
tm_t_events(
label = "Safety Analysis",
dataname = "ADAE",
arm_var = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(bookmark_demo_data[["ADSL"]], c("ARM", "ARMCD")),
selected = "ARM",
multiple = FALSE
)
),
llt = data_extract_spec(
dataname = "ADAE",
select = select_spec(
choices = variable_choices(bookmark_demo_data[["ADAE"]], c("AEDECOD", "AELLT")),
selected = "AEDECOD",
multiple = FALSE
)
)
)
),
title = "Comprehensive Bookmarking Demo"
)
# Launch application
# shinyApp(comprehensive_app$ui, comprehensive_app$server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment