For the EGT04 template, data imputation should be avoided, and missing data explicit and accounted for, so the contingency table sum adds up to the group N. For illustration purposes, missing data are added to the example dataset.
Code
library(scda)library(scda.2022)library(tern)library(dplyr)set.seed(123)adsl <-synthetic_cdisc_dataset("latest", "adsl")adeg <-synthetic_cdisc_dataset("latest", "adeg")# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <-df_explicit_na(adsl)adeg <-df_explicit_na(adeg, omit_columns =c("AVALC", "BASEC"))adeg_labels <-var_labels(adeg)adeg_f <-subset( adeg, PARAMCD =="ECGINTP"&# Analysis in terms of "NORMAL"/"ABNORMAL" (AVALC) SAFFL =="Y"&# "Safety Population Flag" ONTRTFL =="Y"&# "On Treatment Record Flag" WORS02FL =="Y"# "Worst Post-Baseline Observation")adeg_f$AVALC[sample(seq_len(nrow(adeg_f)), size =5)] <-"Missing"adeg_f$BASEC[sample(seq_len(nrow(adeg_f)), size =5)] <-"Missing"adeg_f$AVALC <-factor( adeg_f$AVALC,levels =c("NORMAL", "ABNORMAL", "Missing"),labels =c("Normal", "Abnormal", "Missing"))adeg_f$BASEC <-factor( adeg_f$BASEC,levels =c("NORMAL", "ABNORMAL", "Missing"),labels =c("Normal", "Abnormal", "Missing"))var_labels(adeg_f) <- adeg_labelsadeg_f <- adeg_f %>%var_relabel(BASEC ="Baseline")# Temprary solution for over arching columnadeg_f <- adeg_f %>%mutate(postbaseline_label ="Post-Baseline")
The EGT04 template consists of a stacked list of contingency tables, one per group. For each group, the nās across all cells must add up to the group N in the analysis, and percentages are calculated using N as the denominator.
Description of Planned Arm Post-Baseline
Baseline Normal Abnormal Missing
---------------------------------------------------------------
A: Drug X (N=134)
Normal 20 (14.9%) 81 (60.4%) 1 (0.7%)
Abnormal 11 (8.2%) 19 (14.2%) 0
Missing 0 1 (0.7%) 1 (0.7%)
B: Placebo (N=134)
Normal 18 (13.4%) 81 (60.4%) 2 (1.5%)
Abnormal 3 (2.2%) 28 (20.9%) 0
Missing 0 2 (1.5%) 0
C: Combination (N=132)
Normal 26 (19.7%) 69 (52.3%) 1 (0.8%)
Abnormal 6 (4.5%) 29 (22%) 0
Missing 1 (0.8%) 0 0
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. Altenatively, copy the code and click here to open WebR in a new tab.
Code
# In progress
Timestamp
Code
Sys.time()
[1] "2024-05-08 17:40:23 UTC"
Session Info
Code
sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
locale:
[1] C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.1.4 tern_0.9.4 rtables_0.6.7 magrittr_2.0.3
[5] formatters_0.5.6 scda.2022_0.1.5 scda_0.1.6
loaded via a namespace (and not attached):
[1] Matrix_1.7-0 gtable_0.3.5 jsonlite_1.8.8 compiler_4.4.0
[5] brio_1.1.5 tidyselect_1.2.1 tidyr_1.3.1 splines_4.4.0
[9] scales_1.3.0 yaml_2.3.8 fastmap_1.1.1 lattice_0.22-6
[13] ggplot2_3.5.1 R6_2.5.1 generics_0.1.3 knitr_1.46
[17] forcats_1.0.0 rbibutils_2.2.16 htmlwidgets_1.6.4 backports_1.4.1
[21] checkmate_2.3.1 tibble_3.2.1 munsell_0.5.1 pillar_1.9.0
[25] rlang_1.1.3 utf8_1.2.4 testthat_3.2.1.1 stringi_1.8.4
[29] broom_1.0.5 xfun_0.43 cli_3.6.2 Rdpack_2.6
[33] digest_0.6.35 grid_4.4.0 lifecycle_1.0.4 vctrs_0.6.5
[37] evaluate_0.23 glue_1.7.0 codetools_0.2-20 survival_3.6-4
[41] fansi_1.0.6 colorspace_2.1-0 purrr_1.0.2 rmarkdown_2.26
[45] tools_4.4.0 pkgconfig_2.0.3 htmltools_0.5.8.1
.lock file
Download the .lock file and use renv::restore() on it to recreate environment used to generate this website.
---title: EGT04subtitle: Shift Table of Qualitative ECG Assessments---------------------------------------------------------------------------{{< include ../../_utils/envir_hook.qmd >}}:::: {.panel-tabset}## Data SetupFor the EGT04 template, data imputation should be avoided, and missing data explicit and accounted for, so the contingency table sum adds up to the group N.For illustration purposes, missing data are added to the example dataset.```{r setup, message = FALSE}#| code-fold: showlibrary(scda)library(scda.2022)library(tern)library(dplyr)set.seed(123)adsl <- synthetic_cdisc_dataset("latest", "adsl")adeg <- synthetic_cdisc_dataset("latest", "adeg")# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <- df_explicit_na(adsl)adeg <- df_explicit_na(adeg, omit_columns = c("AVALC", "BASEC"))adeg_labels <- var_labels(adeg)adeg_f <- subset( adeg, PARAMCD == "ECGINTP" & # Analysis in terms of "NORMAL"/"ABNORMAL" (AVALC) SAFFL == "Y" & # "Safety Population Flag" ONTRTFL == "Y" & # "On Treatment Record Flag" WORS02FL == "Y" # "Worst Post-Baseline Observation")adeg_f$AVALC[sample(seq_len(nrow(adeg_f)), size = 5)] <- "Missing"adeg_f$BASEC[sample(seq_len(nrow(adeg_f)), size = 5)] <- "Missing"adeg_f$AVALC <- factor( adeg_f$AVALC, levels = c("NORMAL", "ABNORMAL", "Missing"), labels = c("Normal", "Abnormal", "Missing"))adeg_f$BASEC <- factor( adeg_f$BASEC, levels = c("NORMAL", "ABNORMAL", "Missing"), labels = c("Normal", "Abnormal", "Missing"))var_labels(adeg_f) <- adeg_labelsadeg_f <- adeg_f %>% var_relabel(BASEC = "Baseline")# Temprary solution for over arching columnadeg_f <- adeg_f %>% mutate(postbaseline_label = "Post-Baseline")```## Standard TableThe EGT04 template consists of a stacked list of contingency tables, one per group.For each group, the n's across all cells must add up to the group N in the analysis, and percentages are calculated using N as the denominator.::: {.panel-tabset .nav-justified group="webr"}## {{< fa regular file-lines sm fw >}} Preview```{r variant1, test = list(result_v1 = "result")}# Define the split functionsplit_fun <- drop_split_levelslyt <- basic_table() %>% split_cols_by("postbaseline_label") %>% split_cols_by("AVALC") %>% split_rows_by("ARM", split_fun = split_fun, label_pos = "topleft", split_label = obj_label(adeg_f$ARM)) %>% add_rowcounts() %>% analyze_vars( "BASEC", denom = "N_row", .stats = "count_fraction", na.rm = FALSE ) %>% append_varlabels(adeg_f, c("BASEC"), indent = 1L)result <- build_table(lyt, adeg_f)result````r webr_code_labels <- c("setup", "variant1")`{{< include ../../_utils/webr.qmd >}}:::{{< include ../../_utils/save_results.qmd >}}## `teal` App```{r teal, opts.label = c("skip_if_testing", "app")}#| code-fold: show# In progress```{{< include ../../repro.qmd >}}::::