split_fun <- drop_split_levelslyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%analyze_num_patients(vars ="USUBJID",.stats =c("unique", "nonunique"),.labels =c(unique ="Total number of patients with at least one major protocol deviation",nonunique ="Total number of major protocol deviations" ) ) %>%split_rows_by("DVDECOD",split_fun = split_fun,label_pos ="topleft",split_label =obj_label(addv$DVDECOD) ) %>%count_occurrences(vars ="DVTERM") %>%append_varlabels(addv, "DVTERM", indent =1L)result <-build_table(lyt = lyt, df = addv, alt_counts_df = adsl) %>%prune_table() %>%sort_at_path(path =c("DVDECOD", "*", "DVTERM"), scorefun = score_occurrences)result
Category A: Drug X B: Placebo C: Combination
Description (N=134) (N=134) (N=132)
——————————————————————————————————————————————————————————————————————————————————————————————————————————————
Total number of patients with at least one major protocol deviation 28 (20.9%) 22 (16.4%) 18 (13.6%)
Total number of major protocol deviations 49 35 35
EXCLUSION CRITERIA
Active or untreated or other excluded cns metastases 2 (1.5%) 4 (3.0%) 1 (0.8%)
Pregnancy criteria 3 (2.2%) 3 (2.2%) 1 (0.8%)
History of other malignancies within the last 5 years 3 (2.2%) 1 (0.7%) 1 (0.8%)
Uncontrolled concurrent condition 2 (1.5%) 0 3 (2.3%)
Other exclusion criteria 1 (0.7%) 0 2 (1.5%)
Received prior prohibited therapy or medication 2 (1.5%) 1 (0.7%) 0
INCLUSION CRITERIA
No signed ICF at study entry 5 (3.7%) 0 6 (4.5%)
Ineligible cancer type or current cancer stage 3 (2.2%) 2 (1.5%) 4 (3.0%)
Inclusion lab values outside allowed limits 4 (3.0%) 1 (0.7%) 0
Does not meet prior therapy requirements 2 (1.5%) 1 (0.7%) 1 (0.8%)
Inclusion-related test not done/out of window 1 (0.7%) 1 (0.7%) 0
MEDICATION
Discontinued study drug for unspecified reason 3 (2.2%) 2 (1.5%) 1 (0.8%)
Significant deviation from planned dose 3 (2.2%) 1 (0.7%) 2 (1.5%)
Received incorrect study medication 0 3 (2.2%) 1 (0.8%)
Received prohibited concomitant medication 1 (0.7%) 2 (1.5%) 1 (0.8%)
Dose missed or significantly out of window 2 (1.5%) 0 1 (0.8%)
PROCEDURAL
Eligibility-related test not done/out of window 2 (1.5%) 4 (3.0%) 3 (2.3%)
Omission of screening tumor assessment 4 (3.0%) 1 (0.7%) 3 (2.3%)
Missed assessment affecting safety/study outcomes 2 (1.5%) 3 (2.2%) 1 (0.8%)
Failure to sign updated ICF within two visits 2 (1.5%) 1 (0.7%) 1 (0.8%)
Missed 2 or more efficacy assessments 1 (0.7%) 2 (1.5%) 0
Omission of complete lab panel required by protocol 0 0 1 (0.8%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
Code
library(dplyr)library(tern)adsl <- random.cdisc.data::cadsladdv <- random.cdisc.data::caddv# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <-df_explicit_na(adsl)addv <-df_explicit_na(addv)addv <- addv %>%var_relabel(DVDECOD ="Category",DVTERM ="Description" )
library(teal.modules.clinical)## Data reproducible codedata <-teal_data()data <-within(data, { ADSL <- random.cdisc.data::cadsl ADDV <- random.cdisc.data::caddv# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels. ADSL <-df_explicit_na(ADSL) ADDV <-df_explicit_na(ADDV)})datanames <-c("ADSL", "ADDV")datanames(data) <- datanamesjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADDV <- data[["ADDV"]]## Setup Appapp <-init(data = data,modules =modules(tm_t_events(label ="Major Protocol Deviations Table",dataname ="ADDV",arm_var =choices_selected(c("ARM", "ARMCD"), "ARM"),llt =choices_selected(choices =variable_choices(ADDV, c("DVTERM")),selected =c("DVTERM") ),hlt =choices_selected(choices =variable_choices(ADDV, c("DVDECOD")),selected ="DVDECOD" ),add_total =TRUE,event_type ="major protocol deviation" ) ))shinyApp(app$ui, app$server)
Experimental use!
shinylive allow you to modify to run shiny application entirely in the web browser. Modify the code below and click re-run the app to see the results. The performance is slighly worse and some of the features (e.g. downloading) might not work at all.
#| '!! shinylive warning !!': |#| shinylive does not work in self-contained HTML documents.#| Please set `embed-resources: false` in your metadata.#| standalone: true#| viewerHeight: 800#| editorHeight: 200#| components: [viewer, editor]#| layout: vertical# -- WEBR HELPERS --options(webr_pkg_repos = c("r-universe" = "https://insightsengineering.r-universe.dev", getOption("webr_pkg_repos")))# -- APP CODE --library(teal.modules.clinical)## Data reproducible codedata <- teal_data()data <- within(data, { ADSL <- random.cdisc.data::cadsl ADDV <- random.cdisc.data::caddv # Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels. ADSL <- df_explicit_na(ADSL) ADDV <- df_explicit_na(ADDV)})datanames <- c("ADSL", "ADDV")datanames(data) <- datanamesjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADDV <- data[["ADDV"]]## Setup Appapp <- init( data = data, modules = modules( tm_t_events( label = "Major Protocol Deviations Table", dataname = "ADDV", arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"), llt = choices_selected( choices = variable_choices(ADDV, c("DVTERM")), selected = c("DVTERM") ), hlt = choices_selected( choices = variable_choices(ADDV, c("DVDECOD")), selected = "DVDECOD" ), add_total = TRUE, event_type = "major protocol deviation" ) ))shinyApp(app$ui, app$server)