diff --git a/appendix/reproducibility.html b/appendix/reproducibility.html
index 4ab3fb8c18..d33fa6cf2d 100644
--- a/appendix/reproducibility.html
+++ b/appendix/reproducibility.html
@@ -1225,7 +1225,7 @@
)
@@ -1421,7 +1421,7 @@
other attached packages:
[1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005
- [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011
+ [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012
[5] teal.data_0.3.0.9003 shiny_1.7.5
[7] nestcolor_0.1.2.9004 scda_0.1.6.9012
[9] tern_0.9.0.9002 rtables_0.6.3.9000
@@ -1439,7 +1439,7 @@
[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25
[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6
[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4
-[31] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0
+[31] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0
[34] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1
[37] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2
[40] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0
diff --git a/graphs/other/mng01_files/figure-html/teal-1.png b/graphs/other/mng01_files/figure-html/teal-1.png
index 38f2a8aa1a..ef43684d65 100644
Binary files a/graphs/other/mng01_files/figure-html/teal-1.png and b/graphs/other/mng01_files/figure-html/teal-1.png differ
diff --git a/graphs/pharmacokinetic/pkpg04_files/figure-html/plot1-1.png b/graphs/pharmacokinetic/pkpg04_files/figure-html/plot1-1.png
index 75015f306b..b589c284e9 100644
Binary files a/graphs/pharmacokinetic/pkpg04_files/figure-html/plot1-1.png and b/graphs/pharmacokinetic/pkpg04_files/figure-html/plot1-1.png differ
diff --git a/search.json b/search.json
index 6fdb15ab41..0fb423c332 100644
--- a/search.json
+++ b/search.json
@@ -116,35 +116,35 @@
"href": "graphs/other/fstg01.html",
"title": "FSTG01",
"section": "",
- "text": "Data Setup\nStandard Plot\nPlot Specifying Class Variables and Options for the Treatment Variable\nPlot Selecting Columns and Changing the Alpha Level\nPlot with Fixed Symbol Size\nPlot of CR Only, Setting Values Indicating Response\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\nlibrary(nestcolor)\n\nadsl_f <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n select(STUDYID, USUBJID, ARMCD, ARM, SEX, BMRKR2, STRATA1, STRATA2)\n\nadrs_f <- synthetic_cdisc_dataset(\"latest\", \"adrs\") %>%\n filter(PARAMCD == \"INVET\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVISIT, AVALC)\n\nanl <- inner_join(adsl_f, adrs_f, by = c(\"STUDYID\", \"USUBJID\"))\nanl <- df_explicit_na(anl)\nanl_labels <- var_labels(anl)\n\nanl_rsp_arms_ab <- anl %>%\n mutate(is_rsp = AVALC %in% c(\"CR\", \"PR\")) %>%\n filter(ARMCD %in% c(\"ARM B\", \"ARM A\")) %>%\n mutate(\n ARMCD = relevel(ARMCD, ref = \"ARM B\") %>%\n droplevels(),\n ARM = relevel(ARM, ref = \"B: Placebo\") %>%\n droplevels()\n ) %>%\n droplevels()\nvar_labels(anl_rsp_arms_ab) <- c(anl_labels, is_rsp = \"Is Responder\")\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_rsp_arms_ab,\n conf_level = 0.95\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result\n)\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl_rsp_comb_arms_ac <- anl %>%\n mutate(is_rsp = AVALC %in% c(\"CR\", \"PR\")) %>%\n filter(ARMCD %in% c(\"ARM B\", \"ARM A\", \"ARM C\")) %>%\n mutate(\n ARMCD = relevel(ARMCD, ref = \"ARM B\") %>%\n droplevels() %>%\n combine_levels(levels = c(\"ARM A\", \"ARM C\")),\n ARM = relevel(ARM, ref = \"B: Placebo\") %>%\n droplevels() %>%\n combine_levels(levels = c(\"A: Drug X\", \"C: Combination\")),\n # reorder levels of SEX\n SEX = forcats::fct_relevel(SEX, \"M\", \"F\"),\n # reorder levels of STRATA1 by frequency\n STRATA1 = forcats::fct_infreq(STRATA1)\n ) %>%\n droplevels()\nvar_labels(anl_rsp_comb_arms_ac) <- c(anl_labels, is_rsp = \"Is Responder\")\n\ndf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARMCD\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_rsp_comb_arms_ac,\n conf_level = 0.95\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_rsp_arms_ab,\n conf_level = 0.90\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_rsp_arms_ab,\n conf_level = 0.95\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result,\n col_symbol_size = NULL\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl_cr_arms_ab <- anl %>%\n mutate(is_rsp = AVALC == \"CR\") %>%\n filter(ARMCD %in% c(\"ARM B\", \"ARM A\")) %>%\n mutate(\n ARMCD = relevel(ARMCD, ref = \"ARM B\") %>%\n droplevels(),\n ARM = relevel(ARM, ref = \"B: Placebo\") %>%\n droplevels()\n ) %>%\n droplevels()\nvar_labels(anl_cr_arms_ab) <- c(anl_labels, is_rsp = \"Is CR\")\n\ndf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_cr_arms_ab,\n conf_level = 0.95\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\narm_ref_comp <- list(\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n ),\n ARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADRS\", ADRS, code = 'ADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")'),\n check = TRUE\n ),\n modules = modules(\n tm_g_forest_rsp(\n label = \"Forest Response\",\n dataname = \"ADRS\",\n arm_var = choices_selected(\n variable_choices(ADSL, c(\"ARM\", \"ARMCD\")),\n \"ARMCD\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(ADRS, \"PARAMCD\", \"PARAM\"),\n \"BESRSPI\"\n ),\n subgroup_var = choices_selected(\n variable_choices(ADSL, names(ADSL)),\n c(\"BMRKR2\", \"SEX\")\n ),\n strata_var = choices_selected(\n variable_choices(ADSL, c(\"STRATA1\", \"STRATA2\")),\n \"STRATA2\"\n ),\n plot_height = c(600L, 200L, 2000L),\n plot_width = c(1100L, 200L, 2000L)\n )\n )\n)\n\n[INFO] 2023-09-08 20:06:48.5118 pid:10931 token:[] teal.modules.clinical Initializing tm_g_forest_rsp\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 R6_2.5.1 Rdpack_2.4 \n[67] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[70] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[73] teal.reporter_0.2.1 httpuv_1.6.11 bslib_0.5.1 \n[76] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[79] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[82] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Plot\nPlot Specifying Class Variables and Options for the Treatment Variable\nPlot Selecting Columns and Changing the Alpha Level\nPlot with Fixed Symbol Size\nPlot of CR Only, Setting Values Indicating Response\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\nlibrary(nestcolor)\n\nadsl_f <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n select(STUDYID, USUBJID, ARMCD, ARM, SEX, BMRKR2, STRATA1, STRATA2)\n\nadrs_f <- synthetic_cdisc_dataset(\"latest\", \"adrs\") %>%\n filter(PARAMCD == \"INVET\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVISIT, AVALC)\n\nanl <- inner_join(adsl_f, adrs_f, by = c(\"STUDYID\", \"USUBJID\"))\nanl <- df_explicit_na(anl)\nanl_labels <- var_labels(anl)\n\nanl_rsp_arms_ab <- anl %>%\n mutate(is_rsp = AVALC %in% c(\"CR\", \"PR\")) %>%\n filter(ARMCD %in% c(\"ARM B\", \"ARM A\")) %>%\n mutate(\n ARMCD = relevel(ARMCD, ref = \"ARM B\") %>%\n droplevels(),\n ARM = relevel(ARM, ref = \"B: Placebo\") %>%\n droplevels()\n ) %>%\n droplevels()\nvar_labels(anl_rsp_arms_ab) <- c(anl_labels, is_rsp = \"Is Responder\")\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_rsp_arms_ab,\n conf_level = 0.95\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result\n)\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl_rsp_comb_arms_ac <- anl %>%\n mutate(is_rsp = AVALC %in% c(\"CR\", \"PR\")) %>%\n filter(ARMCD %in% c(\"ARM B\", \"ARM A\", \"ARM C\")) %>%\n mutate(\n ARMCD = relevel(ARMCD, ref = \"ARM B\") %>%\n droplevels() %>%\n combine_levels(levels = c(\"ARM A\", \"ARM C\")),\n ARM = relevel(ARM, ref = \"B: Placebo\") %>%\n droplevels() %>%\n combine_levels(levels = c(\"A: Drug X\", \"C: Combination\")),\n # reorder levels of SEX\n SEX = forcats::fct_relevel(SEX, \"M\", \"F\"),\n # reorder levels of STRATA1 by frequency\n STRATA1 = forcats::fct_infreq(STRATA1)\n ) %>%\n droplevels()\nvar_labels(anl_rsp_comb_arms_ac) <- c(anl_labels, is_rsp = \"Is Responder\")\n\ndf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARMCD\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_rsp_comb_arms_ac,\n conf_level = 0.95\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_rsp_arms_ab,\n conf_level = 0.90\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_rsp_arms_ab,\n conf_level = 0.95\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result,\n col_symbol_size = NULL\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl_cr_arms_ab <- anl %>%\n mutate(is_rsp = AVALC == \"CR\") %>%\n filter(ARMCD %in% c(\"ARM B\", \"ARM A\")) %>%\n mutate(\n ARMCD = relevel(ARMCD, ref = \"ARM B\") %>%\n droplevels(),\n ARM = relevel(ARM, ref = \"B: Placebo\") %>%\n droplevels()\n ) %>%\n droplevels()\nvar_labels(anl_cr_arms_ab) <- c(anl_labels, is_rsp = \"Is CR\")\n\ndf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"is_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"BMRKR2\"),\n strata_var = \"STRATA2\"\n ),\n data = anl_cr_arms_ab,\n conf_level = 0.95\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\narm_ref_comp <- list(\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n ),\n ARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADRS\", ADRS, code = 'ADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")'),\n check = TRUE\n ),\n modules = modules(\n tm_g_forest_rsp(\n label = \"Forest Response\",\n dataname = \"ADRS\",\n arm_var = choices_selected(\n variable_choices(ADSL, c(\"ARM\", \"ARMCD\")),\n \"ARMCD\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(ADRS, \"PARAMCD\", \"PARAM\"),\n \"BESRSPI\"\n ),\n subgroup_var = choices_selected(\n variable_choices(ADSL, names(ADSL)),\n c(\"BMRKR2\", \"SEX\")\n ),\n strata_var = choices_selected(\n variable_choices(ADSL, c(\"STRATA1\", \"STRATA2\")),\n \"STRATA2\"\n ),\n plot_height = c(600L, 200L, 2000L),\n plot_width = c(1100L, 200L, 2000L)\n )\n )\n)\n\n[INFO] 2023-09-09 18:32:47.2621 pid:10947 token:[] teal.modules.clinical Initializing tm_g_forest_rsp\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 R6_2.5.1 Rdpack_2.4 \n[67] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[70] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[73] teal.reporter_0.2.1 httpuv_1.6.11 bslib_0.5.1 \n[76] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[79] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[82] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "graphs/other/ippg01.html",
"href": "graphs/other/ippg01.html",
"title": "IPPG01",
"section": "",
- "text": "For illustration purposes, we will subset the adlb dataset for safety population in treatment arm A and a specific lab parameter (ALT).\n\n\nData Setup\nStandard Plot\nPlot with Patient Baselines as Reference\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(nestcolor)\n\n# use small sample size\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:15)\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadlb <- df_explicit_na(adlb)\n\nadlb_f <- adlb %>%\n filter(\n SAFFL == \"Y\",\n PARAMCD == \"ALT\",\n AVISIT != \"SCREENING\",\n ARMCD == \"ARM A\"\n ) %>%\n mutate(Patient_ID = sub(\".*id-\", \"\", USUBJID))\n\n\n\n\nThe user can select different plotting_choices depending on their preference. To demonstrate, separate plots are produced with a maximum of 3 observations each.\n\nCodeplots <- g_ipp(\n df = adlb_f,\n xvar = \"AVISIT\",\n yvar = \"AVAL\",\n xlab = \"Visit\",\n ylab = \"SGOT/ALT (U/L)\",\n id_var = \"Patient_ID\",\n title = \"Individual Patient Plots\",\n subtitle = \"Treatment Arm A\",\n plotting_choices = \"split_by_max_obs\",\n max_obs_per_plot = 3\n)\nplots\n\n[[1]]\n\n\n\n\n\n\n[[2]]\n\n\n\n\n\n\n\nHere, patients’ individual baseline values will be shown for reference. Note that users can provide their own custom theme to the function via the ggtheme argument.\n\nCodeplots <- g_ipp(\n df = adlb_f,\n xvar = \"AVISIT\",\n yvar = \"AVAL\",\n xlab = \"Visit\",\n ylab = \"SGOT/ALT (U/L)\",\n id_var = \"Patient_ID\",\n title = \"Individual Patient Plots\",\n subtitle = \"Treatment Arm A\",\n add_baseline_hline = TRUE,\n yvar_baseline = \"BASE\",\n ggtheme = theme_minimal(),\n plotting_choices = \"split_by_max_obs\",\n max_obs_per_plot = 3\n)\nplots\n\n[[1]]\n\n\n\n\n\n\n[[2]]\n\n\n\n\n\n\n\n\nCodelibrary(teal)\nlibrary(teal.modules.clinical)\nlibrary(tern)\nlibrary(scda)\n\n# use small sample size\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:15)\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb) %>%\n dplyr::filter(AVISIT != \"SCREENING\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:15)\n ADSL <- df_explicit_na(ADSL)'\n ),\n cdisc_dataset(\n \"ADLB\",\n adlb,\n code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n ADLB <- df_explicit_na(ADLB) %>%\n dplyr::filter(USUBJID %in% ADSL$USUBJID,\n AVISIT != \"SCREENING\")'\n )\n ),\n modules = modules(\n tm_g_ipp(\n label = \"Individual Patient Plot\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n value_choices(adlb, c(\"ARMCD\")),\n \"ARM A\"\n ),\n paramcd = choices_selected(\n value_choices(adlb, \"PARAMCD\"),\n \"ALT\"\n ),\n aval_var = choices_selected(\n variable_choices(adlb, c(\"AVAL\")),\n \"AVAL\"\n ),\n avalu_var = choices_selected(\n variable_choices(adlb, c(\"AVALU\")),\n \"AVALU\",\n fixed = TRUE\n ),\n id_var = choices_selected(\n variable_choices(adlb, c(\"USUBJID\")),\n \"USUBJID\",\n fixed = TRUE\n ),\n visit_var = choices_selected(\n variable_choices(adlb, c(\"AVISIT\")),\n \"AVISIT\"\n ),\n base_var = choices_selected(\n variable_choices(adlb, c(\"BASE\")),\n \"BASE\",\n fixed = TRUE\n ),\n add_baseline_hline = FALSE,\n separate_by_obs = FALSE\n )\n )\n)\n\n[INFO] 2023-09-08 20:05:17.1392 pid:10405 token:[] teal.modules.clinical Initializing tm_g_ipp\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 ggplot2_3.4.3 \n [9] dplyr_1.1.2 scda_0.1.6.9012 \n[11] tern_0.9.0.9002 rtables_0.6.3.9000 \n[13] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] processx_3.8.2 survival_3.5-7 compiler_4.3.1 \n[16] sass_0.4.7 rlang_1.1.1 tools_4.3.1 \n[19] utf8_1.2.3 yaml_2.3.7 knitr_1.43 \n[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25 \n[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6 \n[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[31] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] splines_4.3.1 assertthat_0.2.1 vctrs_0.6.3 \n[46] webshot_0.5.5 Matrix_1.6-1 sandwich_3.0-2 \n[49] jsonlite_1.8.7 callr_3.7.3 teal.widgets_0.4.0.9007\n[52] testthat_3.1.10 fontawesome_0.5.1 jquerylib_0.1.4 \n[55] tidyr_1.3.0 glue_1.6.2 ps_1.7.5 \n[58] codetools_0.2-19 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "For illustration purposes, we will subset the adlb dataset for safety population in treatment arm A and a specific lab parameter (ALT).\n\n\nData Setup\nStandard Plot\nPlot with Patient Baselines as Reference\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(nestcolor)\n\n# use small sample size\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:15)\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadlb <- df_explicit_na(adlb)\n\nadlb_f <- adlb %>%\n filter(\n SAFFL == \"Y\",\n PARAMCD == \"ALT\",\n AVISIT != \"SCREENING\",\n ARMCD == \"ARM A\"\n ) %>%\n mutate(Patient_ID = sub(\".*id-\", \"\", USUBJID))\n\n\n\n\nThe user can select different plotting_choices depending on their preference. To demonstrate, separate plots are produced with a maximum of 3 observations each.\n\nCodeplots <- g_ipp(\n df = adlb_f,\n xvar = \"AVISIT\",\n yvar = \"AVAL\",\n xlab = \"Visit\",\n ylab = \"SGOT/ALT (U/L)\",\n id_var = \"Patient_ID\",\n title = \"Individual Patient Plots\",\n subtitle = \"Treatment Arm A\",\n plotting_choices = \"split_by_max_obs\",\n max_obs_per_plot = 3\n)\nplots\n\n[[1]]\n\n\n\n\n\n\n[[2]]\n\n\n\n\n\n\n\nHere, patients’ individual baseline values will be shown for reference. Note that users can provide their own custom theme to the function via the ggtheme argument.\n\nCodeplots <- g_ipp(\n df = adlb_f,\n xvar = \"AVISIT\",\n yvar = \"AVAL\",\n xlab = \"Visit\",\n ylab = \"SGOT/ALT (U/L)\",\n id_var = \"Patient_ID\",\n title = \"Individual Patient Plots\",\n subtitle = \"Treatment Arm A\",\n add_baseline_hline = TRUE,\n yvar_baseline = \"BASE\",\n ggtheme = theme_minimal(),\n plotting_choices = \"split_by_max_obs\",\n max_obs_per_plot = 3\n)\nplots\n\n[[1]]\n\n\n\n\n\n\n[[2]]\n\n\n\n\n\n\n\n\nCodelibrary(teal)\nlibrary(teal.modules.clinical)\nlibrary(tern)\nlibrary(scda)\n\n# use small sample size\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:15)\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb) %>%\n dplyr::filter(AVISIT != \"SCREENING\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:15)\n ADSL <- df_explicit_na(ADSL)'\n ),\n cdisc_dataset(\n \"ADLB\",\n adlb,\n code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n ADLB <- df_explicit_na(ADLB) %>%\n dplyr::filter(USUBJID %in% ADSL$USUBJID,\n AVISIT != \"SCREENING\")'\n )\n ),\n modules = modules(\n tm_g_ipp(\n label = \"Individual Patient Plot\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n value_choices(adlb, c(\"ARMCD\")),\n \"ARM A\"\n ),\n paramcd = choices_selected(\n value_choices(adlb, \"PARAMCD\"),\n \"ALT\"\n ),\n aval_var = choices_selected(\n variable_choices(adlb, c(\"AVAL\")),\n \"AVAL\"\n ),\n avalu_var = choices_selected(\n variable_choices(adlb, c(\"AVALU\")),\n \"AVALU\",\n fixed = TRUE\n ),\n id_var = choices_selected(\n variable_choices(adlb, c(\"USUBJID\")),\n \"USUBJID\",\n fixed = TRUE\n ),\n visit_var = choices_selected(\n variable_choices(adlb, c(\"AVISIT\")),\n \"AVISIT\"\n ),\n base_var = choices_selected(\n variable_choices(adlb, c(\"BASE\")),\n \"BASE\",\n fixed = TRUE\n ),\n add_baseline_hline = FALSE,\n separate_by_obs = FALSE\n )\n )\n)\n\n[INFO] 2023-09-09 18:31:02.4835 pid:10421 token:[] teal.modules.clinical Initializing tm_g_ipp\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 ggplot2_3.4.3 \n [9] dplyr_1.1.2 scda_0.1.6.9012 \n[11] tern_0.9.0.9002 rtables_0.6.3.9000 \n[13] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] processx_3.8.2 survival_3.5-7 compiler_4.3.1 \n[16] sass_0.4.7 rlang_1.1.1 tools_4.3.1 \n[19] utf8_1.2.3 yaml_2.3.7 knitr_1.43 \n[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25 \n[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6 \n[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[31] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] splines_4.3.1 assertthat_0.2.1 vctrs_0.6.3 \n[46] webshot_0.5.5 Matrix_1.6-1 sandwich_3.0-2 \n[49] jsonlite_1.8.7 callr_3.7.3 teal.widgets_0.4.0.9007\n[52] testthat_3.1.10 fontawesome_0.5.1 jquerylib_0.1.4 \n[55] tidyr_1.3.0 glue_1.6.2 ps_1.7.5 \n[58] codetools_0.2-19 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "graphs/other/bwg01.html",
"href": "graphs/other/bwg01.html",
"title": "BWG01",
"section": "",
- "text": "Data Setup\nStandard Plot\nPlot Changing Whiskers\nPlot Adding Outliers\nPlot Specifying Marker for Outliers and Adding Patient ID\nPlot Specifying Marker for Mean\nPlot by Treatment and Timepoint\nPlot by Timepoint and Treatment\nPlot with Table Section\nPlot with Number of Patients only in Table Section\nteal App\nReproducibility\n\n\n\n\nCode# generic code for all plots\nlibrary(scda)\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(nestcolor)\n\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\nadlb <- adlb %>% filter(PARAMCD == \"ALT\" & AVISIT == \"WEEK 2 DAY 15\")\n\n# Definition of boxplot boundaries and whiskers\nfive_num <- function(x, probs = c(0, 0.25, 0.5, 0.75, 1)) {\n r <- quantile(x, probs)\n names(r) <- c(\"ymin\", \"lower\", \"middle\", \"upper\", \"ymax\")\n r\n}\n\n# get outliers based on quantile\n# for outliers based on IQR see coef in geom_boxplot\nget_outliers <- function(x, probs = c(0.05, 0.95)) {\n r <- subset(x, x < quantile(x, probs[1]) | quantile(x, probs[2]) < x)\n if (!is.null(x)) {\n x_names <- subset(names(x), x < quantile(x, probs[1]) | quantile(x, probs[2]) < x)\n names(r) <- x_names\n }\n r\n}\n\n# create theme used for all plots\ntheme_bp <- theme(\n plot.title = element_text(hjust = 0),\n plot.subtitle = element_text(hjust = 0),\n plot.caption = element_text(hjust = 0),\n panel.background = element_rect(fill = \"white\", color = \"grey50\")\n)\n\n# assign fill color and outline color\nfc <- \"#eaeef5\"\noc <- getOption(\"ggplot2.discrete.fill\")[1]\n\n# get plot metadata data to derive coordinates for adding annotations\nbp_annos <- function(bp, color, annos = 1) {\n bp_mdat <- ggplot_build(bp)$data[[1]]\n # bp_metadata <<- bp_mdat\n if (annos == 1) {\n bp <- bp +\n geom_segment(data = bp_mdat, aes(\n x = xmin + (xmax - xmin) / 4, xend = xmax - (xmax - xmin) / 4,\n y = ymax, yend = ymax\n ), size = .5, color = color) +\n geom_segment(data = bp_mdat, aes(\n x = xmin + (xmax - xmin) / 4, xend = xmax - (xmax - xmin) / 4,\n y = ymin, yend = ymin\n ), size = .5, color = color)\n } else {\n bp <- bp +\n geom_segment(data = bp_mdat, aes(\n x = xmin + (xmax - xmin) / 4, xend = xmax - (xmax - xmin) / 4,\n y = ymax, yend = ymax\n ), size = .5, color = color) +\n geom_segment(data = bp_mdat, aes(\n x = xmin + (xmax - xmin) / 4, xend = xmax - (xmax - xmin) / 4,\n y = ymin, yend = ymin\n ), size = .5, color = color) +\n geom_segment(data = bp_mdat, aes(\n x = xmin, xend = xmax,\n y = middle, yend = middle\n ), colour = color, size = .5)\n }\n return(bp)\n}\n\n\n\n\n\nCodebp_1 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(geom = \"boxplot\", fun.data = five_num, fill = fc, color = oc) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the minimum and maximum values.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_1, oc)\n\nWarning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.\nℹ Please use `linewidth` instead.\n\nCodeplot\n\n\n\n\n\n\n\nCodebp_3 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(\n geom = \"boxplot\", fun.data = five_num,\n fun.args = list(probs = c(0.05, 0.25, 0.5, 0.75, 0.95)), fill = fc, color = oc\n ) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the 5th and 95th percentile. Values outside the whiskers have not been plotted.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_3, oc)\nplot\n\n\n\n\n\n\n\nCodebp_4 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(\n geom = \"boxplot\", fun.data = five_num,\n fun.args = list(probs = c(0.05, 0.25, 0.5, 0.75, 0.95)), fill = fc, color = oc\n ) +\n stat_summary(geom = \"point\", fun = get_outliers, shape = 1) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the 5th and 95th percentile.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_4, oc)\nplot\n\n\n\n\n\n\n\nCodeadlb_o <- adlb %>%\n group_by(ARMCD) %>%\n mutate(OUTLIER = AVAL < quantile(AVAL, 0.01) | AVAL > quantile(AVAL, 0.99)) %>%\n filter(OUTLIER == TRUE) %>%\n select(ARMCD, AVAL, USUBJID)\n# Next step may be study-specific: shorten USUBJID to make annotation labels\n# next 2 lines of code split USUBJID by \"-\" and take the last syllable as ID\nn_split <- max(vapply(strsplit(adlb_o$USUBJID, \"-\"), length, numeric(1)))\nadlb_o$ID <- vapply(strsplit(adlb_o$USUBJID, \"-\"), `[[`, n_split, FUN.VALUE = \"a\")\n\nbp_5 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(\n geom = \"boxplot\", fun.data = five_num,\n fun.args = list(probs = c(0.01, 0.25, 0.5, 0.75, 0.99)), fill = fc, color = oc\n ) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n geom_point(data = adlb_o, aes(x = ARMCD, y = AVAL), shape = 1) +\n geom_text(data = adlb_o, aes(x = ARMCD, y = AVAL, label = ID), size = 3, hjust = -0.2) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the largest and smallest observed value within 1.5*IQR.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_5, oc)\nplot\n\n\n\n\n\n\n\nCodebp_6 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n geom_boxplot(fill = fc, color = oc) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 5) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the minimum and maximum values.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_6, oc)\nplot\n\n\n\n\n\n\n\nCodeadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadlb_v <- adlb %>%\n filter(PARAMCD == \"ALT\" &\n AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\", \"WEEK 4 DAY 29\"))\n\nbp_7 <- ggplot(adlb_v, aes(x = AVISIT, y = AVAL)) +\n stat_summary(geom = \"boxplot\", fun.data = five_num, position = position_dodge2(.5), aes(fill = ARMCD, color = ARMCD)) +\n stat_summary(geom = \"point\", fun = mean, aes(group = ARMCD), size = 3, shape = 8, position = position_dodge2(1)) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n caption = \"The whiskers extend to the minimum and maximum values.\",\n x = \"Visit\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_7, oc, 2)\nplot\n\n\n\n\n\n\n\nCodebp_8 <- ggplot(adlb_v, aes(x = ARMCD, y = AVAL)) +\n stat_summary(geom = \"boxplot\", fun.data = five_num, position = position_dodge2(width = .5), aes(fill = AVISIT, color = AVISIT)) +\n stat_summary(geom = \"point\", fun = mean, aes(group = AVISIT), size = 3, shape = 8, position = position_dodge2(1)) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n caption = \"The whiskers extend to the minimum and maximum values.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_8, oc, 2)\nplot\n\n\n\n\n\n\n\nCode# Make wide dataset with summary statistics\nadlb_wide <- adlb %>%\n group_by(ARMCD) %>%\n summarise(\n n = n(),\n mean = round(mean(AVAL), 1),\n median = round(median(AVAL), 1),\n median_ci = paste(round(DescTools::MedianCI(AVAL)[1:2], 1), collapse = \" - \"),\n q1_q3 = paste(round(quantile(AVAL, c(0.25, 0.75)), 1), collapse = \" - \"),\n min_max = paste0(round(min(AVAL), 1), \"-\", max(round(AVAL, 2)))\n )\n\n# Make long dataset\nadlb_long <- tidyr::gather(adlb_wide, key = type, value = stat, n:min_max)\nadlb_long <- adlb_long %>% mutate(\n type_lbl = case_when(\n type == \"n\" ~ \"n\",\n type == \"mean\" ~ \"Mean\",\n type == \"median\" ~ \"Median\",\n type == \"median_ci\" ~ \"95% CI for Median\",\n type == \"q1_q3\" ~ \"25% and 75%-ile\",\n type == \"min_max\" ~ \"Min - Max\"\n )\n)\nadlb_long$type_lbl <- factor(adlb_long$type_lbl,\n levels = c(\"Min - Max\", \"25% and 75%-ile\", \"95% CI for Median\", \"Median\", \"Mean\", \"n\")\n)\n\nbp_9 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(geom = \"boxplot\", fun.data = five_num, fill = fc, color = oc) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\ntbl_theme <- theme(\n panel.border = element_blank(),\n panel.grid.major = element_blank(),\n panel.grid.minor = element_blank(),\n axis.ticks = element_blank(),\n axis.title = element_blank(),\n axis.text.y = element_text(face = \"plain\"),\n axis.text.x = element_blank()\n)\n\ntbl_1 <- ggplot(adlb_long, aes(x = ARMCD, y = type_lbl, label = stat), vjust = 10) +\n geom_text(size = 3) +\n scale_y_discrete(labels = levels(adlb_long$type_lbl)) +\n theme_bw() +\n tbl_theme +\n labs(caption = \"The whiskers extend to the minimum and maximum values.\") +\n theme_bp\n\nplot <- ggpubr::ggarrange(bp_annos(bp_9, oc), tbl_1,\n heights = c(4, 2),\n ncol = 1, nrow = 2, align = \"v\"\n)\nplot\n\n\n\n\n\n\n\nCodetbl_2 <- adlb_long %>%\n filter(type == \"n\") %>%\n ggplot(aes(x = ARMCD, y = type_lbl, label = stat)) +\n geom_text(size = 3) +\n scale_y_discrete(labels = \"n\") +\n theme_bw() +\n tbl_theme +\n labs(caption = \"The whiskers extend to the minimum and maximum values.\") +\n theme_bp\n\nplot <- ggpubr::ggarrange(bp_annos(bp_9, oc), tbl_2,\n heights = c(6, 1),\n ncol = 1, nrow = 2, align = \"v\"\n)\nplot\n\n\n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.general)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# If PARAMCD and AVISIT are not factors, convert to factors\n# Also fill in missing values with \"<Missing>\"\nADLB <- ADLB %>%\n tern::df_explicit_na(\n omit_columns = setdiff(names(ADLB), c(\"PARAMCD\", \"AVISIT\")),\n char_as_factor = TRUE\n )\n\n# If statment below fails, pre-process ADLB to be one record per\n# study, subject, param and visit eg. filter with ANLFL = 'Y'\nstopifnot(nrow(ADLB) == nrow(unique(ADLB[, c(\"STUDYID\", \"USUBJID\", \"PARAMCD\", \"AVISIT\")])))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL),\n cdisc_dataset(\"ADLB\", ADLB, keys = c(\"STUDYID\", \"USUBJID\", \"PARAMCD\", \"AVISIT\")), # do not modify\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n ADLB <- ADLB %>%\n tern::df_explicit_na(\n omit_columns = setdiff(names(ADLB), c(\"PARAMCD\", \"AVISIT\")),\n char_as_factor = TRUE)'\n ),\n modules = modules(\n tm_g_bivariate(\n x = data_extract_spec(\n dataname = \"ADSL\",\n select = select_spec(\n label = \"Select variable:\",\n choices = names(ADSL),\n selected = \"ARMCD\",\n fixed = FALSE\n )\n ),\n y = data_extract_spec(\n dataname = \"ADLB\",\n filter = list(\n filter_spec(\n vars = c(\"PARAMCD\"),\n choices = levels(ADLB$PARAMCD),\n selected = levels(ADLB$PARAMCD)[1],\n multiple = FALSE,\n label = \"Choose lab parameter\"\n ),\n filter_spec(\n vars = c(\"AVISIT\"),\n choices = levels(ADLB$AVISIT),\n selected = levels(ADLB$AVISIT)[1],\n multiple = FALSE,\n label = \"Choose visit\"\n )\n ),\n select = select_spec(\n label = \"Select variable:\",\n choices = names(ADLB),\n selected = \"AVAL\",\n multiple = FALSE,\n fixed = TRUE\n )\n ),\n row_facet = data_extract_spec(\n dataname = \"ADLB\",\n select = select_spec(\n label = \"Select variables:\",\n choices = names(ADLB),\n selected = NULL,\n multiple = FALSE,\n fixed = FALSE\n )\n ),\n col_facet = data_extract_spec(\n dataname = \"ADLB\",\n select = select_spec(\n label = \"Select variables:\",\n choices = names(ADLB),\n selected = NULL,\n multiple = FALSE,\n fixed = FALSE\n )\n )\n )\n )\n)\n\n[INFO] 2023-09-08 20:04:11.7147 pid:10191 token:[] teal.modules.general Initializing tm_g_bivariate\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.general_0.2.16.9006 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 magrittr_2.0.3 \n [5] teal.slice_0.4.0.9011 teal.data_0.3.0.9003 \n [7] shinyTree_0.3.1 shiny_1.7.5 \n [9] ggmosaic_0.3.3 nestcolor_0.1.2.9004 \n[11] ggplot2_3.4.3 dplyr_1.1.2 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] Rdpack_2.4 gld_2.6.6 logger_0.2.2 \n [4] testthat_3.1.10 readxl_1.4.3 rlang_1.1.1 \n [7] e1071_1.7-13 compiler_4.3.1 callr_3.7.3 \n [10] vctrs_0.6.3 formatters_0.5.2.9001 stringr_1.5.0 \n [13] pkgconfig_2.0.3 fastmap_1.1.1 backports_1.4.1 \n [16] ellipsis_0.3.2 fontawesome_0.5.1 labeling_0.4.2 \n [19] utf8_1.2.3 promises_1.2.1 rmarkdown_2.24 \n [22] ps_1.7.5 purrr_1.0.2 xfun_0.40 \n [25] cachem_1.0.8 teal.reporter_0.2.1 jsonlite_1.8.7 \n [28] later_1.3.1 broom_1.0.5 DescTools_0.99.49 \n [31] R6_2.5.1 bslib_0.5.1 stringi_1.7.12 \n [34] car_3.1-2 boot_1.3-28.1 jquerylib_0.1.4 \n [37] brio_1.1.3 cellranger_1.1.0 Rcpp_1.0.11 \n [40] rtables_0.6.3.9000 knitr_1.43 teal.logger_0.1.3.9000 \n [43] httpuv_1.6.11 Matrix_1.6-1 splines_4.3.1 \n [46] tidyselect_1.2.0 rstudioapi_0.15.0 abind_1.4-5 \n [49] yaml_2.3.7 codetools_0.2-19 processx_3.8.2 \n [52] teal.widgets_0.4.0.9007 lattice_0.21-8 tibble_3.2.1 \n [55] withr_2.5.0 evaluate_0.21 survival_3.5-7 \n [58] proxy_0.4-27 shinycssloaders_1.0.0 pillar_1.9.0 \n [61] ggpubr_0.6.0 carData_3.0-5 checkmate_2.2.0 \n [64] shinyjs_2.1.0 plotly_4.10.2 generics_0.1.3 \n [67] munsell_0.5.0 scales_1.2.1 rootSolve_1.8.2.3 \n [70] xtable_1.8-4 class_7.3-22 glue_1.6.2 \n [73] lmom_2.9 lazyeval_0.2.2 tools_4.3.1 \n [76] data.table_1.14.8 webshot_0.5.5 ggsignif_0.6.4 \n [79] forcats_1.0.0 Exact_3.2 mvtnorm_1.2-2 \n [82] cowplot_1.1.1 grid_4.3.1 tidyr_1.3.0 \n [85] rbibutils_2.2.14 colorspace_2.1-0 cli_3.6.1 \n [88] tern_0.9.0.9002 fansi_1.0.4 expm_0.999-7 \n [91] viridisLite_0.4.2 gtable_0.3.3 rstatix_0.7.2 \n [94] sass_0.4.7 digest_0.6.33 ggrepel_0.9.3 \n [97] htmlwidgets_1.6.2 farver_2.1.1 memoise_2.0.1 \n[100] htmltools_0.5.6 lifecycle_1.0.3 shinyWidgets_0.7.6 \n[103] httr_1.4.7 mime_0.12 MASS_7.3-60 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Plot\nPlot Changing Whiskers\nPlot Adding Outliers\nPlot Specifying Marker for Outliers and Adding Patient ID\nPlot Specifying Marker for Mean\nPlot by Treatment and Timepoint\nPlot by Timepoint and Treatment\nPlot with Table Section\nPlot with Number of Patients only in Table Section\nteal App\nReproducibility\n\n\n\n\nCode# generic code for all plots\nlibrary(scda)\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(nestcolor)\n\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\nadlb <- adlb %>% filter(PARAMCD == \"ALT\" & AVISIT == \"WEEK 2 DAY 15\")\n\n# Definition of boxplot boundaries and whiskers\nfive_num <- function(x, probs = c(0, 0.25, 0.5, 0.75, 1)) {\n r <- quantile(x, probs)\n names(r) <- c(\"ymin\", \"lower\", \"middle\", \"upper\", \"ymax\")\n r\n}\n\n# get outliers based on quantile\n# for outliers based on IQR see coef in geom_boxplot\nget_outliers <- function(x, probs = c(0.05, 0.95)) {\n r <- subset(x, x < quantile(x, probs[1]) | quantile(x, probs[2]) < x)\n if (!is.null(x)) {\n x_names <- subset(names(x), x < quantile(x, probs[1]) | quantile(x, probs[2]) < x)\n names(r) <- x_names\n }\n r\n}\n\n# create theme used for all plots\ntheme_bp <- theme(\n plot.title = element_text(hjust = 0),\n plot.subtitle = element_text(hjust = 0),\n plot.caption = element_text(hjust = 0),\n panel.background = element_rect(fill = \"white\", color = \"grey50\")\n)\n\n# assign fill color and outline color\nfc <- \"#eaeef5\"\noc <- getOption(\"ggplot2.discrete.fill\")[1]\n\n# get plot metadata data to derive coordinates for adding annotations\nbp_annos <- function(bp, color, annos = 1) {\n bp_mdat <- ggplot_build(bp)$data[[1]]\n # bp_metadata <<- bp_mdat\n if (annos == 1) {\n bp <- bp +\n geom_segment(data = bp_mdat, aes(\n x = xmin + (xmax - xmin) / 4, xend = xmax - (xmax - xmin) / 4,\n y = ymax, yend = ymax\n ), size = .5, color = color) +\n geom_segment(data = bp_mdat, aes(\n x = xmin + (xmax - xmin) / 4, xend = xmax - (xmax - xmin) / 4,\n y = ymin, yend = ymin\n ), size = .5, color = color)\n } else {\n bp <- bp +\n geom_segment(data = bp_mdat, aes(\n x = xmin + (xmax - xmin) / 4, xend = xmax - (xmax - xmin) / 4,\n y = ymax, yend = ymax\n ), size = .5, color = color) +\n geom_segment(data = bp_mdat, aes(\n x = xmin + (xmax - xmin) / 4, xend = xmax - (xmax - xmin) / 4,\n y = ymin, yend = ymin\n ), size = .5, color = color) +\n geom_segment(data = bp_mdat, aes(\n x = xmin, xend = xmax,\n y = middle, yend = middle\n ), colour = color, size = .5)\n }\n return(bp)\n}\n\n\n\n\n\nCodebp_1 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(geom = \"boxplot\", fun.data = five_num, fill = fc, color = oc) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the minimum and maximum values.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_1, oc)\n\nWarning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.\nℹ Please use `linewidth` instead.\n\nCodeplot\n\n\n\n\n\n\n\nCodebp_3 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(\n geom = \"boxplot\", fun.data = five_num,\n fun.args = list(probs = c(0.05, 0.25, 0.5, 0.75, 0.95)), fill = fc, color = oc\n ) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the 5th and 95th percentile. Values outside the whiskers have not been plotted.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_3, oc)\nplot\n\n\n\n\n\n\n\nCodebp_4 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(\n geom = \"boxplot\", fun.data = five_num,\n fun.args = list(probs = c(0.05, 0.25, 0.5, 0.75, 0.95)), fill = fc, color = oc\n ) +\n stat_summary(geom = \"point\", fun = get_outliers, shape = 1) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the 5th and 95th percentile.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_4, oc)\nplot\n\n\n\n\n\n\n\nCodeadlb_o <- adlb %>%\n group_by(ARMCD) %>%\n mutate(OUTLIER = AVAL < quantile(AVAL, 0.01) | AVAL > quantile(AVAL, 0.99)) %>%\n filter(OUTLIER == TRUE) %>%\n select(ARMCD, AVAL, USUBJID)\n# Next step may be study-specific: shorten USUBJID to make annotation labels\n# next 2 lines of code split USUBJID by \"-\" and take the last syllable as ID\nn_split <- max(vapply(strsplit(adlb_o$USUBJID, \"-\"), length, numeric(1)))\nadlb_o$ID <- vapply(strsplit(adlb_o$USUBJID, \"-\"), `[[`, n_split, FUN.VALUE = \"a\")\n\nbp_5 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(\n geom = \"boxplot\", fun.data = five_num,\n fun.args = list(probs = c(0.01, 0.25, 0.5, 0.75, 0.99)), fill = fc, color = oc\n ) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n geom_point(data = adlb_o, aes(x = ARMCD, y = AVAL), shape = 1) +\n geom_text(data = adlb_o, aes(x = ARMCD, y = AVAL, label = ID), size = 3, hjust = -0.2) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the largest and smallest observed value within 1.5*IQR.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_5, oc)\nplot\n\n\n\n\n\n\n\nCodebp_6 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n geom_boxplot(fill = fc, color = oc) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 5) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n caption = \"The whiskers extend to the minimum and maximum values.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_6, oc)\nplot\n\n\n\n\n\n\n\nCodeadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadlb_v <- adlb %>%\n filter(PARAMCD == \"ALT\" &\n AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\", \"WEEK 4 DAY 29\"))\n\nbp_7 <- ggplot(adlb_v, aes(x = AVISIT, y = AVAL)) +\n stat_summary(geom = \"boxplot\", fun.data = five_num, position = position_dodge2(.5), aes(fill = ARMCD, color = ARMCD)) +\n stat_summary(geom = \"point\", fun = mean, aes(group = ARMCD), size = 3, shape = 8, position = position_dodge2(1)) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n caption = \"The whiskers extend to the minimum and maximum values.\",\n x = \"Visit\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_7, oc, 2)\nplot\n\n\n\n\n\n\n\nCodebp_8 <- ggplot(adlb_v, aes(x = ARMCD, y = AVAL)) +\n stat_summary(geom = \"boxplot\", fun.data = five_num, position = position_dodge2(width = .5), aes(fill = AVISIT, color = AVISIT)) +\n stat_summary(geom = \"point\", fun = mean, aes(group = AVISIT), size = 3, shape = 8, position = position_dodge2(1)) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n caption = \"The whiskers extend to the minimum and maximum values.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\nplot <- bp_annos(bp_8, oc, 2)\nplot\n\n\n\n\n\n\n\nCode# Make wide dataset with summary statistics\nadlb_wide <- adlb %>%\n group_by(ARMCD) %>%\n summarise(\n n = n(),\n mean = round(mean(AVAL), 1),\n median = round(median(AVAL), 1),\n median_ci = paste(round(DescTools::MedianCI(AVAL)[1:2], 1), collapse = \" - \"),\n q1_q3 = paste(round(quantile(AVAL, c(0.25, 0.75)), 1), collapse = \" - \"),\n min_max = paste0(round(min(AVAL), 1), \"-\", max(round(AVAL, 2)))\n )\n\n# Make long dataset\nadlb_long <- tidyr::gather(adlb_wide, key = type, value = stat, n:min_max)\nadlb_long <- adlb_long %>% mutate(\n type_lbl = case_when(\n type == \"n\" ~ \"n\",\n type == \"mean\" ~ \"Mean\",\n type == \"median\" ~ \"Median\",\n type == \"median_ci\" ~ \"95% CI for Median\",\n type == \"q1_q3\" ~ \"25% and 75%-ile\",\n type == \"min_max\" ~ \"Min - Max\"\n )\n)\nadlb_long$type_lbl <- factor(adlb_long$type_lbl,\n levels = c(\"Min - Max\", \"25% and 75%-ile\", \"95% CI for Median\", \"Median\", \"Mean\", \"n\")\n)\n\nbp_9 <- ggplot(adlb, aes(x = ARMCD, y = AVAL)) +\n stat_summary(geom = \"boxplot\", fun.data = five_num, fill = fc, color = oc) +\n stat_summary(geom = \"point\", fun = mean, size = 3, shape = 8) +\n labs(\n title = \"Box Plot of Laboratory Test Results\",\n subtitle = paste(\"Visit:\", adlb$AVISIT[1]),\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n ) +\n theme_bp\n\ntbl_theme <- theme(\n panel.border = element_blank(),\n panel.grid.major = element_blank(),\n panel.grid.minor = element_blank(),\n axis.ticks = element_blank(),\n axis.title = element_blank(),\n axis.text.y = element_text(face = \"plain\"),\n axis.text.x = element_blank()\n)\n\ntbl_1 <- ggplot(adlb_long, aes(x = ARMCD, y = type_lbl, label = stat), vjust = 10) +\n geom_text(size = 3) +\n scale_y_discrete(labels = levels(adlb_long$type_lbl)) +\n theme_bw() +\n tbl_theme +\n labs(caption = \"The whiskers extend to the minimum and maximum values.\") +\n theme_bp\n\nplot <- ggpubr::ggarrange(bp_annos(bp_9, oc), tbl_1,\n heights = c(4, 2),\n ncol = 1, nrow = 2, align = \"v\"\n)\nplot\n\n\n\n\n\n\n\nCodetbl_2 <- adlb_long %>%\n filter(type == \"n\") %>%\n ggplot(aes(x = ARMCD, y = type_lbl, label = stat)) +\n geom_text(size = 3) +\n scale_y_discrete(labels = \"n\") +\n theme_bw() +\n tbl_theme +\n labs(caption = \"The whiskers extend to the minimum and maximum values.\") +\n theme_bp\n\nplot <- ggpubr::ggarrange(bp_annos(bp_9, oc), tbl_2,\n heights = c(6, 1),\n ncol = 1, nrow = 2, align = \"v\"\n)\nplot\n\n\n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.general)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# If PARAMCD and AVISIT are not factors, convert to factors\n# Also fill in missing values with \"<Missing>\"\nADLB <- ADLB %>%\n tern::df_explicit_na(\n omit_columns = setdiff(names(ADLB), c(\"PARAMCD\", \"AVISIT\")),\n char_as_factor = TRUE\n )\n\n# If statment below fails, pre-process ADLB to be one record per\n# study, subject, param and visit eg. filter with ANLFL = 'Y'\nstopifnot(nrow(ADLB) == nrow(unique(ADLB[, c(\"STUDYID\", \"USUBJID\", \"PARAMCD\", \"AVISIT\")])))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL),\n cdisc_dataset(\"ADLB\", ADLB, keys = c(\"STUDYID\", \"USUBJID\", \"PARAMCD\", \"AVISIT\")), # do not modify\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n ADLB <- ADLB %>%\n tern::df_explicit_na(\n omit_columns = setdiff(names(ADLB), c(\"PARAMCD\", \"AVISIT\")),\n char_as_factor = TRUE)'\n ),\n modules = modules(\n tm_g_bivariate(\n x = data_extract_spec(\n dataname = \"ADSL\",\n select = select_spec(\n label = \"Select variable:\",\n choices = names(ADSL),\n selected = \"ARMCD\",\n fixed = FALSE\n )\n ),\n y = data_extract_spec(\n dataname = \"ADLB\",\n filter = list(\n filter_spec(\n vars = c(\"PARAMCD\"),\n choices = levels(ADLB$PARAMCD),\n selected = levels(ADLB$PARAMCD)[1],\n multiple = FALSE,\n label = \"Choose lab parameter\"\n ),\n filter_spec(\n vars = c(\"AVISIT\"),\n choices = levels(ADLB$AVISIT),\n selected = levels(ADLB$AVISIT)[1],\n multiple = FALSE,\n label = \"Choose visit\"\n )\n ),\n select = select_spec(\n label = \"Select variable:\",\n choices = names(ADLB),\n selected = \"AVAL\",\n multiple = FALSE,\n fixed = TRUE\n )\n ),\n row_facet = data_extract_spec(\n dataname = \"ADLB\",\n select = select_spec(\n label = \"Select variables:\",\n choices = names(ADLB),\n selected = NULL,\n multiple = FALSE,\n fixed = FALSE\n )\n ),\n col_facet = data_extract_spec(\n dataname = \"ADLB\",\n select = select_spec(\n label = \"Select variables:\",\n choices = names(ADLB),\n selected = NULL,\n multiple = FALSE,\n fixed = FALSE\n )\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:29:33.5435 pid:10207 token:[] teal.modules.general Initializing tm_g_bivariate\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.general_0.2.16.9006 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 magrittr_2.0.3 \n [5] teal.slice_0.4.0.9012 teal.data_0.3.0.9003 \n [7] shinyTree_0.3.1 shiny_1.7.5 \n [9] ggmosaic_0.3.3 nestcolor_0.1.2.9004 \n[11] ggplot2_3.4.3 dplyr_1.1.2 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] Rdpack_2.4 gld_2.6.6 logger_0.2.2 \n [4] testthat_3.1.10 readxl_1.4.3 rlang_1.1.1 \n [7] e1071_1.7-13 compiler_4.3.1 callr_3.7.3 \n [10] vctrs_0.6.3 formatters_0.5.2.9001 stringr_1.5.0 \n [13] pkgconfig_2.0.3 fastmap_1.1.1 backports_1.4.1 \n [16] ellipsis_0.3.2 fontawesome_0.5.1 labeling_0.4.2 \n [19] utf8_1.2.3 promises_1.2.1 rmarkdown_2.24 \n [22] ps_1.7.5 purrr_1.0.2 xfun_0.40 \n [25] cachem_1.0.8 teal.reporter_0.2.1 jsonlite_1.8.7 \n [28] later_1.3.1 broom_1.0.5 DescTools_0.99.49 \n [31] R6_2.5.1 bslib_0.5.1 stringi_1.7.12 \n [34] car_3.1-2 boot_1.3-28.1 jquerylib_0.1.4 \n [37] brio_1.1.3 cellranger_1.1.0 Rcpp_1.0.11 \n [40] rtables_0.6.3.9000 knitr_1.43 teal.logger_0.1.3.9001 \n [43] httpuv_1.6.11 Matrix_1.6-1 splines_4.3.1 \n [46] tidyselect_1.2.0 rstudioapi_0.15.0 abind_1.4-5 \n [49] yaml_2.3.7 codetools_0.2-19 processx_3.8.2 \n [52] teal.widgets_0.4.0.9007 lattice_0.21-8 tibble_3.2.1 \n [55] withr_2.5.0 evaluate_0.21 survival_3.5-7 \n [58] proxy_0.4-27 shinycssloaders_1.0.0 pillar_1.9.0 \n [61] ggpubr_0.6.0 carData_3.0-5 checkmate_2.2.0 \n [64] shinyjs_2.1.0 plotly_4.10.2 generics_0.1.3 \n [67] munsell_0.5.0 scales_1.2.1 rootSolve_1.8.2.3 \n [70] xtable_1.8-4 class_7.3-22 glue_1.6.2 \n [73] lmom_2.9 lazyeval_0.2.2 tools_4.3.1 \n [76] data.table_1.14.8 webshot_0.5.5 ggsignif_0.6.4 \n [79] forcats_1.0.0 Exact_3.2 mvtnorm_1.2-2 \n [82] cowplot_1.1.1 grid_4.3.1 tidyr_1.3.0 \n [85] rbibutils_2.2.14 colorspace_2.1-0 cli_3.6.1 \n [88] tern_0.9.0.9002 fansi_1.0.4 expm_0.999-7 \n [91] viridisLite_0.4.2 gtable_0.3.3 rstatix_0.7.2 \n [94] sass_0.4.7 digest_0.6.33 ggrepel_0.9.3 \n [97] htmlwidgets_1.6.2 farver_2.1.1 memoise_2.0.1 \n[100] htmltools_0.5.6 lifecycle_1.0.3 shinyWidgets_0.7.6 \n[103] httr_1.4.7 mime_0.12 MASS_7.3-60 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "graphs/other/mmrmg01.html",
"href": "graphs/other/mmrmg01.html",
"title": "MMRMG01",
"section": "",
- "text": "Given an MMRM fitted with s_mmrm, g_mmrm_lsmeans displays for each visit the adjusted means within group and/or difference in adjusted means between groups. g_mmrm_diagnostic displays marginal residual plots for evaluating model fit.\n\n\nData Setup and Model Fitting\nLeast Squares Means: Estimates Within Groups\nLeast Squares Means: Contrasts Between Groups\nModel Diagnostics: Marginal Fitted Values vs. Residuals\nModel Diagnostics: Normality of Marginal Residuals\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern.mmrm)\nlibrary(scda)\nlibrary(nestcolor)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\nadqs_f <- adqs %>%\n dplyr::filter(PARAMCD == \"FKSI-FWB\" & !AVISIT %in% c(\"BASELINE\")) %>%\n droplevels() %>%\n dplyr::mutate(ARM = factor(ARM, levels = c(\"B: Placebo\", \"A: Drug X\", \"C: Combination\"))) %>%\n dplyr::mutate(AVISITN = rank(AVISITN) %>% as.factor() %>% as.numeric() %>% as.factor())\n\nmmrm_results <- fit_mmrm(\n vars = list(\n response = \"AVAL\",\n covariates = c(\"STRATA2\"),\n id = \"USUBJID\",\n arm = \"ARM\",\n visit = \"AVISIT\"\n ),\n data = adqs_f\n)\n\n\n\n\nConsidering the treatment variable in the model\n\nCodeplot <- g_mmrm_lsmeans(\n mmrm_results,\n select = \"estimates\",\n xlab = \"Visit\"\n)\nplot\n\n\n\n\nConsidering the treatment variable in the model, with lines\n\nCodeplot <- g_mmrm_lsmeans(\n mmrm_results,\n select = \"estimates\",\n xlab = \"Visit\",\n show_lines = TRUE\n)\nplot\n\n\n\n\nConsidering the treatment variable in the model, with statistics table\n\nCodeplot <- g_mmrm_lsmeans(\n mmrm_results,\n select = \"estimates\",\n xlab = \"Visit\",\n table_stats = c(\"n\", \"estimate\", \"se\", \"ci\"),\n table_font_size = 4,\n table_rel_height = 0.6\n)\nplot\n\n\n\n\n\n\n\nUsers can choose to display both estimates and contrasts together by running g_mmrm_lsmeans(mmrm_results).\n\nCodeplot <- g_mmrm_lsmeans(\n mmrm_results,\n select = \"contrasts\",\n titles = c(contrasts = \"Contrasts of FKSI-FWB means\"),\n xlab = \"Visit\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_mmrm_diagnostic(mmrm_results)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_mmrm_diagnostic(mmrm_results, type = \"q-q-residual\")\nplot\n\n\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\") %>%\n dplyr::filter(ABLFL != \"Y\" & ABLFL2 != \"Y\") %>%\n dplyr::filter(AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\")) %>%\n dplyr::mutate(\n AVISIT = as.factor(AVISIT),\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor() # making consecutive numeric factor\n )\n\narm_ref_comp <- list(\n ARMCD = list(\n ref = \"ARM A\",\n comp = c(\"ARM B\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADQS\", adqs),\n code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADQS <- synthetic_cdisc_dataset(\"latest\", \"adqs\") %>%\n dplyr::filter(ABLFL != \"Y\" & ABLFL2 != \"Y\") %>%\n dplyr::filter(AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\")) %>%\n dplyr::mutate(\n AVISIT = as.factor(AVISIT),\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor() # making consecutive numeric factor\n )\n ',\n check = TRUE\n ),\n modules = modules(\n tm_a_mmrm(\n label = \"MMRM\",\n dataname = \"ADQS\",\n aval_var = choices_selected(c(\"AVAL\", \"CHG\"), \"AVAL\"),\n id_var = choices_selected(c(\"USUBJID\", \"SUBJID\"), \"USUBJID\"),\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARMCD\"),\n visit_var = choices_selected(c(\"AVISIT\", \"AVISITN\"), \"AVISIT\"),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = \"FKSI-FWB\"\n ),\n cov_var = choices_selected(c(\"BASE\", \"AGE\", \"SEX\", \"BASE:AVISIT\"), NULL),\n conf_level = choices_selected(c(0.95, 0.9, 0.8), 0.95)\n )\n )\n)\n\n[INFO] 2023-09-08 20:03:07.5642 pid:9965 token:[] teal.modules.clinical Initializing tm_a_mmrm\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 scda_0.1.6.9012 \n [9] tern.mmrm_0.2.2.9006 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] Rdpack_2.4 mmrm_0.2.2 tern.gee_0.1.0.9008 \n [4] logger_0.2.2 testthat_3.1.10 sandwich_3.0-2 \n [7] rlang_1.1.1 multcomp_1.4-25 compiler_4.3.1 \n[10] callr_3.7.3 vctrs_0.6.3 stringr_1.5.0 \n[13] pkgconfig_2.0.3 fastmap_1.1.1 backports_1.4.1 \n[16] ellipsis_0.3.2 fontawesome_0.5.1 labeling_0.4.2 \n[19] utf8_1.2.3 promises_1.2.1 rmarkdown_2.24 \n[22] ps_1.7.5 purrr_1.0.2 xfun_0.40 \n[25] cachem_1.0.8 teal.reporter_0.2.1 jsonlite_1.8.7 \n[28] later_1.3.1 broom_1.0.5 parallel_4.3.1 \n[31] R6_2.5.1 bslib_0.5.1 stringi_1.7.12 \n[34] parallelly_1.36.0 brio_1.1.3 jquerylib_0.1.4 \n[37] numDeriv_2016.8-1.1 estimability_1.4.1 Rcpp_1.0.11 \n[40] assertthat_0.2.1 knitr_1.43 zoo_1.8-12 \n[43] teal.logger_0.1.3.9000 httpuv_1.6.11 Matrix_1.6-1 \n[46] splines_4.3.1 tidyselect_1.2.0 rstudioapi_0.15.0 \n[49] yaml_2.3.7 TMB_1.9.6 codetools_0.2-19 \n[52] processx_3.8.2 teal.widgets_0.4.0.9007 lattice_0.21-8 \n[55] tibble_3.2.1 withr_2.5.0 coda_0.19-4 \n[58] evaluate_0.21 survival_3.5-7 shinycssloaders_1.0.0 \n[61] pillar_1.9.0 checkmate_2.2.0 shinyjs_2.1.0 \n[64] generics_0.1.3 ggplot2_3.4.3 munsell_0.5.0 \n[67] scales_1.2.1 xtable_1.8-4 glue_1.6.2 \n[70] emmeans_1.8.7 tools_4.3.1 webshot_0.5.5 \n[73] mvtnorm_1.2-2 cowplot_1.1.1 grid_4.3.1 \n[76] tidyr_1.3.0 rbibutils_2.2.14 colorspace_2.1-0 \n[79] nlme_3.1-163 cli_3.6.1 fansi_1.0.4 \n[82] geepack_1.3.9 gtable_0.3.3 sass_0.4.7 \n[85] digest_0.6.33 TH.data_1.1-2 htmlwidgets_1.6.2 \n[88] farver_2.1.1 memoise_2.0.1 htmltools_0.5.6 \n[91] lifecycle_1.0.3 shinyWidgets_0.7.6 mime_0.12 \n[94] MASS_7.3-60 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Given an MMRM fitted with s_mmrm, g_mmrm_lsmeans displays for each visit the adjusted means within group and/or difference in adjusted means between groups. g_mmrm_diagnostic displays marginal residual plots for evaluating model fit.\n\n\nData Setup and Model Fitting\nLeast Squares Means: Estimates Within Groups\nLeast Squares Means: Contrasts Between Groups\nModel Diagnostics: Marginal Fitted Values vs. Residuals\nModel Diagnostics: Normality of Marginal Residuals\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern.mmrm)\nlibrary(scda)\nlibrary(nestcolor)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\nadqs_f <- adqs %>%\n dplyr::filter(PARAMCD == \"FKSI-FWB\" & !AVISIT %in% c(\"BASELINE\")) %>%\n droplevels() %>%\n dplyr::mutate(ARM = factor(ARM, levels = c(\"B: Placebo\", \"A: Drug X\", \"C: Combination\"))) %>%\n dplyr::mutate(AVISITN = rank(AVISITN) %>% as.factor() %>% as.numeric() %>% as.factor())\n\nmmrm_results <- fit_mmrm(\n vars = list(\n response = \"AVAL\",\n covariates = c(\"STRATA2\"),\n id = \"USUBJID\",\n arm = \"ARM\",\n visit = \"AVISIT\"\n ),\n data = adqs_f\n)\n\n\n\n\nConsidering the treatment variable in the model\n\nCodeplot <- g_mmrm_lsmeans(\n mmrm_results,\n select = \"estimates\",\n xlab = \"Visit\"\n)\nplot\n\n\n\n\nConsidering the treatment variable in the model, with lines\n\nCodeplot <- g_mmrm_lsmeans(\n mmrm_results,\n select = \"estimates\",\n xlab = \"Visit\",\n show_lines = TRUE\n)\nplot\n\n\n\n\nConsidering the treatment variable in the model, with statistics table\n\nCodeplot <- g_mmrm_lsmeans(\n mmrm_results,\n select = \"estimates\",\n xlab = \"Visit\",\n table_stats = c(\"n\", \"estimate\", \"se\", \"ci\"),\n table_font_size = 4,\n table_rel_height = 0.6\n)\nplot\n\n\n\n\n\n\n\nUsers can choose to display both estimates and contrasts together by running g_mmrm_lsmeans(mmrm_results).\n\nCodeplot <- g_mmrm_lsmeans(\n mmrm_results,\n select = \"contrasts\",\n titles = c(contrasts = \"Contrasts of FKSI-FWB means\"),\n xlab = \"Visit\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_mmrm_diagnostic(mmrm_results)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_mmrm_diagnostic(mmrm_results, type = \"q-q-residual\")\nplot\n\n\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\") %>%\n dplyr::filter(ABLFL != \"Y\" & ABLFL2 != \"Y\") %>%\n dplyr::filter(AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\")) %>%\n dplyr::mutate(\n AVISIT = as.factor(AVISIT),\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor() # making consecutive numeric factor\n )\n\narm_ref_comp <- list(\n ARMCD = list(\n ref = \"ARM A\",\n comp = c(\"ARM B\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADQS\", adqs),\n code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADQS <- synthetic_cdisc_dataset(\"latest\", \"adqs\") %>%\n dplyr::filter(ABLFL != \"Y\" & ABLFL2 != \"Y\") %>%\n dplyr::filter(AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\")) %>%\n dplyr::mutate(\n AVISIT = as.factor(AVISIT),\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor() # making consecutive numeric factor\n )\n ',\n check = TRUE\n ),\n modules = modules(\n tm_a_mmrm(\n label = \"MMRM\",\n dataname = \"ADQS\",\n aval_var = choices_selected(c(\"AVAL\", \"CHG\"), \"AVAL\"),\n id_var = choices_selected(c(\"USUBJID\", \"SUBJID\"), \"USUBJID\"),\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARMCD\"),\n visit_var = choices_selected(c(\"AVISIT\", \"AVISITN\"), \"AVISIT\"),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = \"FKSI-FWB\"\n ),\n cov_var = choices_selected(c(\"BASE\", \"AGE\", \"SEX\", \"BASE:AVISIT\"), NULL),\n conf_level = choices_selected(c(0.95, 0.9, 0.8), 0.95)\n )\n )\n)\n\n[INFO] 2023-09-09 18:28:15.1554 pid:9980 token:[] teal.modules.clinical Initializing tm_a_mmrm\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 scda_0.1.6.9012 \n [9] tern.mmrm_0.2.2.9006 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] Rdpack_2.4 mmrm_0.2.2 tern.gee_0.1.0.9008 \n [4] logger_0.2.2 testthat_3.1.10 sandwich_3.0-2 \n [7] rlang_1.1.1 multcomp_1.4-25 compiler_4.3.1 \n[10] callr_3.7.3 vctrs_0.6.3 stringr_1.5.0 \n[13] pkgconfig_2.0.3 fastmap_1.1.1 backports_1.4.1 \n[16] ellipsis_0.3.2 fontawesome_0.5.1 labeling_0.4.2 \n[19] utf8_1.2.3 promises_1.2.1 rmarkdown_2.24 \n[22] ps_1.7.5 purrr_1.0.2 xfun_0.40 \n[25] cachem_1.0.8 teal.reporter_0.2.1 jsonlite_1.8.7 \n[28] later_1.3.1 broom_1.0.5 parallel_4.3.1 \n[31] R6_2.5.1 bslib_0.5.1 stringi_1.7.12 \n[34] parallelly_1.36.0 brio_1.1.3 jquerylib_0.1.4 \n[37] numDeriv_2016.8-1.1 estimability_1.4.1 Rcpp_1.0.11 \n[40] assertthat_0.2.1 knitr_1.43 zoo_1.8-12 \n[43] teal.logger_0.1.3.9001 httpuv_1.6.11 Matrix_1.6-1 \n[46] splines_4.3.1 tidyselect_1.2.0 rstudioapi_0.15.0 \n[49] yaml_2.3.7 TMB_1.9.6 codetools_0.2-19 \n[52] processx_3.8.2 teal.widgets_0.4.0.9007 lattice_0.21-8 \n[55] tibble_3.2.1 withr_2.5.0 coda_0.19-4 \n[58] evaluate_0.21 survival_3.5-7 shinycssloaders_1.0.0 \n[61] pillar_1.9.0 checkmate_2.2.0 shinyjs_2.1.0 \n[64] generics_0.1.3 ggplot2_3.4.3 munsell_0.5.0 \n[67] scales_1.2.1 xtable_1.8-4 glue_1.6.2 \n[70] emmeans_1.8.7 tools_4.3.1 webshot_0.5.5 \n[73] mvtnorm_1.2-2 cowplot_1.1.1 grid_4.3.1 \n[76] tidyr_1.3.0 rbibutils_2.2.14 colorspace_2.1-0 \n[79] nlme_3.1-163 cli_3.6.1 fansi_1.0.4 \n[82] geepack_1.3.9 gtable_0.3.3 sass_0.4.7 \n[85] digest_0.6.33 TH.data_1.1-2 htmlwidgets_1.6.2 \n[88] farver_2.1.1 memoise_2.0.1 htmltools_0.5.6 \n[91] lifecycle_1.0.3 shinyWidgets_0.7.6 mime_0.12 \n[94] MASS_7.3-60 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "graphs/other/fstg02.html",
"href": "graphs/other/fstg02.html",
"title": "FSTG02",
"section": "",
- "text": "Data Setup\nStandard Plot\nPlot Specifying Class Variables and Options for the Treatment Variable\nPlot Selecting Columns and Changing the Alpha Level)\nPlot with Fixed Symbol Size\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(forcats)\nlibrary(nestcolor)\nlibrary(scda)\n\npreprocess_adtte <- function(adtte) {\n # Save variable labels before data processing steps.\n adtte_labels <- var_labels(adtte)\n\n adtte <- adtte %>%\n df_explicit_na() %>%\n dplyr::filter(\n PARAMCD == \"OS\",\n ARM %in% c(\"B: Placebo\", \"A: Drug X\"),\n SEX %in% c(\"M\", \"F\")\n ) %>%\n dplyr::mutate(\n # Reorder levels of ARM to display reference arm before treatment arm.\n ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")),\n SEX = droplevels(SEX),\n is_event = CNSR == 0,\n # Convert time to MONTH\n AVAL = day2month(AVAL),\n AVALU = \"Months\"\n ) %>%\n var_relabel(\n ARM = adtte_labels[\"ARM\"],\n SEX = adtte_labels[\"SEX\"],\n is_event = \"Event Flag\",\n AVAL = adtte_labels[\"AVAL\"],\n AVALU = adtte_labels[\"AVALU\"]\n )\n\n adtte\n}\n\nanl <- synthetic_cdisc_dataset(\"latest\", \"adtte\") %>%\n preprocess_adtte()\n\n\n\n\n\nCodeanl1 <- anl\n\ndf <- extract_survival_subgroups(\n variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")),\n data = anl1\n)\n\nresult <- basic_table() %>%\n tabulate_survival_subgroups(\n df = df,\n vars = c(\"n_tot\", \"n\", \"median\", \"hr\", \"ci\"),\n time_unit = anl1$AVALU[1]\n )\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)\nSex \n F 161 82 NA 79 NA 0.79 (0.49, 1.28)\n M 107 52 NA 55 9.6 1.39 (0.78, 2.47)\nCategorical Level Biomarker 2 \n LOW 95 45 NA 50 9.3 1.14 (0.64, 2.02)\n MEDIUM 93 56 NA 37 NA 0.97 (0.52, 1.82)\n HIGH 80 33 NA 47 NA 0.97 (0.45, 2.12)\n\nCode# Add plot.\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl2 <- anl %>%\n mutate(\n # Recode levels of arm.\n ARM = forcats::fct_recode(\n ARM,\n \"Placebo\" = \"B: Placebo\",\n \"Drug X\" = \"A: Drug X\"\n ),\n # Reorder levels of `SEX`.\n SEX = forcats::fct_relevel(SEX, \"M\", \"F\"),\n # Reorder levels of `STRATA1`` by frequency.\n STRATA1 = forcats::fct_infreq(STRATA1)\n )\n\ndf <- extract_survival_subgroups(\n variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"STRATA1\")),\n data = anl2\n)\n\nresult <- basic_table() %>%\n tabulate_survival_subgroups(\n df = df,\n vars = c(\"n_tot\", \"n\", \"median\", \"hr\", \"ci\"),\n time_unit = anl2$AVALU[1]\n )\nresult\n\nBaseline Risk Factors Placebo Drug X \n Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)\nSex \n M 107 52 NA 55 9.6 1.39 (0.78, 2.47)\n F 161 82 NA 79 NA 0.79 (0.49, 1.28)\nStratification Factor 1 \n C 94 45 NA 49 NA 0.75 (0.41, 1.38)\n B 92 45 NA 47 NA 1.34 (0.71, 2.54)\n A 82 44 NA 38 NA 1.02 (0.53, 1.97)\n\nCodep <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl3 <- anl\n\ndf <- extract_survival_subgroups(\n variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")),\n control = control_coxph(conf_level = 0.9),\n data = anl3\n)\n\nresult <- basic_table() %>%\n tabulate_survival_subgroups(\n df = df,\n vars = c(\"n_tot\", \"hr\", \"ci\")\n )\nresult\n\nBaseline Risk Factors \n Total n Hazard Ratio 90% Wald CI \n—————————————————————————————————————————————————————————————————————\nAll Patients 268 1.00 (0.74, 1.36)\nSex \n F 161 0.79 (0.53, 1.19)\n M 107 1.39 (0.86, 2.25)\nCategorical Level Biomarker 2 \n LOW 95 1.14 (0.71, 1.84)\n MEDIUM 93 0.97 (0.58, 1.64)\n HIGH 80 0.97 (0.51, 1.87)\n\nCode# Add plot.\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl4 <- anl\n\ndf <- extract_survival_subgroups(\n variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")),\n data = anl4\n)\n\nresult <- basic_table() %>%\n tabulate_survival_subgroups(\n df = df,\n vars = c(\"n_tot\", \"n\", \"median\", \"hr\", \"ci\"),\n time_unit = anl4$AVALU[1]\n )\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)\nSex \n F 161 82 NA 79 NA 0.79 (0.49, 1.28)\n M 107 52 NA 55 9.6 1.39 (0.78, 2.47)\nCategorical Level Biomarker 2 \n LOW 95 45 NA 50 9.3 1.14 (0.64, 2.02)\n MEDIUM 93 56 NA 37 NA 0.97 (0.52, 1.82)\n HIGH 80 33 NA 47 NA 0.97 (0.45, 2.12)\n\nCode# Add plot.\np <- g_forest(\n tbl = result,\n col_symbol_size = NULL\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADSL <- ADSL %>%\n dplyr::filter(ARM %in% c(\"B: Placebo\", \"A: Drug X\")) %>%\n dplyr::mutate(ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\"))) %>%\n dplyr::mutate(ARMCD = droplevels(forcats::fct_relevel(ARMCD, \"ARM B\")))\nADSL$RACE <- droplevels(ADSL$RACE)\n\nADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\nadtte_labels <- var_labels(ADTTE)\n\nADTTE <- ADTTE %>%\n dplyr::filter(\n PARAMCD == \"OS\",\n ARM %in% c(\"B: Placebo\", \"A: Drug X\"),\n SEX %in% c(\"M\", \"F\")\n ) %>%\n dplyr::mutate(\n # Reorder levels of ARM to display reference arm before treatment arm.\n ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")),\n SEX = droplevels(SEX),\n is_event = CNSR == 0,\n # Convert time to MONTH\n AVAL = day2month(AVAL),\n AVALU = \"Months\"\n ) %>%\n var_relabel(\n ARM = adtte_labels[\"ARM\"],\n SEX = adtte_labels[\"SEX\"],\n is_event = \"Event Flag\",\n AVAL = adtte_labels[\"AVAL\"],\n AVALU = adtte_labels[\"AVALU\"]\n )\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- ADSL %>%\n dplyr::filter(ARM %in% c(\"B: Placebo\", \"A: Drug X\")) %>%\n dplyr::mutate(ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\"))) %>%\n dplyr::mutate(ARMCD = droplevels(forcats::fct_relevel(ARMCD, \"ARM B\")))\n ADSL$RACE <- droplevels(ADSL$RACE)\n '\n ),\n cdisc_dataset(\"ADTTE\", ADTTE, code = '\n ADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n adtte_labels <- var_labels(ADTTE)\n ADTTE <- ADTTE %>%\n dplyr::filter(\n PARAMCD == \"OS\",\n ARM %in% c(\"B: Placebo\", \"A: Drug X\"),\n SEX %in% c(\"M\", \"F\")\n ) %>%\n dplyr::mutate(\n # Reorder levels of ARM to display reference arm before treatment arm.\n ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")),\n SEX = droplevels(SEX),\n is_event = CNSR == 0,\n # Convert time to MONTH\n AVAL = day2month(AVAL),\n AVALU = \"Months\"\n ) %>%\n var_relabel(\n ARM = adtte_labels[\"ARM\"],\n SEX = adtte_labels[\"SEX\"],\n is_event = \"Event Flag\",\n AVAL = adtte_labels[\"AVAL\"],\n AVALU = adtte_labels[\"AVALU\"]\n )\n '),\n check = TRUE\n ),\n modules = modules(\n tm_g_forest_tte(\n label = \"Forest Survival\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n subgroup_var = choices_selected(names(ADSL), c(\"SEX\", \"BMRKR2\")),\n paramcd = choices_selected(value_choices(ADTTE, \"PARAMCD\", \"PARAM\"), \"OS\"),\n strata_var = choices_selected(c(\"STRATA1\", \"STRATA2\"), \"STRATA2\"),\n plot_height = c(600, 200, 2000),\n plot_width = c(1500, 200, 5000)\n )\n )\n)\n\n[INFO] 2023-09-08 20:01:54.3489 pid:9743 token:[] teal.modules.clinical Initializing tm_g_forest_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 nestcolor_0.1.2.9004 \n [9] forcats_1.0.0 dplyr_1.1.2 \n[11] tern_0.9.0.9002 rtables_0.6.3.9000 \n[13] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 R6_2.5.1 Rdpack_2.4 \n[67] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[70] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[73] teal.reporter_0.2.1 httpuv_1.6.11 bslib_0.5.1 \n[76] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[79] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[82] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Plot\nPlot Specifying Class Variables and Options for the Treatment Variable\nPlot Selecting Columns and Changing the Alpha Level)\nPlot with Fixed Symbol Size\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(forcats)\nlibrary(nestcolor)\nlibrary(scda)\n\npreprocess_adtte <- function(adtte) {\n # Save variable labels before data processing steps.\n adtte_labels <- var_labels(adtte)\n\n adtte <- adtte %>%\n df_explicit_na() %>%\n dplyr::filter(\n PARAMCD == \"OS\",\n ARM %in% c(\"B: Placebo\", \"A: Drug X\"),\n SEX %in% c(\"M\", \"F\")\n ) %>%\n dplyr::mutate(\n # Reorder levels of ARM to display reference arm before treatment arm.\n ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")),\n SEX = droplevels(SEX),\n is_event = CNSR == 0,\n # Convert time to MONTH\n AVAL = day2month(AVAL),\n AVALU = \"Months\"\n ) %>%\n var_relabel(\n ARM = adtte_labels[\"ARM\"],\n SEX = adtte_labels[\"SEX\"],\n is_event = \"Event Flag\",\n AVAL = adtte_labels[\"AVAL\"],\n AVALU = adtte_labels[\"AVALU\"]\n )\n\n adtte\n}\n\nanl <- synthetic_cdisc_dataset(\"latest\", \"adtte\") %>%\n preprocess_adtte()\n\n\n\n\n\nCodeanl1 <- anl\n\ndf <- extract_survival_subgroups(\n variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")),\n data = anl1\n)\n\nresult <- basic_table() %>%\n tabulate_survival_subgroups(\n df = df,\n vars = c(\"n_tot\", \"n\", \"median\", \"hr\", \"ci\"),\n time_unit = anl1$AVALU[1]\n )\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)\nSex \n F 161 82 NA 79 NA 0.79 (0.49, 1.28)\n M 107 52 NA 55 9.6 1.39 (0.78, 2.47)\nCategorical Level Biomarker 2 \n LOW 95 45 NA 50 9.3 1.14 (0.64, 2.02)\n MEDIUM 93 56 NA 37 NA 0.97 (0.52, 1.82)\n HIGH 80 33 NA 47 NA 0.97 (0.45, 2.12)\n\nCode# Add plot.\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl2 <- anl %>%\n mutate(\n # Recode levels of arm.\n ARM = forcats::fct_recode(\n ARM,\n \"Placebo\" = \"B: Placebo\",\n \"Drug X\" = \"A: Drug X\"\n ),\n # Reorder levels of `SEX`.\n SEX = forcats::fct_relevel(SEX, \"M\", \"F\"),\n # Reorder levels of `STRATA1`` by frequency.\n STRATA1 = forcats::fct_infreq(STRATA1)\n )\n\ndf <- extract_survival_subgroups(\n variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"STRATA1\")),\n data = anl2\n)\n\nresult <- basic_table() %>%\n tabulate_survival_subgroups(\n df = df,\n vars = c(\"n_tot\", \"n\", \"median\", \"hr\", \"ci\"),\n time_unit = anl2$AVALU[1]\n )\nresult\n\nBaseline Risk Factors Placebo Drug X \n Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)\nSex \n M 107 52 NA 55 9.6 1.39 (0.78, 2.47)\n F 161 82 NA 79 NA 0.79 (0.49, 1.28)\nStratification Factor 1 \n C 94 45 NA 49 NA 0.75 (0.41, 1.38)\n B 92 45 NA 47 NA 1.34 (0.71, 2.54)\n A 82 44 NA 38 NA 1.02 (0.53, 1.97)\n\nCodep <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl3 <- anl\n\ndf <- extract_survival_subgroups(\n variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")),\n control = control_coxph(conf_level = 0.9),\n data = anl3\n)\n\nresult <- basic_table() %>%\n tabulate_survival_subgroups(\n df = df,\n vars = c(\"n_tot\", \"hr\", \"ci\")\n )\nresult\n\nBaseline Risk Factors \n Total n Hazard Ratio 90% Wald CI \n—————————————————————————————————————————————————————————————————————\nAll Patients 268 1.00 (0.74, 1.36)\nSex \n F 161 0.79 (0.53, 1.19)\n M 107 1.39 (0.86, 2.25)\nCategorical Level Biomarker 2 \n LOW 95 1.14 (0.71, 1.84)\n MEDIUM 93 0.97 (0.58, 1.64)\n HIGH 80 0.97 (0.51, 1.87)\n\nCode# Add plot.\np <- g_forest(\n tbl = result\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodeanl4 <- anl\n\ndf <- extract_survival_subgroups(\n variables = list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARM\", subgroups = c(\"SEX\", \"BMRKR2\")),\n data = anl4\n)\n\nresult <- basic_table() %>%\n tabulate_survival_subgroups(\n df = df,\n vars = c(\"n_tot\", \"n\", \"median\", \"hr\", \"ci\"),\n time_unit = anl4$AVALU[1]\n )\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 NA 134 NA 1.00 (0.69, 1.44)\nSex \n F 161 82 NA 79 NA 0.79 (0.49, 1.28)\n M 107 52 NA 55 9.6 1.39 (0.78, 2.47)\nCategorical Level Biomarker 2 \n LOW 95 45 NA 50 9.3 1.14 (0.64, 2.02)\n MEDIUM 93 56 NA 37 NA 0.97 (0.52, 1.82)\n HIGH 80 33 NA 47 NA 0.97 (0.45, 2.12)\n\nCode# Add plot.\np <- g_forest(\n tbl = result,\n col_symbol_size = NULL\n)\n\ngrid::grid.draw(p)\n\n\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADSL <- ADSL %>%\n dplyr::filter(ARM %in% c(\"B: Placebo\", \"A: Drug X\")) %>%\n dplyr::mutate(ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\"))) %>%\n dplyr::mutate(ARMCD = droplevels(forcats::fct_relevel(ARMCD, \"ARM B\")))\nADSL$RACE <- droplevels(ADSL$RACE)\n\nADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\nadtte_labels <- var_labels(ADTTE)\n\nADTTE <- ADTTE %>%\n dplyr::filter(\n PARAMCD == \"OS\",\n ARM %in% c(\"B: Placebo\", \"A: Drug X\"),\n SEX %in% c(\"M\", \"F\")\n ) %>%\n dplyr::mutate(\n # Reorder levels of ARM to display reference arm before treatment arm.\n ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")),\n SEX = droplevels(SEX),\n is_event = CNSR == 0,\n # Convert time to MONTH\n AVAL = day2month(AVAL),\n AVALU = \"Months\"\n ) %>%\n var_relabel(\n ARM = adtte_labels[\"ARM\"],\n SEX = adtte_labels[\"SEX\"],\n is_event = \"Event Flag\",\n AVAL = adtte_labels[\"AVAL\"],\n AVALU = adtte_labels[\"AVALU\"]\n )\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- ADSL %>%\n dplyr::filter(ARM %in% c(\"B: Placebo\", \"A: Drug X\")) %>%\n dplyr::mutate(ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\"))) %>%\n dplyr::mutate(ARMCD = droplevels(forcats::fct_relevel(ARMCD, \"ARM B\")))\n ADSL$RACE <- droplevels(ADSL$RACE)\n '\n ),\n cdisc_dataset(\"ADTTE\", ADTTE, code = '\n ADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n adtte_labels <- var_labels(ADTTE)\n ADTTE <- ADTTE %>%\n dplyr::filter(\n PARAMCD == \"OS\",\n ARM %in% c(\"B: Placebo\", \"A: Drug X\"),\n SEX %in% c(\"M\", \"F\")\n ) %>%\n dplyr::mutate(\n # Reorder levels of ARM to display reference arm before treatment arm.\n ARM = droplevels(forcats::fct_relevel(ARM, \"B: Placebo\")),\n SEX = droplevels(SEX),\n is_event = CNSR == 0,\n # Convert time to MONTH\n AVAL = day2month(AVAL),\n AVALU = \"Months\"\n ) %>%\n var_relabel(\n ARM = adtte_labels[\"ARM\"],\n SEX = adtte_labels[\"SEX\"],\n is_event = \"Event Flag\",\n AVAL = adtte_labels[\"AVAL\"],\n AVALU = adtte_labels[\"AVALU\"]\n )\n '),\n check = TRUE\n ),\n modules = modules(\n tm_g_forest_tte(\n label = \"Forest Survival\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n subgroup_var = choices_selected(names(ADSL), c(\"SEX\", \"BMRKR2\")),\n paramcd = choices_selected(value_choices(ADTTE, \"PARAMCD\", \"PARAM\"), \"OS\"),\n strata_var = choices_selected(c(\"STRATA1\", \"STRATA2\"), \"STRATA2\"),\n plot_height = c(600, 200, 2000),\n plot_width = c(1500, 200, 5000)\n )\n )\n)\n\n[INFO] 2023-09-09 18:26:45.5124 pid:9758 token:[] teal.modules.clinical Initializing tm_g_forest_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 nestcolor_0.1.2.9004 \n [9] forcats_1.0.0 dplyr_1.1.2 \n[11] tern_0.9.0.9002 rtables_0.6.3.9000 \n[13] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 R6_2.5.1 Rdpack_2.4 \n[67] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[70] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[73] teal.reporter_0.2.1 httpuv_1.6.11 bslib_0.5.1 \n[76] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[79] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[82] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "graphs/pharmacokinetic/pkcg02.html",
@@ -186,14 +186,14 @@
"href": "tables/other/rmpt04.html",
"title": "RMPT04",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\n# Simulate ADEX records with PARAMCD == \"TDURD\" as they are not in sample scda dataset.\nset.seed(1, kind = \"Mersenne-Twister\")\nadex2 <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE)\n ) %>%\n bind_rows(adex)\n\n\n# Now pre-processing steps are carried out.\nanl <- adex2 %>%\n filter(\n PARAMCD == \"TDURD\",\n PARCAT2 == \"Drug A\",\n SAFFL == \"Y\"\n )\n\nadsl_f <- adsl %>% filter(adsl$SAFFL == \"Y\")\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Extent of Exposure by Ethnic Origin: Safety-Evaluable Patients\",\n main_footer = \"* Patient Time is the sum of exposure across all patients in days.\",\n show_colcounts = TRUE\n) %>%\n analyze_patients_exposure_in_cols(\n var = \"ETHNIC\",\n col_split = TRUE,\n add_total_level = TRUE,\n custom_label = \"Total\"\n ) %>%\n append_topleft(c(\"\", \"Ethnicity\"))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f)\nresult\n\nExtent of Exposure by Ethnic Origin: Safety-Evaluable Patients\n\n——————————————————————————————————————————————————\n Patients Person time\nEthnicity (N=400) (N=400) \n——————————————————————————————————————————————————\nHISPANIC OR LATINO 28 (7.0%) 2423 \nNOT HISPANIC OR LATINO 165 (41.2%) 15570 \nNOT REPORTED 18 (4.5%) 2085 \nUNKNOWN 6 (1.5%) 563 \nTotal 217 (54.2%) 20641 \n——————————————————————————————————————————————————\n\n* Patient Time is the sum of exposure across all patients in days.\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\nset.seed(1, kind = \"Mersenne-Twister\")\nadex <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\"\n ) %>%\n bind_rows(adex)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEX\", adex, code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n set.seed(1, kind = \"Mersenne-Twister\")\n ADEX <- ADEX %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\") %>%\n bind_rows(ADEX)'),\n check = TRUE\n ),\n modules = modules(\n tm_t_exposure(\n label = \"Duration of Exposure Table\",\n dataname = \"ADEX\",\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = \"TDURD\"\n ),\n col_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"ARM\")),\n selected = NULL\n ),\n row_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"ETHNIC\", \"SEX\")),\n selected = \"ETHNIC\"\n ),\n parcat = choices_selected(\n choices = value_choices(adex, \"PARCAT2\"),\n selected = \"Drug A\"\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-08 19:59:14.2982 pid:8649 token:[] teal.modules.clinical Initializing tm_t_exposure\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\n# Simulate ADEX records with PARAMCD == \"TDURD\" as they are not in sample scda dataset.\nset.seed(1, kind = \"Mersenne-Twister\")\nadex2 <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE)\n ) %>%\n bind_rows(adex)\n\n\n# Now pre-processing steps are carried out.\nanl <- adex2 %>%\n filter(\n PARAMCD == \"TDURD\",\n PARCAT2 == \"Drug A\",\n SAFFL == \"Y\"\n )\n\nadsl_f <- adsl %>% filter(adsl$SAFFL == \"Y\")\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Extent of Exposure by Ethnic Origin: Safety-Evaluable Patients\",\n main_footer = \"* Patient Time is the sum of exposure across all patients in days.\",\n show_colcounts = TRUE\n) %>%\n analyze_patients_exposure_in_cols(\n var = \"ETHNIC\",\n col_split = TRUE,\n add_total_level = TRUE,\n custom_label = \"Total\"\n ) %>%\n append_topleft(c(\"\", \"Ethnicity\"))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f)\nresult\n\nExtent of Exposure by Ethnic Origin: Safety-Evaluable Patients\n\n——————————————————————————————————————————————————\n Patients Person time\nEthnicity (N=400) (N=400) \n——————————————————————————————————————————————————\nHISPANIC OR LATINO 28 (7.0%) 2423 \nNOT HISPANIC OR LATINO 165 (41.2%) 15570 \nNOT REPORTED 18 (4.5%) 2085 \nUNKNOWN 6 (1.5%) 563 \nTotal 217 (54.2%) 20641 \n——————————————————————————————————————————————————\n\n* Patient Time is the sum of exposure across all patients in days.\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\nset.seed(1, kind = \"Mersenne-Twister\")\nadex <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\"\n ) %>%\n bind_rows(adex)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEX\", adex, code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n set.seed(1, kind = \"Mersenne-Twister\")\n ADEX <- ADEX %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\") %>%\n bind_rows(ADEX)'),\n check = TRUE\n ),\n modules = modules(\n tm_t_exposure(\n label = \"Duration of Exposure Table\",\n dataname = \"ADEX\",\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = \"TDURD\"\n ),\n col_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"ARM\")),\n selected = NULL\n ),\n row_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"ETHNIC\", \"SEX\")),\n selected = \"ETHNIC\"\n ),\n parcat = choices_selected(\n choices = value_choices(adex, \"PARCAT2\"),\n selected = \"Drug A\"\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-09 18:23:06.8760 pid:8656 token:[] teal.modules.clinical Initializing tm_t_exposure\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/other/cmht01.html",
"href": "tables/other/cmht01.html",
"title": "CMHT01",
"section": "",
- "text": "Data Setup\nTable of Single Parameter\nTable of Multiple Parameters\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\n\n\n\n\nCodeanl_01 <- adqs %>%\n filter(PARAMCD == \"FKSI-FWB\" & AVISIT == \"WEEK 1 DAY 8\") %>%\n mutate(is_rsp = PCHG > 15) %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\") %>%\n mutate(strata = interaction(STRATA1, STRATA2, drop = TRUE))\n\nlyt_01 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(vars = \"is_rsp\", table_names = \"est_prop\") %>%\n estimate_proportion_diff(\n var_labels = \"Unstratified Analysis\",\n vars = \"is_rsp\",\n show_labels = \"visible\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(vars = \"is_rsp\", table_names = \"test_prop\") %>%\n estimate_odds_ratio(vars = \"is_rsp\", table_names = \"est_or\") %>%\n estimate_proportion_diff(\n var_labels = \"Stratified Analysis\",\n vars = \"is_rsp\",\n show_labels = \"visible\",\n method = \"cmh\",\n variables = list(strata = \"strata\"),\n table_names = \"est_prop_diff_strat\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n method = \"cmh\",\n variables = list(strata = \"strata\"),\n table_names = \"test_prop_strat\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n variables = list(strata = \"strata\", arm = \"ARM\"),\n table_names = \"est_or_strat\"\n )\n\nresult <- build_table(\n lyt = lyt_01,\n df = anl_01,\n alt_counts_df = adsl\n)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nResponders 49 (36.6%) 51 (38.1%) 47 (35.6%) \n95% CI (Wald, with correction) (28.0, 45.1) (29.5, 46.7) (27.1, 44.2) \nUnstratified Analysis \n Difference in Response rate (%) 1.5 -1.0 \n 95% CI (Wald, with correction) (-10.8, 13.8) (-13.3, 11.3) \n p-value (Chi-Squared Test) 0.8006 0.8704 \nOdds Ratio (95% CI) 1.07 (0.65 - 1.75) 0.96 (0.58 - 1.58)\nStratified Analysis \n Difference in Response rate (%) 2.8 -1.5 \n 95% CI (CMH, without correction) (-8.2, 13.8) (-13.0, 9.9) \n p-value (Cochran-Mantel-Haenszel Test) 0.6397 0.7952 \nOdds Ratio (95% CI) 1.12 (0.68 - 1.83) 0.99 (0.60 - 1.64)\n\n\n\n\n\nCodeanl_02 <- adqs %>%\n filter(AVISIT == \"WEEK 1 DAY 8\") %>%\n mutate(is_rsp = PCHG > 15) %>%\n mutate(PARAM = droplevels(PARAM)) %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\") %>%\n mutate(strata = interaction(STRATA1, STRATA2, drop = TRUE))\n\nvar_labels(anl_02)[\"PARAM\"] <- \"Parameter\"\n\nsplit_fun <- drop_split_levels\n\nlyt_02 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n split_rows_by(\n var = \"PARAM\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(anl_02$PARAM)\n ) %>%\n estimate_proportion(vars = \"is_rsp\", table_names = \"est_prop\") %>%\n estimate_proportion_diff(\n var_labels = \"Unstratified Analysis\",\n vars = \"is_rsp\",\n show_labels = \"visible\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(vars = \"is_rsp\", table_names = \"test_prop\") %>%\n estimate_odds_ratio(vars = \"is_rsp\", table_names = \"est_or\") %>%\n estimate_proportion_diff(\n var_labels = \"Stratified Analysis\",\n vars = \"is_rsp\",\n show_labels = \"visible\",\n method = \"cmh\",\n variables = list(strata = \"strata\"),\n table_names = \"est_prop_diff_strat\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n method = \"cmh\",\n variables = list(strata = \"strata\"),\n table_names = \"test_prop_strat\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n variables = list(strata = \"strata\", arm = \"ARM\"),\n table_names = \"est_or_strat\"\n )\n\nresult <- build_table(\n lyt = lyt_02,\n df = anl_02,\n alt_counts_df = adsl\n)\nresult\n\nParameter A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nBFI All Questions \n Responders 57 (42.5%) 65 (48.5%) 50 (37.9%) \n 95% CI (Wald, with correction) (33.8, 51.3) (39.7, 57.3) (29.2, 46.5) \n Unstratified Analysis \n Difference in Response rate (%) 6.0 -4.7 \n 95% CI (Wald, with correction) (-6.7, 18.6) (-17.2, 7.9) \n p-value (Chi-Squared Test) 0.3264 0.4385 \n Odds Ratio (95% CI) 1.27 (0.79 - 2.06) 0.82 (0.50 - 1.35)\n Stratified Analysis \n Difference in Response rate (%) 6.7 -5.1 \n 95% CI (CMH, without correction) (-5.0, 18.4) (-16.8, 6.6) \n p-value (Cochran-Mantel-Haenszel Test) 0.2781 0.4056 \n Odds Ratio (95% CI) 1.30 (0.80 - 2.11) 0.80 (0.49 - 1.32)\nFatigue Interference \n Responders 66 (49.3%) 50 (37.3%) 48 (36.4%) \n 95% CI (Wald, with correction) (40.4, 58.1) (28.8, 45.9) (27.8, 44.9) \n Unstratified Analysis \n Difference in Response rate (%) -11.9 -12.9 \n 95% CI (Wald, with correction) (-24.5, 0.6) (-25.4, -0.3) \n p-value (Chi-Squared Test) 0.0485 0.0337 \n Odds Ratio (95% CI) 0.61 (0.38 - 1.00) 0.59 (0.36 - 0.96)\n Stratified Analysis \n Difference in Response rate (%) -12.0 -13.3 \n 95% CI (CMH, without correction) (-23.7, -0.2) (-24.9, -1.6) \n p-value (Cochran-Mantel-Haenszel Test) 0.0518 0.0303 \n Odds Ratio (95% CI) 0.61 (0.37 - 0.99) 0.58 (0.36 - 0.96)\nFKSI-19 All Questions \n Responders 60 (44.8%) 57 (42.5%) 68 (51.5%) \n 95% CI (Wald, with correction) (36.0, 53.6) (33.8, 51.3) (42.6, 60.4) \n Unstratified Analysis \n Difference in Response rate (%) -2.2 6.7 \n 95% CI (Wald, with correction) (-14.9, 10.4) (-6.0, 19.5) \n p-value (Chi-Squared Test) 0.7118 0.2714 \n Odds Ratio (95% CI) 0.91 (0.56 - 1.48) 1.31 (0.81 - 2.12)\n Stratified Analysis \n Difference in Response rate (%) -2.8 5.6 \n 95% CI (CMH, without correction) (-14.3, 8.8) (-6.2, 17.4) \n p-value (Cochran-Mantel-Haenszel Test) 0.6442 0.3683 \n Odds Ratio (95% CI) 0.90 (0.56 - 1.47) 1.26 (0.77 - 2.04)\nFunction/Well-Being (GF1,GF3,GF7) \n Responders 49 (36.6%) 51 (38.1%) 47 (35.6%) \n 95% CI (Wald, with correction) (28.0, 45.1) (29.5, 46.7) (27.1, 44.2) \n Unstratified Analysis \n Difference in Response rate (%) 1.5 -1.0 \n 95% CI (Wald, with correction) (-10.8, 13.8) (-13.3, 11.3) \n p-value (Chi-Squared Test) 0.8006 0.8704 \n Odds Ratio (95% CI) 1.07 (0.65 - 1.75) 0.96 (0.58 - 1.58)\n Stratified Analysis \n Difference in Response rate (%) 2.8 -1.5 \n 95% CI (CMH, without correction) (-8.2, 13.8) (-13.0, 9.9) \n p-value (Cochran-Mantel-Haenszel Test) 0.6397 0.7952 \n Odds Ratio (95% CI) 1.12 (0.68 - 1.83) 0.99 (0.60 - 1.64)\nTreatment Side Effects (GP2,C5,GP5) \n Responders 62 (46.3%) 49 (36.6%) 51 (38.6%) \n 95% CI (Wald, with correction) (37.5, 55.1) (28.0, 45.1) (30.0, 47.3) \n Unstratified Analysis \n Difference in Response rate (%) -9.7 -7.6 \n 95% CI (Wald, with correction) (-22.2, 2.8) (-20.2, 5.0) \n p-value (Chi-Squared Test) 0.1069 0.2080 \n Odds Ratio (95% CI) 0.67 (0.41 - 1.09) 0.73 (0.45 - 1.19)\n Stratified Analysis \n Difference in Response rate (%) -9.6 -7.1 \n 95% CI (CMH, without correction) (-21.0, 1.8) (-18.8, 4.6) \n p-value (Cochran-Mantel-Haenszel Test) 0.1168 0.2426 \n Odds Ratio (95% CI) 0.67 (0.41 - 1.10) 0.73 (0.45 - 1.19)\n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\narm_ref_comp <- list(\n ARMCD = list(ref = \"ARM B\", comp = c(\"ARM A\", \"ARM C\")),\n ARM = list(ref = \"B: Placebo\", comp = c(\"A: Drug X\", \"C: Combination\"))\n)\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL),\n cdisc_dataset(\"ADRS\", ADRS),\n code =\n 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")'\n ),\n modules = modules(\n tm_t_binary_outcome(\n label = \"Responders\",\n dataname = \"ADRS\",\n paramcd = choices_selected(\n choices = value_choices(ADRS, \"PARAMCD\", \"PARAM\"),\n selected = \"BESRSPI\"\n ),\n arm_var = choices_selected(\n choices = variable_choices(ADRS, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n strata_var = choices_selected(\n choices = variable_choices(ADRS, c(\"SEX\", \"BMRKR2\")),\n select = NULL\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:58:25.8882 pid:8479 token:[] teal.modules.clinical Initializing tm_t_binary_outcome\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nTable of Single Parameter\nTable of Multiple Parameters\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\n\n\n\n\nCodeanl_01 <- adqs %>%\n filter(PARAMCD == \"FKSI-FWB\" & AVISIT == \"WEEK 1 DAY 8\") %>%\n mutate(is_rsp = PCHG > 15) %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\") %>%\n mutate(strata = interaction(STRATA1, STRATA2, drop = TRUE))\n\nlyt_01 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(vars = \"is_rsp\", table_names = \"est_prop\") %>%\n estimate_proportion_diff(\n var_labels = \"Unstratified Analysis\",\n vars = \"is_rsp\",\n show_labels = \"visible\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(vars = \"is_rsp\", table_names = \"test_prop\") %>%\n estimate_odds_ratio(vars = \"is_rsp\", table_names = \"est_or\") %>%\n estimate_proportion_diff(\n var_labels = \"Stratified Analysis\",\n vars = \"is_rsp\",\n show_labels = \"visible\",\n method = \"cmh\",\n variables = list(strata = \"strata\"),\n table_names = \"est_prop_diff_strat\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n method = \"cmh\",\n variables = list(strata = \"strata\"),\n table_names = \"test_prop_strat\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n variables = list(strata = \"strata\", arm = \"ARM\"),\n table_names = \"est_or_strat\"\n )\n\nresult <- build_table(\n lyt = lyt_01,\n df = anl_01,\n alt_counts_df = adsl\n)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nResponders 49 (36.6%) 51 (38.1%) 47 (35.6%) \n95% CI (Wald, with correction) (28.0, 45.1) (29.5, 46.7) (27.1, 44.2) \nUnstratified Analysis \n Difference in Response rate (%) 1.5 -1.0 \n 95% CI (Wald, with correction) (-10.8, 13.8) (-13.3, 11.3) \n p-value (Chi-Squared Test) 0.8006 0.8704 \nOdds Ratio (95% CI) 1.07 (0.65 - 1.75) 0.96 (0.58 - 1.58)\nStratified Analysis \n Difference in Response rate (%) 2.8 -1.5 \n 95% CI (CMH, without correction) (-8.2, 13.8) (-13.0, 9.9) \n p-value (Cochran-Mantel-Haenszel Test) 0.6397 0.7952 \nOdds Ratio (95% CI) 1.12 (0.68 - 1.83) 0.99 (0.60 - 1.64)\n\n\n\n\n\nCodeanl_02 <- adqs %>%\n filter(AVISIT == \"WEEK 1 DAY 8\") %>%\n mutate(is_rsp = PCHG > 15) %>%\n mutate(PARAM = droplevels(PARAM)) %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\") %>%\n mutate(strata = interaction(STRATA1, STRATA2, drop = TRUE))\n\nvar_labels(anl_02)[\"PARAM\"] <- \"Parameter\"\n\nsplit_fun <- drop_split_levels\n\nlyt_02 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n split_rows_by(\n var = \"PARAM\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(anl_02$PARAM)\n ) %>%\n estimate_proportion(vars = \"is_rsp\", table_names = \"est_prop\") %>%\n estimate_proportion_diff(\n var_labels = \"Unstratified Analysis\",\n vars = \"is_rsp\",\n show_labels = \"visible\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(vars = \"is_rsp\", table_names = \"test_prop\") %>%\n estimate_odds_ratio(vars = \"is_rsp\", table_names = \"est_or\") %>%\n estimate_proportion_diff(\n var_labels = \"Stratified Analysis\",\n vars = \"is_rsp\",\n show_labels = \"visible\",\n method = \"cmh\",\n variables = list(strata = \"strata\"),\n table_names = \"est_prop_diff_strat\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n method = \"cmh\",\n variables = list(strata = \"strata\"),\n table_names = \"test_prop_strat\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n variables = list(strata = \"strata\", arm = \"ARM\"),\n table_names = \"est_or_strat\"\n )\n\nresult <- build_table(\n lyt = lyt_02,\n df = anl_02,\n alt_counts_df = adsl\n)\nresult\n\nParameter A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nBFI All Questions \n Responders 57 (42.5%) 65 (48.5%) 50 (37.9%) \n 95% CI (Wald, with correction) (33.8, 51.3) (39.7, 57.3) (29.2, 46.5) \n Unstratified Analysis \n Difference in Response rate (%) 6.0 -4.7 \n 95% CI (Wald, with correction) (-6.7, 18.6) (-17.2, 7.9) \n p-value (Chi-Squared Test) 0.3264 0.4385 \n Odds Ratio (95% CI) 1.27 (0.79 - 2.06) 0.82 (0.50 - 1.35)\n Stratified Analysis \n Difference in Response rate (%) 6.7 -5.1 \n 95% CI (CMH, without correction) (-5.0, 18.4) (-16.8, 6.6) \n p-value (Cochran-Mantel-Haenszel Test) 0.2781 0.4056 \n Odds Ratio (95% CI) 1.30 (0.80 - 2.11) 0.80 (0.49 - 1.32)\nFatigue Interference \n Responders 66 (49.3%) 50 (37.3%) 48 (36.4%) \n 95% CI (Wald, with correction) (40.4, 58.1) (28.8, 45.9) (27.8, 44.9) \n Unstratified Analysis \n Difference in Response rate (%) -11.9 -12.9 \n 95% CI (Wald, with correction) (-24.5, 0.6) (-25.4, -0.3) \n p-value (Chi-Squared Test) 0.0485 0.0337 \n Odds Ratio (95% CI) 0.61 (0.38 - 1.00) 0.59 (0.36 - 0.96)\n Stratified Analysis \n Difference in Response rate (%) -12.0 -13.3 \n 95% CI (CMH, without correction) (-23.7, -0.2) (-24.9, -1.6) \n p-value (Cochran-Mantel-Haenszel Test) 0.0518 0.0303 \n Odds Ratio (95% CI) 0.61 (0.37 - 0.99) 0.58 (0.36 - 0.96)\nFKSI-19 All Questions \n Responders 60 (44.8%) 57 (42.5%) 68 (51.5%) \n 95% CI (Wald, with correction) (36.0, 53.6) (33.8, 51.3) (42.6, 60.4) \n Unstratified Analysis \n Difference in Response rate (%) -2.2 6.7 \n 95% CI (Wald, with correction) (-14.9, 10.4) (-6.0, 19.5) \n p-value (Chi-Squared Test) 0.7118 0.2714 \n Odds Ratio (95% CI) 0.91 (0.56 - 1.48) 1.31 (0.81 - 2.12)\n Stratified Analysis \n Difference in Response rate (%) -2.8 5.6 \n 95% CI (CMH, without correction) (-14.3, 8.8) (-6.2, 17.4) \n p-value (Cochran-Mantel-Haenszel Test) 0.6442 0.3683 \n Odds Ratio (95% CI) 0.90 (0.56 - 1.47) 1.26 (0.77 - 2.04)\nFunction/Well-Being (GF1,GF3,GF7) \n Responders 49 (36.6%) 51 (38.1%) 47 (35.6%) \n 95% CI (Wald, with correction) (28.0, 45.1) (29.5, 46.7) (27.1, 44.2) \n Unstratified Analysis \n Difference in Response rate (%) 1.5 -1.0 \n 95% CI (Wald, with correction) (-10.8, 13.8) (-13.3, 11.3) \n p-value (Chi-Squared Test) 0.8006 0.8704 \n Odds Ratio (95% CI) 1.07 (0.65 - 1.75) 0.96 (0.58 - 1.58)\n Stratified Analysis \n Difference in Response rate (%) 2.8 -1.5 \n 95% CI (CMH, without correction) (-8.2, 13.8) (-13.0, 9.9) \n p-value (Cochran-Mantel-Haenszel Test) 0.6397 0.7952 \n Odds Ratio (95% CI) 1.12 (0.68 - 1.83) 0.99 (0.60 - 1.64)\nTreatment Side Effects (GP2,C5,GP5) \n Responders 62 (46.3%) 49 (36.6%) 51 (38.6%) \n 95% CI (Wald, with correction) (37.5, 55.1) (28.0, 45.1) (30.0, 47.3) \n Unstratified Analysis \n Difference in Response rate (%) -9.7 -7.6 \n 95% CI (Wald, with correction) (-22.2, 2.8) (-20.2, 5.0) \n p-value (Chi-Squared Test) 0.1069 0.2080 \n Odds Ratio (95% CI) 0.67 (0.41 - 1.09) 0.73 (0.45 - 1.19)\n Stratified Analysis \n Difference in Response rate (%) -9.6 -7.1 \n 95% CI (CMH, without correction) (-21.0, 1.8) (-18.8, 4.6) \n p-value (Cochran-Mantel-Haenszel Test) 0.1168 0.2426 \n Odds Ratio (95% CI) 0.67 (0.41 - 1.10) 0.73 (0.45 - 1.19)\n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\narm_ref_comp <- list(\n ARMCD = list(ref = \"ARM B\", comp = c(\"ARM A\", \"ARM C\")),\n ARM = list(ref = \"B: Placebo\", comp = c(\"A: Drug X\", \"C: Combination\"))\n)\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL),\n cdisc_dataset(\"ADRS\", ADRS),\n code =\n 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")'\n ),\n modules = modules(\n tm_t_binary_outcome(\n label = \"Responders\",\n dataname = \"ADRS\",\n paramcd = choices_selected(\n choices = value_choices(ADRS, \"PARAMCD\", \"PARAM\"),\n selected = \"BESRSPI\"\n ),\n arm_var = choices_selected(\n choices = variable_choices(ADRS, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n strata_var = choices_selected(\n choices = variable_choices(ADRS, c(\"SEX\", \"BMRKR2\")),\n select = NULL\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:22:05.8573 pid:8486 token:[] teal.modules.clinical Initializing tm_t_binary_outcome\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/other/ratet01.html",
@@ -214,35 +214,35 @@
"href": "tables/efficacy/lgrt02.html",
"title": "LGRT02",
"section": "",
- "text": "Data Setup\nMulti-Variable Logistic Regression\nMulti-Variable Logistic Regression with Interaction Term\nMulti-Variable Logistic Regression Specifying Covariates\nMulti-Variable Logistic Regression Setting an Event, Alpha Level, and Level for Interaction\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadrs <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadrs <- df_explicit_na(adrs)\n\nadsl <- adsl %>%\n dplyr::filter(SEX %in% c(\"F\", \"M\"))\n\nadrs <- adrs %>%\n dplyr::filter(PARAMCD == \"BESRSPI\") %>%\n dplyr::mutate(\n Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0),\n SEX = factor(SEX, c(\"M\", \"F\")),\n RACE = factor(\n RACE,\n levels = c(\n \"AMERICAN INDIAN OR ALASKA NATIVE\", \"ASIAN\", \"BLACK OR AFRICAN AMERICAN\",\n \"WHITE\", \"MULTIPLE\", \"NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER\"\n )\n )\n ) %>%\n var_relabel(Response = \"Response\", SEX = \"Sex\", RACE = \"Race\")\n\n\n\n\n\nCodemodel <- fit_logistic(\n adrs,\n variables = list(response = \"Response\", arm = \"ARMCD\", covariates = c(\"SEX\", \"AGE\"))\n)\nconf_level <- 0.95\ndf <- broom::tidy(model, conf_level = conf_level)\n\n# empty string flag\ndf <- df_explicit_na(df, na_level = \"_NA_\")\n\nresult <- basic_table() %>%\n summarize_logistic(\n conf_level = conf_level,\n drop_and_remove_str = \"_NA_\"\n ) %>%\n append_topleft(\"Logistic regression\") %>%\n build_table(df = df)\nresult\n\nLogistic regression Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nPlanned Arm Code 2 0.0408 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 -2.094 1.080 0.12 (0.01, 1.02) 0.0524 \n ARM C, n = 132 1 -0.074 1.423 0.93 (0.06, 15.09) 0.9584 \nSex \n Reference M, n = 169 \n F, n = 231 1 0.331 0.695 1.39 (0.36, 5.44) 0.6339 \nAge \n Age 1 0.070 0.054 1.07 (0.97, 1.19) 0.1945 \n\n\n\n\n\nCodemodel <- fit_logistic(\n adrs,\n variables = list(\n response = \"Response\",\n arm = \"ARMCD\",\n covariates = c(\"SEX\", \"AGE\"),\n interaction = \"SEX\"\n )\n)\nconf_level <- 0.95\ndf <- broom::tidy(model, conf_level = conf_level)\n\n# empty string flag\ndf <- df_explicit_na(df, na_level = \"_NA_\")\n\nresult <- basic_table() %>%\n summarize_logistic(\n conf_level = conf_level,\n drop_and_remove_str = \"_NA_\"\n ) %>%\n append_topleft(\"Logistic regression with interaction\") %>%\n build_table(df = df)\nresult\n\nLogistic regression with interaction Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value\n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAge \n Age 1 0.067 0.054 1.07 (0.96, 1.19) 0.2084 \nPlanned Arm Code 2 0.4882 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 -17.850 2362.767 0.9940 \n Sex \n F 0.23 (0.02, 2.11) \n M 0.00 (0.00, >999.99) \n ARM C, n = 132 1 -16.442 2362.767 0.9944 \n Sex \n F >999.99 (0.00, >999.99) \n M 0.00 (0.00, >999.99) \nSex \n Reference M, n = 169 \n F, n = 231 1 -16.044 2362.767 0.9946 \n Planned Arm Code \n ARM A 0.00 (0.00, >999.99) \n ARM B 1.39 (0.29, 6.59) \n ARM C >999.99 (0.00, >999.99) \nInteraction of Planned Arm Code * Sex 2 0.9999 \n Reference ARM A or M, n = 248 \n ARM B * F, n = 82 1 16.373 2362.767 0.9945 \n ARM C * F, n = 70 1 32.492 3156.732 0.9918 \n\n\n\n\n\nCodemodel <- fit_logistic(\n adrs,\n variables = list(\n response = \"Response\",\n arm = \"ARMCD\",\n covariates = c(\"SEX\", \"AGE\", \"RACE\")\n )\n)\nconf_level <- 0.95\ndf <- broom::tidy(model, conf_level = conf_level)\n\n# empty string flag\ndf <- df_explicit_na(df, na_level = \"_NA_\")\n\nresult <- basic_table() %>%\n summarize_logistic(\n conf_level = conf_level,\n drop_and_remove_str = \"_NA_\"\n ) %>%\n append_topleft(\"y ~ ARM + SEX + AGE + RACE\") %>%\n build_table(df = df)\nresult\n\ny ~ ARM + SEX + AGE + RACE Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nPlanned Arm Code 2 0.0346 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 -2.162 1.084 0.12 (0.01, 0.96) 0.0461 \n ARM C, n = 132 1 -0.090 1.426 0.91 (0.06, 14.97) 0.9499 \nSex \n Reference M, n = 169 \n F, n = 231 1 0.364 0.701 1.44 (0.36, 5.69) 0.6032 \nAge \n Age 1 0.071 0.053 1.07 (0.97, 1.19) 0.1866 \nRace 5 0.9685 \n Reference AMERICAN INDIAN OR ALASKA NATIVE, n = 25 \n ASIAN, n = 208 1 -16.246 2017.122 0.00 (0.00, >999.99) 0.9936 \n BLACK OR AFRICAN AMERICAN, n = 91 1 -15.205 2017.122 0.00 (0.00, >999.99) 0.9940 \n WHITE, n = 74 1 -15.955 2017.122 0.00 (0.00, >999.99) 0.9937 \n MULTIPLE, n = 1 1 -0.363 10941.553 0.70 (0.00, >999.99) 1.0000 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER, n = 1 1 1.036 10941.553 2.82 (0.00, >999.99) 0.9999 \n\n\n\n\n\nCodemodel <- fit_logistic(\n adrs,\n variables = list(\n response = \"Response\",\n arm = \"ARMCD\",\n covariates = c(\"SEX\", \"AGE\"),\n interaction = \"AGE\"\n ),\n response_definition = \"1 - response\"\n)\nconf_level <- 0.9\ndf <- broom::tidy(model, conf_level = conf_level, at = c(30, 50))\n\n# empty string flag\ndf <- df_explicit_na(df, na_level = \"_NA_\")\n\nresult <- basic_table() %>%\n summarize_logistic(\n conf_level = conf_level,\n drop_and_remove_str = \"_NA_\"\n ) %>%\n append_topleft(\"Estimations at age 30 and 50\") %>%\n build_table(df = df)\nresult\n\nEstimations at age 30 and 50 Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 90% CI p-value\n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nSex \n Reference M, n = 169 \n F, n = 231 1 -0.381 0.710 0.68 (0.21, 2.20) 0.5915 \nPlanned Arm Code 2 0.2768 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 -20.020 13.714 0.1443 \n Age \n 30 234.91 (0.30, >999.99) \n 50 >999.99 (0.04, >999.99) \n ARM C, n = 132 1 -15.622 14.810 0.2915 \n Age \n 30 31.95 (0.03, >999.99) \n 50 >999.99 (<0.01, >999.99) \nAge \n Age 1 -0.877 0.581 0.1309 \n Planned Arm Code \n ARM A 0.42 (0.16, 1.08) \n ARM B 0.97 (0.89, 1.06) \n ARM C 0.79 (0.55, 1.11) \nInteraction of Planned Arm Code * Age 2 0.2213 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 0.849 0.583 0.1449 \n ARM C, n = 132 1 0.636 0.618 0.3034 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\") %>%\n filter(PARAMCD %in% c(\"BESRSPI\", \"INVET\"))\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\n \"ADRS\", ADRS,\n code = 'ADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\") %>% filter(PARAMCD %in% c(\"BESRSPI\", \"INVET\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_logistic(\n label = \"Logistic Regression\",\n dataname = \"ADRS\",\n arm_var = choices_selected(\n choices = variable_choices(ADRS, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n choices = value_choices(ADRS, \"PARAMCD\", \"PARAM\"),\n selected = \"BESRSPI\"\n ),\n cov_var = choices_selected(\n choices = c(\"SEX\", \"AGE\", \"BMRKR1\", \"BMRKR2\"),\n selected = \"SEX\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:56:08.5151 pid:7984 token:[] teal.modules.clinical Initializing tm_t_logistic\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] abind_1.4-5 multcomp_1.4-25 withr_2.5.0 \n[25] purrr_1.0.2 shinyWidgets_0.7.6 geepack_1.3.9 \n[28] grid_4.3.1 fansi_1.0.4 teal.logger_0.1.3.9000 \n[31] xtable_1.8-4 colorspace_2.1-0 ggplot2_3.4.3 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] splines_4.3.1 assertthat_0.2.1 vctrs_0.6.3 \n[46] webshot_0.5.5 Matrix_1.6-1 sandwich_3.0-2 \n[49] jsonlite_1.8.7 carData_3.0-5 callr_3.7.3 \n[52] car_3.1-2 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[55] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[58] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[61] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[64] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[67] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[70] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[73] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[76] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[79] bslib_0.5.1 httpuv_1.6.11 Rcpp_1.0.11 \n[82] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[85] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[88] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nMulti-Variable Logistic Regression\nMulti-Variable Logistic Regression with Interaction Term\nMulti-Variable Logistic Regression Specifying Covariates\nMulti-Variable Logistic Regression Setting an Event, Alpha Level, and Level for Interaction\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadrs <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadrs <- df_explicit_na(adrs)\n\nadsl <- adsl %>%\n dplyr::filter(SEX %in% c(\"F\", \"M\"))\n\nadrs <- adrs %>%\n dplyr::filter(PARAMCD == \"BESRSPI\") %>%\n dplyr::mutate(\n Response = case_when(AVALC %in% c(\"PR\", \"CR\") ~ 1, TRUE ~ 0),\n SEX = factor(SEX, c(\"M\", \"F\")),\n RACE = factor(\n RACE,\n levels = c(\n \"AMERICAN INDIAN OR ALASKA NATIVE\", \"ASIAN\", \"BLACK OR AFRICAN AMERICAN\",\n \"WHITE\", \"MULTIPLE\", \"NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER\"\n )\n )\n ) %>%\n var_relabel(Response = \"Response\", SEX = \"Sex\", RACE = \"Race\")\n\n\n\n\n\nCodemodel <- fit_logistic(\n adrs,\n variables = list(response = \"Response\", arm = \"ARMCD\", covariates = c(\"SEX\", \"AGE\"))\n)\nconf_level <- 0.95\ndf <- broom::tidy(model, conf_level = conf_level)\n\n# empty string flag\ndf <- df_explicit_na(df, na_level = \"_NA_\")\n\nresult <- basic_table() %>%\n summarize_logistic(\n conf_level = conf_level,\n drop_and_remove_str = \"_NA_\"\n ) %>%\n append_topleft(\"Logistic regression\") %>%\n build_table(df = df)\nresult\n\nLogistic regression Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nPlanned Arm Code 2 0.0408 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 -2.094 1.080 0.12 (0.01, 1.02) 0.0524 \n ARM C, n = 132 1 -0.074 1.423 0.93 (0.06, 15.09) 0.9584 \nSex \n Reference M, n = 169 \n F, n = 231 1 0.331 0.695 1.39 (0.36, 5.44) 0.6339 \nAge \n Age 1 0.070 0.054 1.07 (0.97, 1.19) 0.1945 \n\n\n\n\n\nCodemodel <- fit_logistic(\n adrs,\n variables = list(\n response = \"Response\",\n arm = \"ARMCD\",\n covariates = c(\"SEX\", \"AGE\"),\n interaction = \"SEX\"\n )\n)\nconf_level <- 0.95\ndf <- broom::tidy(model, conf_level = conf_level)\n\n# empty string flag\ndf <- df_explicit_na(df, na_level = \"_NA_\")\n\nresult <- basic_table() %>%\n summarize_logistic(\n conf_level = conf_level,\n drop_and_remove_str = \"_NA_\"\n ) %>%\n append_topleft(\"Logistic regression with interaction\") %>%\n build_table(df = df)\nresult\n\nLogistic regression with interaction Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value\n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAge \n Age 1 0.067 0.054 1.07 (0.96, 1.19) 0.2084 \nPlanned Arm Code 2 0.4882 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 -17.850 2362.767 0.9940 \n Sex \n F 0.23 (0.02, 2.11) \n M 0.00 (0.00, >999.99) \n ARM C, n = 132 1 -16.442 2362.767 0.9944 \n Sex \n F >999.99 (0.00, >999.99) \n M 0.00 (0.00, >999.99) \nSex \n Reference M, n = 169 \n F, n = 231 1 -16.044 2362.767 0.9946 \n Planned Arm Code \n ARM A 0.00 (0.00, >999.99) \n ARM B 1.39 (0.29, 6.59) \n ARM C >999.99 (0.00, >999.99) \nInteraction of Planned Arm Code * Sex 2 0.9999 \n Reference ARM A or M, n = 248 \n ARM B * F, n = 82 1 16.373 2362.767 0.9945 \n ARM C * F, n = 70 1 32.492 3156.732 0.9918 \n\n\n\n\n\nCodemodel <- fit_logistic(\n adrs,\n variables = list(\n response = \"Response\",\n arm = \"ARMCD\",\n covariates = c(\"SEX\", \"AGE\", \"RACE\")\n )\n)\nconf_level <- 0.95\ndf <- broom::tidy(model, conf_level = conf_level)\n\n# empty string flag\ndf <- df_explicit_na(df, na_level = \"_NA_\")\n\nresult <- basic_table() %>%\n summarize_logistic(\n conf_level = conf_level,\n drop_and_remove_str = \"_NA_\"\n ) %>%\n append_topleft(\"y ~ ARM + SEX + AGE + RACE\") %>%\n build_table(df = df)\nresult\n\ny ~ ARM + SEX + AGE + RACE Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nPlanned Arm Code 2 0.0346 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 -2.162 1.084 0.12 (0.01, 0.96) 0.0461 \n ARM C, n = 132 1 -0.090 1.426 0.91 (0.06, 14.97) 0.9499 \nSex \n Reference M, n = 169 \n F, n = 231 1 0.364 0.701 1.44 (0.36, 5.69) 0.6032 \nAge \n Age 1 0.071 0.053 1.07 (0.97, 1.19) 0.1866 \nRace 5 0.9685 \n Reference AMERICAN INDIAN OR ALASKA NATIVE, n = 25 \n ASIAN, n = 208 1 -16.246 2017.122 0.00 (0.00, >999.99) 0.9936 \n BLACK OR AFRICAN AMERICAN, n = 91 1 -15.205 2017.122 0.00 (0.00, >999.99) 0.9940 \n WHITE, n = 74 1 -15.955 2017.122 0.00 (0.00, >999.99) 0.9937 \n MULTIPLE, n = 1 1 -0.363 10941.553 0.70 (0.00, >999.99) 1.0000 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER, n = 1 1 1.036 10941.553 2.82 (0.00, >999.99) 0.9999 \n\n\n\n\n\nCodemodel <- fit_logistic(\n adrs,\n variables = list(\n response = \"Response\",\n arm = \"ARMCD\",\n covariates = c(\"SEX\", \"AGE\"),\n interaction = \"AGE\"\n ),\n response_definition = \"1 - response\"\n)\nconf_level <- 0.9\ndf <- broom::tidy(model, conf_level = conf_level, at = c(30, 50))\n\n# empty string flag\ndf <- df_explicit_na(df, na_level = \"_NA_\")\n\nresult <- basic_table() %>%\n summarize_logistic(\n conf_level = conf_level,\n drop_and_remove_str = \"_NA_\"\n ) %>%\n append_topleft(\"Estimations at age 30 and 50\") %>%\n build_table(df = df)\nresult\n\nEstimations at age 30 and 50 Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 90% CI p-value\n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nSex \n Reference M, n = 169 \n F, n = 231 1 -0.381 0.710 0.68 (0.21, 2.20) 0.5915 \nPlanned Arm Code 2 0.2768 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 -20.020 13.714 0.1443 \n Age \n 30 234.91 (0.30, >999.99) \n 50 >999.99 (0.04, >999.99) \n ARM C, n = 132 1 -15.622 14.810 0.2915 \n Age \n 30 31.95 (0.03, >999.99) \n 50 >999.99 (<0.01, >999.99) \nAge \n Age 1 -0.877 0.581 0.1309 \n Planned Arm Code \n ARM A 0.42 (0.16, 1.08) \n ARM B 0.97 (0.89, 1.06) \n ARM C 0.79 (0.55, 1.11) \nInteraction of Planned Arm Code * Age 2 0.2213 \n Reference ARM A, n = 134 \n ARM B, n = 134 1 0.849 0.583 0.1449 \n ARM C, n = 132 1 0.636 0.618 0.3034 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\") %>%\n filter(PARAMCD %in% c(\"BESRSPI\", \"INVET\"))\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\n \"ADRS\", ADRS,\n code = 'ADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\") %>% filter(PARAMCD %in% c(\"BESRSPI\", \"INVET\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_logistic(\n label = \"Logistic Regression\",\n dataname = \"ADRS\",\n arm_var = choices_selected(\n choices = variable_choices(ADRS, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n choices = value_choices(ADRS, \"PARAMCD\", \"PARAM\"),\n selected = \"BESRSPI\"\n ),\n cov_var = choices_selected(\n choices = c(\"SEX\", \"AGE\", \"BMRKR1\", \"BMRKR2\"),\n selected = \"SEX\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:19:13.7822 pid:7990 token:[] teal.modules.clinical Initializing tm_t_logistic\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] abind_1.4-5 multcomp_1.4-25 withr_2.5.0 \n[25] purrr_1.0.2 shinyWidgets_0.7.6 geepack_1.3.9 \n[28] grid_4.3.1 fansi_1.0.4 teal.logger_0.1.3.9001 \n[31] xtable_1.8-4 colorspace_2.1-0 ggplot2_3.4.3 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] splines_4.3.1 assertthat_0.2.1 vctrs_0.6.3 \n[46] webshot_0.5.5 Matrix_1.6-1 sandwich_3.0-2 \n[49] jsonlite_1.8.7 carData_3.0-5 callr_3.7.3 \n[52] car_3.1-2 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[55] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[58] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[61] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[64] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[67] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[70] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[73] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[76] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[79] bslib_0.5.1 httpuv_1.6.11 Rcpp_1.0.11 \n[82] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[85] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[88] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/efficacy/aovt01.html",
"href": "tables/efficacy/aovt01.html",
"title": "AOVT01",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\nadqs_multi <- filter(adqs, AVISIT == \"WEEK 1 DAY 8\")\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nl <- basic_table() %>%\n split_cols_by(\"ARMCD\", ref_group = \"ARM A\") %>%\n split_rows_by(\"PARAMCD\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adqs_multi$PARAMCD)\n ) %>%\n summarize_ancova(\n vars = \"CHG\",\n variables = list(\n arm = \"ARMCD\",\n covariates = c(\"BASE\", \"STRATA1\")\n ),\n conf_level = 0.95,\n var_labels = \"Adjusted mean\"\n )\n\nresult <- build_table(\n lyt = l,\n df = adqs_multi,\n alt_counts_df = adsl\n)\n\nresult\n\nParameter Code ARM A ARM B ARM C \n————————————————————————————————————————————————————————————————————————\nBFIALL \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 4.47 6.33 4.02 \n Difference in Adjusted Means 1.85 -0.46 \n 95% CI (-0.14, 3.85) (-2.45, 1.54)\n p-value 0.0679 0.6539 \nFATIGI \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 5.42 4.83 4.56 \n Difference in Adjusted Means -0.59 -0.86 \n 95% CI (-2.58, 1.41) (-2.87, 1.15)\n p-value 0.5644 0.4026 \nFKSI-FWB \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 4.29 3.51 3.06 \n Difference in Adjusted Means -0.79 -1.24 \n 95% CI (-2.71, 1.14) (-3.17, 0.69)\n p-value 0.4221 0.2088 \nFKSI-TSE \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 4.70 3.84 4.45 \n Difference in Adjusted Means -0.86 -0.25 \n 95% CI (-2.80, 1.09) (-2.20, 1.70)\n p-value 0.3858 0.8007 \nFKSIALL \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 5.03 5.82 6.44 \n Difference in Adjusted Means 0.79 1.42 \n 95% CI (-1.17, 2.76) (-0.56, 3.39)\n p-value 0.4288 0.1591 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\narm_ref_comp <- list(\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n ),\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADQS\", adqs),\n code =\n 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\n ADQS <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adqs\"))',\n check = TRUE\n ),\n modules = modules(\n tm_t_ancova(\n label = \"ANCOVA table\",\n dataname = \"ADQS\",\n avisit = choices_selected(\n choices = value_choices(adqs, \"AVISIT\"),\n selected = \"WEEK 1 DAY 8\"\n ),\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ACTARMCD\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n aval_var = choices_selected(\n choices = variable_choices(adqs, c(\"CHG\", \"AVAL\")),\n selected = \"CHG\"\n ),\n cov_var = choices_selected(\n choices = variable_choices(adqs, c(\"BASE\", \"STRATA1\", \"SEX\")),\n selected = \"STRATA1\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = c(\"FKSI-FWB\", \"BFIALL\")\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:54:53.2311 pid:7788 token:[] teal.modules.clinical Initializing tm_t_ancova\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\nadqs_multi <- filter(adqs, AVISIT == \"WEEK 1 DAY 8\")\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nl <- basic_table() %>%\n split_cols_by(\"ARMCD\", ref_group = \"ARM A\") %>%\n split_rows_by(\"PARAMCD\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adqs_multi$PARAMCD)\n ) %>%\n summarize_ancova(\n vars = \"CHG\",\n variables = list(\n arm = \"ARMCD\",\n covariates = c(\"BASE\", \"STRATA1\")\n ),\n conf_level = 0.95,\n var_labels = \"Adjusted mean\"\n )\n\nresult <- build_table(\n lyt = l,\n df = adqs_multi,\n alt_counts_df = adsl\n)\n\nresult\n\nParameter Code ARM A ARM B ARM C \n————————————————————————————————————————————————————————————————————————\nBFIALL \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 4.47 6.33 4.02 \n Difference in Adjusted Means 1.85 -0.46 \n 95% CI (-0.14, 3.85) (-2.45, 1.54)\n p-value 0.0679 0.6539 \nFATIGI \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 5.42 4.83 4.56 \n Difference in Adjusted Means -0.59 -0.86 \n 95% CI (-2.58, 1.41) (-2.87, 1.15)\n p-value 0.5644 0.4026 \nFKSI-FWB \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 4.29 3.51 3.06 \n Difference in Adjusted Means -0.79 -1.24 \n 95% CI (-2.71, 1.14) (-3.17, 0.69)\n p-value 0.4221 0.2088 \nFKSI-TSE \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 4.70 3.84 4.45 \n Difference in Adjusted Means -0.86 -0.25 \n 95% CI (-2.80, 1.09) (-2.20, 1.70)\n p-value 0.3858 0.8007 \nFKSIALL \n Adjusted mean \n n 134 134 132 \n Adjusted Mean 5.03 5.82 6.44 \n Difference in Adjusted Means 0.79 1.42 \n 95% CI (-1.17, 2.76) (-0.56, 3.39)\n p-value 0.4288 0.1591 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\narm_ref_comp <- list(\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n ),\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADQS\", adqs),\n code =\n 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\n ADQS <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adqs\"))',\n check = TRUE\n ),\n modules = modules(\n tm_t_ancova(\n label = \"ANCOVA table\",\n dataname = \"ADQS\",\n avisit = choices_selected(\n choices = value_choices(adqs, \"AVISIT\"),\n selected = \"WEEK 1 DAY 8\"\n ),\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ACTARMCD\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n aval_var = choices_selected(\n choices = variable_choices(adqs, c(\"CHG\", \"AVAL\")),\n selected = \"CHG\"\n ),\n cov_var = choices_selected(\n choices = variable_choices(adqs, c(\"BASE\", \"STRATA1\", \"SEX\")),\n selected = \"STRATA1\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = c(\"FKSI-FWB\", \"BFIALL\")\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:17:43.1650 pid:7794 token:[] teal.modules.clinical Initializing tm_t_ancova\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/efficacy/mmrmt01.html",
"href": "tables/efficacy/mmrmt01.html",
"title": "MMRMT01",
"section": "",
- "text": "Data Setup\nLeast Squares Means\nFixed Effects\nCovariance Matrix\nModel Diagnostics\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern.mmrm)\nlibrary(scda)\nlibrary(broom)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\nadqs_f <- adqs %>%\n dplyr::filter(PARAMCD == \"FKSI-FWB\" & !AVISIT %in% c(\"BASELINE\", \"SCREENING\")) %>%\n droplevels() %>%\n dplyr::mutate(ARMCD = factor(ARMCD, levels = c(\"ARM B\", \"ARM A\", \"ARM C\"))) %>%\n dplyr::mutate(\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor()\n )\nadsl_sub <- adqs_f %>%\n dplyr::filter(!is.na(CHG)) %>%\n distinct(USUBJID) %>%\n left_join(adsl, by = \"USUBJID\")\nvar_labels(adqs_f) <- var_labels(adqs)\n\n\n\n\nConsidering the treatment variable in the model\n\nCodemmrm_results <- fit_mmrm(\n vars = list(\n response = \"CHG\",\n covariates = c(\"BASE\", \"STRATA1\", \"BMRKR2\"),\n id = \"USUBJID\",\n arm = \"ARMCD\",\n visit = \"AVISIT\"\n ),\n data = adqs_f,\n weights_emmeans = \"equal\"\n)\n\ndf <- tidy(mmrm_results)\nattr(df$AVISIT, \"label\") <- \"Visit\"\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\", ref_group = mmrm_results$ref_level) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(df$AVISIT)) %>%\n summarize_lsmeans(show_relative = \"increase\") %>%\n append_topleft(\" Statistics\") %>%\n build_table(df, alt_counts_df = adsl_sub)\n\nresult\n\nVisit ARM B ARM A ARM C \n Statistics (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nWEEK 1 DAY 8 \n n 134 134 132 \n Adjusted Mean (SE) 3.488 (0.687) 4.246 (0.687) 3.163 (0.692) \n 95% CI (2.136, 4.839) (2.895, 5.598) (1.803, 4.523) \n Difference in Adjusted Means (SE) 0.759 (0.973) -0.325 (0.976) \n 95% CI (-1.155, 2.672) (-2.243, 1.593) \n Relative Increase (%) 21.8% -9.3% \n p-value (MMRM) 0.4362 0.7393 \nWEEK 2 DAY 15 \n n 134 134 132 \n Adjusted Mean (SE) 9.135 (0.768) 9.018 (0.767) 8.509 (0.773) \n 95% CI (7.626, 10.644) (7.510, 10.527) (6.991, 10.028) \n Difference in Adjusted Means (SE) -0.117 (1.087) -0.626 (1.090) \n 95% CI (-2.253, 2.020) (-2.768, 1.517) \n Relative Increase (%) -1.3% -6.8% \n p-value (MMRM) 0.9147 0.5662 \nWEEK 3 DAY 22 \n n 134 134 132 \n Adjusted Mean (SE) 13.547 (0.871) 16.014 (0.871) 15.789 (0.877) \n 95% CI (11.835, 15.259) (14.303, 17.726) (14.066, 17.513)\n Difference in Adjusted Means (SE) 2.467 (1.232) 2.242 (1.236) \n 95% CI (0.044, 4.890) (-0.187, 4.672) \n Relative Increase (%) 18.2% 16.6% \n p-value (MMRM) 0.0460 0.0704 \nWEEK 4 DAY 29 \n n 134 134 132 \n Adjusted Mean (SE) 18.102 (0.995) 19.479 (0.995) 19.511 (1.002) \n 95% CI (16.146, 20.059) (17.523, 21.435) (17.541, 21.481)\n Difference in Adjusted Means (SE) 1.377 (1.408) 1.409 (1.413) \n 95% CI (-1.392, 4.145) (-1.368, 4.186) \n Relative Increase (%) 7.6% 7.8% \n p-value (MMRM) 0.3288 0.3192 \nWEEK 5 DAY 36 \n n 134 134 132 \n Adjusted Mean (SE) 23.503 (1.058) 24.931 (1.058) 23.704 (1.065) \n 95% CI (21.423, 25.583) (22.851, 27.011) (21.610, 25.798)\n Difference in Adjusted Means (SE) 1.428 (1.497) 0.201 (1.502) \n 95% CI (-1.515, 4.371) (-2.752, 3.153) \n Relative Increase (%) 6.1% 0.9% \n p-value (MMRM) 0.3408 0.8937 \n\n\nNot considering the treatment variable in the model\n\nCodemmrm_results_no_arm <- fit_mmrm(\n vars = list(\n response = \"CHG\",\n covariates = c(\"BMRKR2\", \"STRATA1\"),\n id = \"USUBJID\",\n visit = \"AVISIT\"\n ),\n data = adqs_f,\n weights_emmeans = \"equal\",\n parallel = TRUE\n)\n\ndf_no_arm <- tidy(mmrm_results_no_arm)\nattr(df_no_arm$AVISIT, \"label\") <- \"Visit\"\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(df_no_arm$AVISIT)) %>%\n summarize_lsmeans(arms = FALSE) %>%\n append_topleft(\" Statistics\") %>%\n build_table(df_no_arm, alt_counts_df = adsl_sub)\n\nresult\n\nVisit All Patients \n Statistics (N=400) \n———————————————————————————————————————\nWEEK 1 DAY 8 \n n 400 \n Adjusted Mean (SE) 3.615 (0.620) \n 95% CI (2.396, 4.834) \nWEEK 2 DAY 15 \n n 400 \n Adjusted Mean (SE) 8.870 (0.602) \n 95% CI (7.687, 10.053) \nWEEK 3 DAY 22 \n n 400 \n Adjusted Mean (SE) 15.094 (0.683) \n 95% CI (13.751, 16.437)\nWEEK 4 DAY 29 \n n 400 \n Adjusted Mean (SE) 19.009 (0.717) \n 95% CI (17.599, 20.418)\nWEEK 5 DAY 36 \n n 400 \n Adjusted Mean (SE) 24.028 (0.747) \n 95% CI (22.560, 25.496)\n\n\nAdding baseline rows\nIt may be of interest to summarize some different statistics at the baseline visit or summarize a different variable in the data set not used in the MMRM. For example, the model may use the variable CHG but the baseline visit row may summarize the AVAL variable, thus we would need to create two tables and then combine them to accomplish this.\n\nCode# First have the least-square means table.\na <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\", ref_group = mmrm_results$ref_level) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(df$AVISIT)) %>%\n summarize_lsmeans(show_relative = \"increase\") %>%\n append_topleft(\" Statistics\") %>%\n build_table(df, alt_counts_df = adsl_sub)\n\n# Second prepare the baseline values summary table.\nbaseline_dat <- adqs %>%\n filter(AVISIT == \"BASELINE\") %>%\n droplevels()\n\nb <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\") %>%\n split_rows_by(\"AVISIT\") %>%\n analyze_vars(\"AVAL\") %>%\n append_topleft(\" Statistics\") %>%\n build_table(baseline_dat, alt_counts_df = adsl_sub)\n\n# Now we can combine them as follows.\ncol_info(b) <- EmptyColInfo\nrbind(b, a)\n\nVisit ARM B ARM A ARM C \n Statistics (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nBASELINE \n n 670 670 660 \n Mean (SD) 49.8 (8.1) 50.4 (8.3) 50.2 (8.4) \n Median 49.6 50.2 50.4 \n Min - Max 24.3 - 72.9 21.7 - 74.5 26.0 - 71.4 \nWEEK 1 DAY 8 \n n 134 134 132 \n Adjusted Mean (SE) 3.488 (0.687) 4.246 (0.687) 3.163 (0.692) \n 95% CI (2.136, 4.839) (2.895, 5.598) (1.803, 4.523) \n Difference in Adjusted Means (SE) 0.759 (0.973) -0.325 (0.976) \n 95% CI (-1.155, 2.672) (-2.243, 1.593) \n Relative Increase (%) 21.8% -9.3% \n p-value (MMRM) 0.4362 0.7393 \nWEEK 2 DAY 15 \n n 134 134 132 \n Adjusted Mean (SE) 9.135 (0.768) 9.018 (0.767) 8.509 (0.773) \n 95% CI (7.626, 10.644) (7.510, 10.527) (6.991, 10.028) \n Difference in Adjusted Means (SE) -0.117 (1.087) -0.626 (1.090) \n 95% CI (-2.253, 2.020) (-2.768, 1.517) \n Relative Increase (%) -1.3% -6.8% \n p-value (MMRM) 0.9147 0.5662 \nWEEK 3 DAY 22 \n n 134 134 132 \n Adjusted Mean (SE) 13.547 (0.871) 16.014 (0.871) 15.789 (0.877) \n 95% CI (11.835, 15.259) (14.303, 17.726) (14.066, 17.513)\n Difference in Adjusted Means (SE) 2.467 (1.232) 2.242 (1.236) \n 95% CI (0.044, 4.890) (-0.187, 4.672) \n Relative Increase (%) 18.2% 16.6% \n p-value (MMRM) 0.0460 0.0704 \nWEEK 4 DAY 29 \n n 134 134 132 \n Adjusted Mean (SE) 18.102 (0.995) 19.479 (0.995) 19.511 (1.002) \n 95% CI (16.146, 20.059) (17.523, 21.435) (17.541, 21.481)\n Difference in Adjusted Means (SE) 1.377 (1.408) 1.409 (1.413) \n 95% CI (-1.392, 4.145) (-1.368, 4.186) \n Relative Increase (%) 7.6% 7.8% \n p-value (MMRM) 0.3288 0.3192 \nWEEK 5 DAY 36 \n n 134 134 132 \n Adjusted Mean (SE) 23.503 (1.058) 24.931 (1.058) 23.704 (1.065) \n 95% CI (21.423, 25.583) (22.851, 27.011) (21.610, 25.798)\n Difference in Adjusted Means (SE) 1.428 (1.497) 0.201 (1.502) \n 95% CI (-1.515, 4.371) (-2.752, 3.153) \n Relative Increase (%) 6.1% 0.9% \n p-value (MMRM) 0.3408 0.8937 \n\n\nConsidering visit averages\nIt may also be of interest to summarize several different statistics for an averaged combination of various visits in the MMRM. For example, you may want to see the statistics for the average of the first 2 visits, or the average statistics of all visits combined. This can be accomplished by specifying the averages_emmeans argument when fitting the MMRM model.\n\nCodemmrm_results_avg_visits <- fit_mmrm(\n vars = list(\n response = \"CHG\",\n covariates = c(\"BASE\", \"STRATA1\", \"BMRKR2\"),\n id = \"USUBJID\",\n arm = \"ARMCD\",\n visit = \"AVISIT\"\n ),\n data = adqs_f,\n weights_emmeans = \"equal\",\n averages_emmeans = list(\n \"WEEKS 1-2\" = c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\"),\n \"WEEKS 3-5\" = c(\"WEEK 3 DAY 22\", \"WEEK 4 DAY 29\", \"WEEK 5 DAY 36\"),\n \"ALL VISITS\" = c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\", \"WEEK 4 DAY 29\", \"WEEK 5 DAY 36\")\n )\n)\n\ndf_avgs <- tidy(mmrm_results_avg_visits)\nattr(df_avgs$AVISIT, \"label\") <- \"Visit\"\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\", ref_group = mmrm_results_avg_visits$ref_level) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(df_avgs$AVISIT)) %>%\n summarize_lsmeans(show_relative = \"increase\") %>%\n append_topleft(\" Statistics\") %>%\n build_table(df_avgs, alt_counts_df = adsl_sub)\n\nresult\n\nVisit ARM B ARM A ARM C \n Statistics (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nWEEK 1 DAY 8 \n n 134 134 132 \n Adjusted Mean (SE) 3.488 (0.687) 4.246 (0.687) 3.163 (0.692) \n 95% CI (2.136, 4.839) (2.895, 5.598) (1.803, 4.523) \n Difference in Adjusted Means (SE) 0.759 (0.973) -0.325 (0.976) \n 95% CI (-1.155, 2.672) (-2.243, 1.593) \n Relative Increase (%) 21.8% -9.3% \n p-value (MMRM) 0.4362 0.7393 \nWEEK 2 DAY 15 \n n 134 134 132 \n Adjusted Mean (SE) 9.135 (0.768) 9.018 (0.767) 8.509 (0.773) \n 95% CI (7.626, 10.644) (7.510, 10.527) (6.991, 10.028) \n Difference in Adjusted Means (SE) -0.117 (1.087) -0.626 (1.090) \n 95% CI (-2.253, 2.020) (-2.768, 1.517) \n Relative Increase (%) -1.3% -6.8% \n p-value (MMRM) 0.9147 0.5662 \nWEEK 3 DAY 22 \n n 134 134 132 \n Adjusted Mean (SE) 13.547 (0.871) 16.014 (0.871) 15.789 (0.877) \n 95% CI (11.835, 15.259) (14.303, 17.726) (14.066, 17.513)\n Difference in Adjusted Means (SE) 2.467 (1.232) 2.242 (1.236) \n 95% CI (0.044, 4.890) (-0.187, 4.672) \n Relative Increase (%) 18.2% 16.6% \n p-value (MMRM) 0.0460 0.0704 \nWEEK 4 DAY 29 \n n 134 134 132 \n Adjusted Mean (SE) 18.102 (0.995) 19.479 (0.995) 19.511 (1.002) \n 95% CI (16.146, 20.059) (17.523, 21.435) (17.541, 21.481)\n Difference in Adjusted Means (SE) 1.377 (1.408) 1.409 (1.413) \n 95% CI (-1.392, 4.145) (-1.368, 4.186) \n Relative Increase (%) 7.6% 7.8% \n p-value (MMRM) 0.3288 0.3192 \nWEEK 5 DAY 36 \n n 134 134 132 \n Adjusted Mean (SE) 23.503 (1.058) 24.931 (1.058) 23.704 (1.065) \n 95% CI (21.423, 25.583) (22.851, 27.011) (21.610, 25.798)\n Difference in Adjusted Means (SE) 1.428 (1.497) 0.201 (1.502) \n 95% CI (-1.515, 4.371) (-2.752, 3.153) \n Relative Increase (%) 6.1% 0.9% \n p-value (MMRM) 0.3408 0.8937 \nWEEKS 1-2 \n n 134 134 132 \n Adjusted Mean (SE) 6.311 (0.514) 6.632 (0.514) 5.836 (0.516) \n 95% CI (5.301, 7.322) (5.623, 7.642) (4.821, 6.852) \n Difference in Adjusted Means (SE) 0.321 (0.728) -0.475 (0.729) \n 95% CI (-1.111, 1.753) (-1.909, 0.959) \n Relative Increase (%) 5.1% -7.5% \n p-value (MMRM) 0.6596 0.5151 \nWEEKS 3-5 \n n 134 134 132 \n Adjusted Mean (SE) 18.384 (0.560) 20.141 (0.560) 19.668 (0.563) \n 95% CI (17.284, 19.485) (19.041, 21.241) (18.562, 20.775)\n Difference in Adjusted Means (SE) 1.757 (0.793) 1.284 (0.794) \n 95% CI (0.198, 3.316) (-0.278, 2.846) \n Relative Increase (%) 9.6% 7.0% \n p-value (MMRM) 0.0273 0.1068 \nALL VISITS \n n 134 134 132 \n Adjusted Mean (SE) 13.555 (0.388) 14.738 (0.388) 14.135 (0.389) \n 95% CI (12.792, 14.318) (13.976, 15.500) (13.370, 14.900)\n Difference in Adjusted Means (SE) 1.183 (0.551) 0.580 (0.551) \n 95% CI (0.100, 2.266) (-0.502, 1.663) \n Relative Increase (%) 8.7% 4.3% \n p-value (MMRM) 0.0324 0.2924 \n\n\n\n\n\nConsidering the treatment variable in the model\n\nCodeas.rtable(mmrm_results, type = \"fixed\")\n\n Estimate Std. Error t value df Pr(>|t|)\n——————————————————————————————————————————————————————————————————————————————————\n(Intercept) 55.7483 1.5244 36.5713 510 <0.0001 \nBASE -1.0196 0.0246 -41.4362 392 <0.0001 \nSTRATA1B -0.0369 0.5345 -0.0691 392 0.9450 \nSTRATA1C 0.0205 0.5238 0.0392 392 0.9688 \nBMRKR2MEDIUM -0.3840 0.5198 -0.7386 392 0.4606 \nBMRKR2HIGH -1.0056 0.5259 -1.9123 392 0.0566 \nARMCDARM A 0.7587 0.9733 0.7795 396 0.4362 \nARMCDARM C -0.3248 0.9756 -0.3329 394 0.7393 \nAVISITWEEK 2 DAY 15 5.6472 1.0331 5.4665 397 <0.0001 \nAVISITWEEK 3 DAY 22 10.0591 1.0897 9.2311 397 <0.0001 \nAVISITWEEK 4 DAY 29 14.6145 1.2176 12.0027 397 <0.0001 \nAVISITWEEK 5 DAY 36 20.0154 1.2584 15.9057 397 <0.0001 \nARMCDARM A:AVISITWEEK 2 DAY 15 -0.8752 1.4610 -0.5990 397 0.5495 \nARMCDARM C:AVISITWEEK 2 DAY 15 -0.3007 1.4665 -0.2050 397 0.8376 \nARMCDARM A:AVISITWEEK 3 DAY 22 1.7085 1.5411 1.1087 397 0.2682 \nARMCDARM C:AVISITWEEK 3 DAY 22 2.5673 1.5469 1.6597 397 0.0978 \nARMCDARM A:AVISITWEEK 4 DAY 29 0.6181 1.7220 0.3589 397 0.7198 \nARMCDARM C:AVISITWEEK 4 DAY 29 1.7337 1.7285 1.0030 397 0.3165 \nARMCDARM A:AVISITWEEK 5 DAY 36 0.6690 1.7796 0.3759 397 0.7072 \nARMCDARM C:AVISITWEEK 5 DAY 36 0.5257 1.7863 0.2943 397 0.7687 \n\n\nNot considering the treatment variable in the model\n\nCodeas.rtable(mmrm_results_no_arm, type = \"fixed\")\n\n Estimate Std. Error t value df Pr(>|t|)\n——————————————————————————————————————————————————————————————————————\n(Intercept) 1.5624 1.1751 1.3296 466 0.1843 \nBMRKR2MEDIUM 1.0924 1.1878 0.9196 395 0.3583 \nBMRKR2HIGH 1.4619 1.1971 1.2212 395 0.2227 \nSTRATA1B 2.6321 1.2180 2.1610 395 0.0313 \nSTRATA1C 0.9717 1.2008 0.8092 395 0.4189 \nAVISITWEEK 2 DAY 15 5.2548 0.5967 8.8061 399 <0.0001 \nAVISITWEEK 3 DAY 22 11.4787 0.6314 18.1802 399 <0.0001 \nAVISITWEEK 4 DAY 29 15.3937 0.7039 21.8696 399 <0.0001 \nAVISITWEEK 5 DAY 36 20.4130 0.7266 28.0921 399 <0.0001 \n\n\n\n\n\n\nCodeas.rtable(mmrm_results, type = \"cov\")\n\n WEEK 1 DAY 8 WEEK 2 DAY 15 WEEK 3 DAY 22 WEEK 4 DAY 29 WEEK 5 DAY 36\n————————————————————————————————————————————————————————————————————————————————————————————\nWEEK 1 DAY 8 63.0140 -0.6664 2.5965 -1.6231 0.2589 \nWEEK 2 DAY 15 -0.6664 78.6592 1.7004 -11.8677 -0.4261 \nWEEK 3 DAY 22 2.5965 1.7004 101.2949 -5.8424 7.1145 \nWEEK 4 DAY 29 -1.6231 -11.8677 -5.8424 132.4034 -5.3739 \nWEEK 5 DAY 36 0.2589 -0.4261 7.1145 -5.3739 149.6937 \n\n\n\n\nModel diagnostics are currently available to evaluate choice of covariates for the fixed and random effects. Statistics to evaluate choice of covariance structure are being investigated and will be included in a future release.\n\nCodeas.rtable(mmrm_results, type = \"diagnostic\")\n\n Diagnostic statistic value\n———————————————————————————————————————————\nREML criterion 14835.9968 \nAIC 14865.9968 \nAICc 14866.2412 \nBIC 14925.8688 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\") %>%\n dplyr::filter(ABLFL != \"Y\" & ABLFL2 != \"Y\") %>%\n dplyr::filter(AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\")) %>%\n dplyr::mutate(\n AVISIT = as.factor(AVISIT),\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor() # making consecutive numeric factor\n )\n\narm_ref_comp <- list(\n ARMCD = list(\n ref = \"ARM A\",\n comp = c(\"ARM B\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADQS\", adqs,\n code = 'ADQS <- synthetic_cdisc_dataset(\"latest\", \"adqs\") %>%\n dplyr::filter(ABLFL != \"Y\" & ABLFL2 != \"Y\") %>%\n dplyr::filter(AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\")) %>%\n dplyr::mutate(\n AVISIT = as.factor(AVISIT),\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor() # making consecutive numeric factor\n )'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_a_mmrm(\n label = \"MMRM\",\n dataname = \"ADQS\",\n aval_var = choices_selected(c(\"AVAL\", \"CHG\"), \"CHG\"),\n id_var = choices_selected(c(\"USUBJID\", \"SUBJID\"), \"USUBJID\"),\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARMCD\"),\n visit_var = choices_selected(c(\"AVISIT\", \"AVISITN\"), \"AVISIT\"),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = \"FKSI-FWB\"\n ),\n cov_var = choices_selected(c(\"BASE\", \"AGE\", \"SEX\", \"BASE:AVISIT\"), NULL),\n conf_level = choices_selected(c(0.95, 0.9, 0.8), 0.95)\n )\n )\n)\n\n[INFO] 2023-09-08 19:53:34.7033 pid:7586 token:[] teal.modules.clinical Initializing tm_a_mmrm\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] broom_1.0.5 scda_0.1.6.9012 \n [9] tern.mmrm_0.2.2.9006 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] Rdpack_2.4 mmrm_0.2.2 tern.gee_0.1.0.9008 \n [4] logger_0.2.2 testthat_3.1.10 sandwich_3.0-2 \n [7] rlang_1.1.1 multcomp_1.4-25 compiler_4.3.1 \n[10] callr_3.7.3 vctrs_0.6.3 stringr_1.5.0 \n[13] pkgconfig_2.0.3 fastmap_1.1.1 backports_1.4.1 \n[16] ellipsis_0.3.2 fontawesome_0.5.1 utf8_1.2.3 \n[19] promises_1.2.1 rmarkdown_2.24 ps_1.7.5 \n[22] purrr_1.0.2 xfun_0.40 cachem_1.0.8 \n[25] teal.reporter_0.2.1 jsonlite_1.8.7 later_1.3.1 \n[28] parallel_4.3.1 R6_2.5.1 bslib_0.5.1 \n[31] stringi_1.7.12 parallelly_1.36.0 brio_1.1.3 \n[34] jquerylib_0.1.4 numDeriv_2016.8-1.1 estimability_1.4.1 \n[37] Rcpp_1.0.11 assertthat_0.2.1 knitr_1.43 \n[40] zoo_1.8-12 teal.logger_0.1.3.9000 httpuv_1.6.11 \n[43] Matrix_1.6-1 splines_4.3.1 tidyselect_1.2.0 \n[46] rstudioapi_0.15.0 yaml_2.3.7 TMB_1.9.6 \n[49] codetools_0.2-19 processx_3.8.2 teal.widgets_0.4.0.9007\n[52] lattice_0.21-8 tibble_3.2.1 withr_2.5.0 \n[55] coda_0.19-4 evaluate_0.21 survival_3.5-7 \n[58] shinycssloaders_1.0.0 pillar_1.9.0 checkmate_2.2.0 \n[61] shinyjs_2.1.0 generics_0.1.3 ggplot2_3.4.3 \n[64] munsell_0.5.0 scales_1.2.1 xtable_1.8-4 \n[67] glue_1.6.2 emmeans_1.8.7 tools_4.3.1 \n[70] webshot_0.5.5 forcats_1.0.0 mvtnorm_1.2-2 \n[73] cowplot_1.1.1 grid_4.3.1 tidyr_1.3.0 \n[76] rbibutils_2.2.14 colorspace_2.1-0 nlme_3.1-163 \n[79] cli_3.6.1 fansi_1.0.4 geepack_1.3.9 \n[82] gtable_0.3.3 sass_0.4.7 digest_0.6.33 \n[85] TH.data_1.1-2 htmlwidgets_1.6.2 memoise_2.0.1 \n[88] htmltools_0.5.6 lifecycle_1.0.3 shinyWidgets_0.7.6 \n[91] mime_0.12 MASS_7.3-60 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nLeast Squares Means\nFixed Effects\nCovariance Matrix\nModel Diagnostics\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern.mmrm)\nlibrary(scda)\nlibrary(broom)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\nadqs_f <- adqs %>%\n dplyr::filter(PARAMCD == \"FKSI-FWB\" & !AVISIT %in% c(\"BASELINE\", \"SCREENING\")) %>%\n droplevels() %>%\n dplyr::mutate(ARMCD = factor(ARMCD, levels = c(\"ARM B\", \"ARM A\", \"ARM C\"))) %>%\n dplyr::mutate(\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor()\n )\nadsl_sub <- adqs_f %>%\n dplyr::filter(!is.na(CHG)) %>%\n distinct(USUBJID) %>%\n left_join(adsl, by = \"USUBJID\")\nvar_labels(adqs_f) <- var_labels(adqs)\n\n\n\n\nConsidering the treatment variable in the model\n\nCodemmrm_results <- fit_mmrm(\n vars = list(\n response = \"CHG\",\n covariates = c(\"BASE\", \"STRATA1\", \"BMRKR2\"),\n id = \"USUBJID\",\n arm = \"ARMCD\",\n visit = \"AVISIT\"\n ),\n data = adqs_f,\n weights_emmeans = \"equal\"\n)\n\ndf <- tidy(mmrm_results)\nattr(df$AVISIT, \"label\") <- \"Visit\"\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\", ref_group = mmrm_results$ref_level) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(df$AVISIT)) %>%\n summarize_lsmeans(show_relative = \"increase\") %>%\n append_topleft(\" Statistics\") %>%\n build_table(df, alt_counts_df = adsl_sub)\n\nresult\n\nVisit ARM B ARM A ARM C \n Statistics (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nWEEK 1 DAY 8 \n n 134 134 132 \n Adjusted Mean (SE) 3.488 (0.687) 4.246 (0.687) 3.163 (0.692) \n 95% CI (2.136, 4.839) (2.895, 5.598) (1.803, 4.523) \n Difference in Adjusted Means (SE) 0.759 (0.973) -0.325 (0.976) \n 95% CI (-1.155, 2.672) (-2.243, 1.593) \n Relative Increase (%) 21.8% -9.3% \n p-value (MMRM) 0.4362 0.7393 \nWEEK 2 DAY 15 \n n 134 134 132 \n Adjusted Mean (SE) 9.135 (0.768) 9.018 (0.767) 8.509 (0.773) \n 95% CI (7.626, 10.644) (7.510, 10.527) (6.991, 10.028) \n Difference in Adjusted Means (SE) -0.117 (1.087) -0.626 (1.090) \n 95% CI (-2.253, 2.020) (-2.768, 1.517) \n Relative Increase (%) -1.3% -6.8% \n p-value (MMRM) 0.9147 0.5662 \nWEEK 3 DAY 22 \n n 134 134 132 \n Adjusted Mean (SE) 13.547 (0.871) 16.014 (0.871) 15.789 (0.877) \n 95% CI (11.835, 15.259) (14.303, 17.726) (14.066, 17.513)\n Difference in Adjusted Means (SE) 2.467 (1.232) 2.242 (1.236) \n 95% CI (0.044, 4.890) (-0.187, 4.672) \n Relative Increase (%) 18.2% 16.6% \n p-value (MMRM) 0.0460 0.0704 \nWEEK 4 DAY 29 \n n 134 134 132 \n Adjusted Mean (SE) 18.102 (0.995) 19.479 (0.995) 19.511 (1.002) \n 95% CI (16.146, 20.059) (17.523, 21.435) (17.541, 21.481)\n Difference in Adjusted Means (SE) 1.377 (1.408) 1.409 (1.413) \n 95% CI (-1.392, 4.145) (-1.368, 4.186) \n Relative Increase (%) 7.6% 7.8% \n p-value (MMRM) 0.3288 0.3192 \nWEEK 5 DAY 36 \n n 134 134 132 \n Adjusted Mean (SE) 23.503 (1.058) 24.931 (1.058) 23.704 (1.065) \n 95% CI (21.423, 25.583) (22.851, 27.011) (21.610, 25.798)\n Difference in Adjusted Means (SE) 1.428 (1.497) 0.201 (1.502) \n 95% CI (-1.515, 4.371) (-2.752, 3.153) \n Relative Increase (%) 6.1% 0.9% \n p-value (MMRM) 0.3408 0.8937 \n\n\nNot considering the treatment variable in the model\n\nCodemmrm_results_no_arm <- fit_mmrm(\n vars = list(\n response = \"CHG\",\n covariates = c(\"BMRKR2\", \"STRATA1\"),\n id = \"USUBJID\",\n visit = \"AVISIT\"\n ),\n data = adqs_f,\n weights_emmeans = \"equal\",\n parallel = TRUE\n)\n\ndf_no_arm <- tidy(mmrm_results_no_arm)\nattr(df_no_arm$AVISIT, \"label\") <- \"Visit\"\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(df_no_arm$AVISIT)) %>%\n summarize_lsmeans(arms = FALSE) %>%\n append_topleft(\" Statistics\") %>%\n build_table(df_no_arm, alt_counts_df = adsl_sub)\n\nresult\n\nVisit All Patients \n Statistics (N=400) \n———————————————————————————————————————\nWEEK 1 DAY 8 \n n 400 \n Adjusted Mean (SE) 3.615 (0.620) \n 95% CI (2.396, 4.834) \nWEEK 2 DAY 15 \n n 400 \n Adjusted Mean (SE) 8.870 (0.602) \n 95% CI (7.687, 10.053) \nWEEK 3 DAY 22 \n n 400 \n Adjusted Mean (SE) 15.094 (0.683) \n 95% CI (13.751, 16.437)\nWEEK 4 DAY 29 \n n 400 \n Adjusted Mean (SE) 19.009 (0.717) \n 95% CI (17.599, 20.418)\nWEEK 5 DAY 36 \n n 400 \n Adjusted Mean (SE) 24.028 (0.747) \n 95% CI (22.560, 25.496)\n\n\nAdding baseline rows\nIt may be of interest to summarize some different statistics at the baseline visit or summarize a different variable in the data set not used in the MMRM. For example, the model may use the variable CHG but the baseline visit row may summarize the AVAL variable, thus we would need to create two tables and then combine them to accomplish this.\n\nCode# First have the least-square means table.\na <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\", ref_group = mmrm_results$ref_level) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(df$AVISIT)) %>%\n summarize_lsmeans(show_relative = \"increase\") %>%\n append_topleft(\" Statistics\") %>%\n build_table(df, alt_counts_df = adsl_sub)\n\n# Second prepare the baseline values summary table.\nbaseline_dat <- adqs %>%\n filter(AVISIT == \"BASELINE\") %>%\n droplevels()\n\nb <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\") %>%\n split_rows_by(\"AVISIT\") %>%\n analyze_vars(\"AVAL\") %>%\n append_topleft(\" Statistics\") %>%\n build_table(baseline_dat, alt_counts_df = adsl_sub)\n\n# Now we can combine them as follows.\ncol_info(b) <- EmptyColInfo\nrbind(b, a)\n\nVisit ARM B ARM A ARM C \n Statistics (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nBASELINE \n n 670 670 660 \n Mean (SD) 49.8 (8.1) 50.4 (8.3) 50.2 (8.4) \n Median 49.6 50.2 50.4 \n Min - Max 24.3 - 72.9 21.7 - 74.5 26.0 - 71.4 \nWEEK 1 DAY 8 \n n 134 134 132 \n Adjusted Mean (SE) 3.488 (0.687) 4.246 (0.687) 3.163 (0.692) \n 95% CI (2.136, 4.839) (2.895, 5.598) (1.803, 4.523) \n Difference in Adjusted Means (SE) 0.759 (0.973) -0.325 (0.976) \n 95% CI (-1.155, 2.672) (-2.243, 1.593) \n Relative Increase (%) 21.8% -9.3% \n p-value (MMRM) 0.4362 0.7393 \nWEEK 2 DAY 15 \n n 134 134 132 \n Adjusted Mean (SE) 9.135 (0.768) 9.018 (0.767) 8.509 (0.773) \n 95% CI (7.626, 10.644) (7.510, 10.527) (6.991, 10.028) \n Difference in Adjusted Means (SE) -0.117 (1.087) -0.626 (1.090) \n 95% CI (-2.253, 2.020) (-2.768, 1.517) \n Relative Increase (%) -1.3% -6.8% \n p-value (MMRM) 0.9147 0.5662 \nWEEK 3 DAY 22 \n n 134 134 132 \n Adjusted Mean (SE) 13.547 (0.871) 16.014 (0.871) 15.789 (0.877) \n 95% CI (11.835, 15.259) (14.303, 17.726) (14.066, 17.513)\n Difference in Adjusted Means (SE) 2.467 (1.232) 2.242 (1.236) \n 95% CI (0.044, 4.890) (-0.187, 4.672) \n Relative Increase (%) 18.2% 16.6% \n p-value (MMRM) 0.0460 0.0704 \nWEEK 4 DAY 29 \n n 134 134 132 \n Adjusted Mean (SE) 18.102 (0.995) 19.479 (0.995) 19.511 (1.002) \n 95% CI (16.146, 20.059) (17.523, 21.435) (17.541, 21.481)\n Difference in Adjusted Means (SE) 1.377 (1.408) 1.409 (1.413) \n 95% CI (-1.392, 4.145) (-1.368, 4.186) \n Relative Increase (%) 7.6% 7.8% \n p-value (MMRM) 0.3288 0.3192 \nWEEK 5 DAY 36 \n n 134 134 132 \n Adjusted Mean (SE) 23.503 (1.058) 24.931 (1.058) 23.704 (1.065) \n 95% CI (21.423, 25.583) (22.851, 27.011) (21.610, 25.798)\n Difference in Adjusted Means (SE) 1.428 (1.497) 0.201 (1.502) \n 95% CI (-1.515, 4.371) (-2.752, 3.153) \n Relative Increase (%) 6.1% 0.9% \n p-value (MMRM) 0.3408 0.8937 \n\n\nConsidering visit averages\nIt may also be of interest to summarize several different statistics for an averaged combination of various visits in the MMRM. For example, you may want to see the statistics for the average of the first 2 visits, or the average statistics of all visits combined. This can be accomplished by specifying the averages_emmeans argument when fitting the MMRM model.\n\nCodemmrm_results_avg_visits <- fit_mmrm(\n vars = list(\n response = \"CHG\",\n covariates = c(\"BASE\", \"STRATA1\", \"BMRKR2\"),\n id = \"USUBJID\",\n arm = \"ARMCD\",\n visit = \"AVISIT\"\n ),\n data = adqs_f,\n weights_emmeans = \"equal\",\n averages_emmeans = list(\n \"WEEKS 1-2\" = c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\"),\n \"WEEKS 3-5\" = c(\"WEEK 3 DAY 22\", \"WEEK 4 DAY 29\", \"WEEK 5 DAY 36\"),\n \"ALL VISITS\" = c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\", \"WEEK 4 DAY 29\", \"WEEK 5 DAY 36\")\n )\n)\n\ndf_avgs <- tidy(mmrm_results_avg_visits)\nattr(df_avgs$AVISIT, \"label\") <- \"Visit\"\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\", ref_group = mmrm_results_avg_visits$ref_level) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(df_avgs$AVISIT)) %>%\n summarize_lsmeans(show_relative = \"increase\") %>%\n append_topleft(\" Statistics\") %>%\n build_table(df_avgs, alt_counts_df = adsl_sub)\n\nresult\n\nVisit ARM B ARM A ARM C \n Statistics (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nWEEK 1 DAY 8 \n n 134 134 132 \n Adjusted Mean (SE) 3.488 (0.687) 4.246 (0.687) 3.163 (0.692) \n 95% CI (2.136, 4.839) (2.895, 5.598) (1.803, 4.523) \n Difference in Adjusted Means (SE) 0.759 (0.973) -0.325 (0.976) \n 95% CI (-1.155, 2.672) (-2.243, 1.593) \n Relative Increase (%) 21.8% -9.3% \n p-value (MMRM) 0.4362 0.7393 \nWEEK 2 DAY 15 \n n 134 134 132 \n Adjusted Mean (SE) 9.135 (0.768) 9.018 (0.767) 8.509 (0.773) \n 95% CI (7.626, 10.644) (7.510, 10.527) (6.991, 10.028) \n Difference in Adjusted Means (SE) -0.117 (1.087) -0.626 (1.090) \n 95% CI (-2.253, 2.020) (-2.768, 1.517) \n Relative Increase (%) -1.3% -6.8% \n p-value (MMRM) 0.9147 0.5662 \nWEEK 3 DAY 22 \n n 134 134 132 \n Adjusted Mean (SE) 13.547 (0.871) 16.014 (0.871) 15.789 (0.877) \n 95% CI (11.835, 15.259) (14.303, 17.726) (14.066, 17.513)\n Difference in Adjusted Means (SE) 2.467 (1.232) 2.242 (1.236) \n 95% CI (0.044, 4.890) (-0.187, 4.672) \n Relative Increase (%) 18.2% 16.6% \n p-value (MMRM) 0.0460 0.0704 \nWEEK 4 DAY 29 \n n 134 134 132 \n Adjusted Mean (SE) 18.102 (0.995) 19.479 (0.995) 19.511 (1.002) \n 95% CI (16.146, 20.059) (17.523, 21.435) (17.541, 21.481)\n Difference in Adjusted Means (SE) 1.377 (1.408) 1.409 (1.413) \n 95% CI (-1.392, 4.145) (-1.368, 4.186) \n Relative Increase (%) 7.6% 7.8% \n p-value (MMRM) 0.3288 0.3192 \nWEEK 5 DAY 36 \n n 134 134 132 \n Adjusted Mean (SE) 23.503 (1.058) 24.931 (1.058) 23.704 (1.065) \n 95% CI (21.423, 25.583) (22.851, 27.011) (21.610, 25.798)\n Difference in Adjusted Means (SE) 1.428 (1.497) 0.201 (1.502) \n 95% CI (-1.515, 4.371) (-2.752, 3.153) \n Relative Increase (%) 6.1% 0.9% \n p-value (MMRM) 0.3408 0.8937 \nWEEKS 1-2 \n n 134 134 132 \n Adjusted Mean (SE) 6.311 (0.514) 6.632 (0.514) 5.836 (0.516) \n 95% CI (5.301, 7.322) (5.623, 7.642) (4.821, 6.852) \n Difference in Adjusted Means (SE) 0.321 (0.728) -0.475 (0.729) \n 95% CI (-1.111, 1.753) (-1.909, 0.959) \n Relative Increase (%) 5.1% -7.5% \n p-value (MMRM) 0.6596 0.5151 \nWEEKS 3-5 \n n 134 134 132 \n Adjusted Mean (SE) 18.384 (0.560) 20.141 (0.560) 19.668 (0.563) \n 95% CI (17.284, 19.485) (19.041, 21.241) (18.562, 20.775)\n Difference in Adjusted Means (SE) 1.757 (0.793) 1.284 (0.794) \n 95% CI (0.198, 3.316) (-0.278, 2.846) \n Relative Increase (%) 9.6% 7.0% \n p-value (MMRM) 0.0273 0.1068 \nALL VISITS \n n 134 134 132 \n Adjusted Mean (SE) 13.555 (0.388) 14.738 (0.388) 14.135 (0.389) \n 95% CI (12.792, 14.318) (13.976, 15.500) (13.370, 14.900)\n Difference in Adjusted Means (SE) 1.183 (0.551) 0.580 (0.551) \n 95% CI (0.100, 2.266) (-0.502, 1.663) \n Relative Increase (%) 8.7% 4.3% \n p-value (MMRM) 0.0324 0.2924 \n\n\n\n\n\nConsidering the treatment variable in the model\n\nCodeas.rtable(mmrm_results, type = \"fixed\")\n\n Estimate Std. Error t value df Pr(>|t|)\n——————————————————————————————————————————————————————————————————————————————————\n(Intercept) 55.7483 1.5244 36.5713 510 <0.0001 \nBASE -1.0196 0.0246 -41.4362 392 <0.0001 \nSTRATA1B -0.0369 0.5345 -0.0691 392 0.9450 \nSTRATA1C 0.0205 0.5238 0.0392 392 0.9688 \nBMRKR2MEDIUM -0.3840 0.5198 -0.7386 392 0.4606 \nBMRKR2HIGH -1.0056 0.5259 -1.9123 392 0.0566 \nARMCDARM A 0.7587 0.9733 0.7795 396 0.4362 \nARMCDARM C -0.3248 0.9756 -0.3329 394 0.7393 \nAVISITWEEK 2 DAY 15 5.6472 1.0331 5.4665 397 <0.0001 \nAVISITWEEK 3 DAY 22 10.0591 1.0897 9.2311 397 <0.0001 \nAVISITWEEK 4 DAY 29 14.6145 1.2176 12.0027 397 <0.0001 \nAVISITWEEK 5 DAY 36 20.0154 1.2584 15.9057 397 <0.0001 \nARMCDARM A:AVISITWEEK 2 DAY 15 -0.8752 1.4610 -0.5990 397 0.5495 \nARMCDARM C:AVISITWEEK 2 DAY 15 -0.3007 1.4665 -0.2050 397 0.8376 \nARMCDARM A:AVISITWEEK 3 DAY 22 1.7085 1.5411 1.1087 397 0.2682 \nARMCDARM C:AVISITWEEK 3 DAY 22 2.5673 1.5469 1.6597 397 0.0978 \nARMCDARM A:AVISITWEEK 4 DAY 29 0.6181 1.7220 0.3589 397 0.7198 \nARMCDARM C:AVISITWEEK 4 DAY 29 1.7337 1.7285 1.0030 397 0.3165 \nARMCDARM A:AVISITWEEK 5 DAY 36 0.6690 1.7796 0.3759 397 0.7072 \nARMCDARM C:AVISITWEEK 5 DAY 36 0.5257 1.7863 0.2943 397 0.7687 \n\n\nNot considering the treatment variable in the model\n\nCodeas.rtable(mmrm_results_no_arm, type = \"fixed\")\n\n Estimate Std. Error t value df Pr(>|t|)\n——————————————————————————————————————————————————————————————————————\n(Intercept) 1.5624 1.1751 1.3296 466 0.1843 \nBMRKR2MEDIUM 1.0924 1.1878 0.9196 395 0.3583 \nBMRKR2HIGH 1.4619 1.1971 1.2212 395 0.2227 \nSTRATA1B 2.6321 1.2180 2.1610 395 0.0313 \nSTRATA1C 0.9717 1.2008 0.8092 395 0.4189 \nAVISITWEEK 2 DAY 15 5.2548 0.5967 8.8061 399 <0.0001 \nAVISITWEEK 3 DAY 22 11.4787 0.6314 18.1802 399 <0.0001 \nAVISITWEEK 4 DAY 29 15.3937 0.7039 21.8696 399 <0.0001 \nAVISITWEEK 5 DAY 36 20.4130 0.7266 28.0921 399 <0.0001 \n\n\n\n\n\n\nCodeas.rtable(mmrm_results, type = \"cov\")\n\n WEEK 1 DAY 8 WEEK 2 DAY 15 WEEK 3 DAY 22 WEEK 4 DAY 29 WEEK 5 DAY 36\n————————————————————————————————————————————————————————————————————————————————————————————\nWEEK 1 DAY 8 63.0140 -0.6664 2.5965 -1.6231 0.2589 \nWEEK 2 DAY 15 -0.6664 78.6592 1.7004 -11.8677 -0.4261 \nWEEK 3 DAY 22 2.5965 1.7004 101.2949 -5.8424 7.1145 \nWEEK 4 DAY 29 -1.6231 -11.8677 -5.8424 132.4034 -5.3739 \nWEEK 5 DAY 36 0.2589 -0.4261 7.1145 -5.3739 149.6937 \n\n\n\n\nModel diagnostics are currently available to evaluate choice of covariates for the fixed and random effects. Statistics to evaluate choice of covariance structure are being investigated and will be included in a future release.\n\nCodeas.rtable(mmrm_results, type = \"diagnostic\")\n\n Diagnostic statistic value\n———————————————————————————————————————————\nREML criterion 14835.9968 \nAIC 14865.9968 \nAICc 14866.2412 \nBIC 14925.8688 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\") %>%\n dplyr::filter(ABLFL != \"Y\" & ABLFL2 != \"Y\") %>%\n dplyr::filter(AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\")) %>%\n dplyr::mutate(\n AVISIT = as.factor(AVISIT),\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor() # making consecutive numeric factor\n )\n\narm_ref_comp <- list(\n ARMCD = list(\n ref = \"ARM A\",\n comp = c(\"ARM B\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADQS\", adqs,\n code = 'ADQS <- synthetic_cdisc_dataset(\"latest\", \"adqs\") %>%\n dplyr::filter(ABLFL != \"Y\" & ABLFL2 != \"Y\") %>%\n dplyr::filter(AVISIT %in% c(\"WEEK 1 DAY 8\", \"WEEK 2 DAY 15\", \"WEEK 3 DAY 22\")) %>%\n dplyr::mutate(\n AVISIT = as.factor(AVISIT),\n AVISITN = rank(AVISITN) %>%\n as.factor() %>%\n as.numeric() %>%\n as.factor() # making consecutive numeric factor\n )'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_a_mmrm(\n label = \"MMRM\",\n dataname = \"ADQS\",\n aval_var = choices_selected(c(\"AVAL\", \"CHG\"), \"CHG\"),\n id_var = choices_selected(c(\"USUBJID\", \"SUBJID\"), \"USUBJID\"),\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARMCD\"),\n visit_var = choices_selected(c(\"AVISIT\", \"AVISITN\"), \"AVISIT\"),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = \"FKSI-FWB\"\n ),\n cov_var = choices_selected(c(\"BASE\", \"AGE\", \"SEX\", \"BASE:AVISIT\"), NULL),\n conf_level = choices_selected(c(0.95, 0.9, 0.8), 0.95)\n )\n )\n)\n\n[INFO] 2023-09-09 18:16:10.3389 pid:7592 token:[] teal.modules.clinical Initializing tm_a_mmrm\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] broom_1.0.5 scda_0.1.6.9012 \n [9] tern.mmrm_0.2.2.9006 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] Rdpack_2.4 mmrm_0.2.2 tern.gee_0.1.0.9008 \n [4] logger_0.2.2 testthat_3.1.10 sandwich_3.0-2 \n [7] rlang_1.1.1 multcomp_1.4-25 compiler_4.3.1 \n[10] callr_3.7.3 vctrs_0.6.3 stringr_1.5.0 \n[13] pkgconfig_2.0.3 fastmap_1.1.1 backports_1.4.1 \n[16] ellipsis_0.3.2 fontawesome_0.5.1 utf8_1.2.3 \n[19] promises_1.2.1 rmarkdown_2.24 ps_1.7.5 \n[22] purrr_1.0.2 xfun_0.40 cachem_1.0.8 \n[25] teal.reporter_0.2.1 jsonlite_1.8.7 later_1.3.1 \n[28] parallel_4.3.1 R6_2.5.1 bslib_0.5.1 \n[31] stringi_1.7.12 parallelly_1.36.0 brio_1.1.3 \n[34] jquerylib_0.1.4 numDeriv_2016.8-1.1 estimability_1.4.1 \n[37] Rcpp_1.0.11 assertthat_0.2.1 knitr_1.43 \n[40] zoo_1.8-12 teal.logger_0.1.3.9001 httpuv_1.6.11 \n[43] Matrix_1.6-1 splines_4.3.1 tidyselect_1.2.0 \n[46] rstudioapi_0.15.0 yaml_2.3.7 TMB_1.9.6 \n[49] codetools_0.2-19 processx_3.8.2 teal.widgets_0.4.0.9007\n[52] lattice_0.21-8 tibble_3.2.1 withr_2.5.0 \n[55] coda_0.19-4 evaluate_0.21 survival_3.5-7 \n[58] shinycssloaders_1.0.0 pillar_1.9.0 checkmate_2.2.0 \n[61] shinyjs_2.1.0 generics_0.1.3 ggplot2_3.4.3 \n[64] munsell_0.5.0 scales_1.2.1 xtable_1.8-4 \n[67] glue_1.6.2 emmeans_1.8.7 tools_4.3.1 \n[70] webshot_0.5.5 forcats_1.0.0 mvtnorm_1.2-2 \n[73] cowplot_1.1.1 grid_4.3.1 tidyr_1.3.0 \n[76] rbibutils_2.2.14 colorspace_2.1-0 nlme_3.1-163 \n[79] cli_3.6.1 fansi_1.0.4 geepack_1.3.9 \n[82] gtable_0.3.3 sass_0.4.7 digest_0.6.33 \n[85] TH.data_1.1-2 htmlwidgets_1.6.2 memoise_2.0.1 \n[88] htmltools_0.5.6 lifecycle_1.0.3 shinyWidgets_0.7.6 \n[91] mime_0.12 MASS_7.3-60 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/efficacy/dort01.html",
"href": "tables/efficacy/dort01.html",
"title": "DORT01",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Selecting Sections to Display\nTable Modifying Analysis Details like Conf. Type and Alpha Level\nTable Modifying Time Point for the “XX Months duration” Analysis\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\nadtte_f <- adtte %>%\n filter(PARAMCD == \"CRSD\" & BMEASIFL == \"Y\") %>%\n dplyr::mutate(\n AVAL = day2month(AVAL),\n is_event = CNSR == 0,\n is_not_event = CNSR == 1,\n EVNT1 = factor(\n case_when(\n is_event == TRUE ~ \"Responders with subsequent event (%)\",\n is_event == FALSE ~ \"Responders without subsequent event (%)\"\n ),\n levels = c(\"Responders with subsequent event (%)\", \"Responders without subsequent event (%)\")\n ),\n EVNTDESC = factor(EVNTDESC)\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n count_values(\n vars = \"USUBJID\",\n values = unique(adtte$USUBJID),\n .labels = \"Responders\",\n .stats = \"count\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders with subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n show_labels = \"hidden\",\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Responders with subsequent event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 2L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders without subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Duration of response (Months)\",\n is_event = \"is_event\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months duration\",\n is_event = \"is_event\",\n time_point = 12\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table(prune_func = prune_zeros_only)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————\nResponders 68 73 62 \n Responders with subsequent event (%) 46 (67.6%) 39 (53.4%) 32 (51.6%) \n Earliest contributing event \n Death 26 24 16 \n Disease Progression 20 15 16 \n Responders without subsequent event (%) 22 (32.4%) 34 (46.6%) 30 (48.4%) \nDuration of response (Months) \n Median 5.3 6.2 5.3 \n 95% CI (4.6, 5.8) (5.4, 6.3) (4.6, 5.8) \n 25% and 75%-ile 3.8, 6.3 4.6, 6.4 4.0, 6.1 \n Range (censored) 3.6 to 6.3 3.3 to 6.5 3.3 to 6.4 \n Range (event) 0.5 to 6.4 0.9 to 6.5 0.6 to 6.6 \n12 Months duration \n Patients remaining at risk NA NA NA \n Event Free Rate (%) NA NA NA \n 95% CI NA NA NA \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n count_values(\n vars = \"USUBJID\",\n values = unique(adtte$USUBJID),\n .labels = \"Responders\",\n .stats = \"count\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders with subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n show_labels = \"hidden\",\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Responders with subsequent event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 2L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders without subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Duration of response (Months)\",\n is_event = \"is_event\",\n table_names = \"surv_time\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"cox_pair\"\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table(prune_func = prune_zeros_only)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nResponders 68 73 62 \n Responders with subsequent event (%) 46 (67.6%) 39 (53.4%) 32 (51.6%) \n Earliest contributing event \n Death 26 24 16 \n Disease Progression 20 15 16 \n Responders without subsequent event (%) 22 (32.4%) 34 (46.6%) 30 (48.4%) \nDuration of response (Months) \n Median 5.3 6.2 5.3 \n 95% CI (4.6, 5.8) (5.4, 6.3) (4.6, 5.8) \n 25% and 75%-ile 3.8, 6.3 4.6, 6.4 4.0, 6.1 \n Range (censored) 3.6 to 6.3 3.3 to 6.5 3.3 to 6.4 \n Range (event) 0.5 to 6.4 0.9 to 6.5 0.6 to 6.6 \nUnstratified Analysis \n p-value (log-rank) 0.0223 0.6659 \n Hazard Ratio 0.60 0.90 \n 95% CI (0.39, 0.93) (0.57, 1.44) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n count_values(\n vars = \"USUBJID\",\n values = unique(adtte$USUBJID),\n .labels = \"Responders\",\n .stats = \"count\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders with subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n show_labels = \"hidden\",\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Responders with subsequent event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 2L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders without subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Duration of response (Months)\",\n is_event = \"is_event\",\n control = control_surv_time(conf_level = 0.90, conf_type = \"log-log\")\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months duration\",\n is_event = \"is_event\",\n time_point = 12,\n control = control_surv_timepoint(conf_level = 0.975)\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table(prune_func = prune_zeros_only)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————\nResponders 68 73 62 \n Responders with subsequent event (%) 46 (67.6%) 39 (53.4%) 32 (51.6%) \n Earliest contributing event \n Death 26 24 16 \n Disease Progression 20 15 16 \n Responders without subsequent event (%) 22 (32.4%) 34 (46.6%) 30 (48.4%) \nDuration of response (Months) \n Median 5.3 6.2 5.3 \n 90% CI (4.6, 5.8) (5.5, 6.3) (4.6, 5.7) \n 25% and 75%-ile 3.8, 6.3 4.6, 6.4 4.0, 6.1 \n Range (censored) 3.6 to 6.3 3.3 to 6.5 3.3 to 6.4 \n Range (event) 0.5 to 6.4 0.9 to 6.5 0.6 to 6.6 \n12 Months duration \n Patients remaining at risk NA NA NA \n Event Free Rate (%) NA NA NA \n 97.5% CI NA NA NA \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n count_values(\n vars = \"USUBJID\",\n values = unique(adtte$USUBJID),\n .labels = \"Responders\",\n .stats = \"count\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders with subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n show_labels = \"hidden\",\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Responders with subsequent event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 2L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders without subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Duration of response (Months)\",\n is_event = \"is_event\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months duration\",\n is_event = \"is_event\",\n time_point = 6\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table(prune_func = prune_zeros_only)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nResponders 68 73 62 \n Responders with subsequent event (%) 46 (67.6%) 39 (53.4%) 32 (51.6%) \n Earliest contributing event \n Death 26 24 16 \n Disease Progression 20 15 16 \n Responders without subsequent event (%) 22 (32.4%) 34 (46.6%) 30 (48.4%) \nDuration of response (Months) \n Median 5.3 6.2 5.3 \n 95% CI (4.6, 5.8) (5.4, 6.3) (4.6, 5.8) \n 25% and 75%-ile 3.8, 6.3 4.6, 6.4 4.0, 6.1 \n Range (censored) 3.6 to 6.3 3.3 to 6.5 3.3 to 6.4 \n Range (event) 0.5 to 6.4 0.9 to 6.5 0.6 to 6.6 \n6 Months duration \n Patients remaining at risk 10 18 7 \n Event Free Rate (%) 33.46 50.23 30.56 \n 95% CI (20.88, 46.05) (36.54, 63.92) (13.56, 47.57)\n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nADSL <- df_explicit_na(ADSL)\nADTTE <- df_explicit_na(ADTTE)\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% df_explicit_na()'),\n cdisc_dataset(\"ADTTE\", ADTTE, code = 'ADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\") %>% df_explicit_na()'),\n check = TRUE\n ),\n modules = modules(\n tm_t_tte(\n label = \"Time To Event Table\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(\n variable_choices(ADSL, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(ADTTE, \"PARAMCD\", \"PARAM\"),\n \"CRSD\"\n ),\n strata_var = choices_selected(\n variable_choices(ADSL, c(\"SEX\", \"BMRKR2\")),\n \"SEX\"\n ),\n time_points = choices_selected(c(6, 8), 6),\n event_desc_var = choices_selected(\n variable_choices(ADTTE, \"EVNTDESC\"),\n \"EVNTDESC\",\n fixed = TRUE\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:51:53.0681 pid:7390 token:[] teal.modules.clinical Initializing tm_t_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Selecting Sections to Display\nTable Modifying Analysis Details like Conf. Type and Alpha Level\nTable Modifying Time Point for the “XX Months duration” Analysis\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\nadtte_f <- adtte %>%\n filter(PARAMCD == \"CRSD\" & BMEASIFL == \"Y\") %>%\n dplyr::mutate(\n AVAL = day2month(AVAL),\n is_event = CNSR == 0,\n is_not_event = CNSR == 1,\n EVNT1 = factor(\n case_when(\n is_event == TRUE ~ \"Responders with subsequent event (%)\",\n is_event == FALSE ~ \"Responders without subsequent event (%)\"\n ),\n levels = c(\"Responders with subsequent event (%)\", \"Responders without subsequent event (%)\")\n ),\n EVNTDESC = factor(EVNTDESC)\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n count_values(\n vars = \"USUBJID\",\n values = unique(adtte$USUBJID),\n .labels = \"Responders\",\n .stats = \"count\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders with subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n show_labels = \"hidden\",\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Responders with subsequent event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 2L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders without subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Duration of response (Months)\",\n is_event = \"is_event\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months duration\",\n is_event = \"is_event\",\n time_point = 12\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table(prune_func = prune_zeros_only)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————\nResponders 68 73 62 \n Responders with subsequent event (%) 46 (67.6%) 39 (53.4%) 32 (51.6%) \n Earliest contributing event \n Death 26 24 16 \n Disease Progression 20 15 16 \n Responders without subsequent event (%) 22 (32.4%) 34 (46.6%) 30 (48.4%) \nDuration of response (Months) \n Median 5.3 6.2 5.3 \n 95% CI (4.6, 5.8) (5.4, 6.3) (4.6, 5.8) \n 25% and 75%-ile 3.8, 6.3 4.6, 6.4 4.0, 6.1 \n Range (censored) 3.6 to 6.3 3.3 to 6.5 3.3 to 6.4 \n Range (event) 0.5 to 6.4 0.9 to 6.5 0.6 to 6.6 \n12 Months duration \n Patients remaining at risk NA NA NA \n Event Free Rate (%) NA NA NA \n 95% CI NA NA NA \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n count_values(\n vars = \"USUBJID\",\n values = unique(adtte$USUBJID),\n .labels = \"Responders\",\n .stats = \"count\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders with subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n show_labels = \"hidden\",\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Responders with subsequent event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 2L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders without subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Duration of response (Months)\",\n is_event = \"is_event\",\n table_names = \"surv_time\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"cox_pair\"\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table(prune_func = prune_zeros_only)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nResponders 68 73 62 \n Responders with subsequent event (%) 46 (67.6%) 39 (53.4%) 32 (51.6%) \n Earliest contributing event \n Death 26 24 16 \n Disease Progression 20 15 16 \n Responders without subsequent event (%) 22 (32.4%) 34 (46.6%) 30 (48.4%) \nDuration of response (Months) \n Median 5.3 6.2 5.3 \n 95% CI (4.6, 5.8) (5.4, 6.3) (4.6, 5.8) \n 25% and 75%-ile 3.8, 6.3 4.6, 6.4 4.0, 6.1 \n Range (censored) 3.6 to 6.3 3.3 to 6.5 3.3 to 6.4 \n Range (event) 0.5 to 6.4 0.9 to 6.5 0.6 to 6.6 \nUnstratified Analysis \n p-value (log-rank) 0.0223 0.6659 \n Hazard Ratio 0.60 0.90 \n 95% CI (0.39, 0.93) (0.57, 1.44) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n count_values(\n vars = \"USUBJID\",\n values = unique(adtte$USUBJID),\n .labels = \"Responders\",\n .stats = \"count\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders with subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n show_labels = \"hidden\",\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Responders with subsequent event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 2L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders without subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Duration of response (Months)\",\n is_event = \"is_event\",\n control = control_surv_time(conf_level = 0.90, conf_type = \"log-log\")\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months duration\",\n is_event = \"is_event\",\n time_point = 12,\n control = control_surv_timepoint(conf_level = 0.975)\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table(prune_func = prune_zeros_only)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————\nResponders 68 73 62 \n Responders with subsequent event (%) 46 (67.6%) 39 (53.4%) 32 (51.6%) \n Earliest contributing event \n Death 26 24 16 \n Disease Progression 20 15 16 \n Responders without subsequent event (%) 22 (32.4%) 34 (46.6%) 30 (48.4%) \nDuration of response (Months) \n Median 5.3 6.2 5.3 \n 90% CI (4.6, 5.8) (5.5, 6.3) (4.6, 5.7) \n 25% and 75%-ile 3.8, 6.3 4.6, 6.4 4.0, 6.1 \n Range (censored) 3.6 to 6.3 3.3 to 6.5 3.3 to 6.4 \n Range (event) 0.5 to 6.4 0.9 to 6.5 0.6 to 6.6 \n12 Months duration \n Patients remaining at risk NA NA NA \n Event Free Rate (%) NA NA NA \n 97.5% CI NA NA NA \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n count_values(\n vars = \"USUBJID\",\n values = unique(adtte$USUBJID),\n .labels = \"Responders\",\n .stats = \"count\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders with subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n show_labels = \"hidden\",\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Responders with subsequent event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 2L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Responders without subsequent event (%)\"),\n .indent_mods = c(count_fraction = 1L),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Duration of response (Months)\",\n is_event = \"is_event\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months duration\",\n is_event = \"is_event\",\n time_point = 6\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table(prune_func = prune_zeros_only)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nResponders 68 73 62 \n Responders with subsequent event (%) 46 (67.6%) 39 (53.4%) 32 (51.6%) \n Earliest contributing event \n Death 26 24 16 \n Disease Progression 20 15 16 \n Responders without subsequent event (%) 22 (32.4%) 34 (46.6%) 30 (48.4%) \nDuration of response (Months) \n Median 5.3 6.2 5.3 \n 95% CI (4.6, 5.8) (5.4, 6.3) (4.6, 5.8) \n 25% and 75%-ile 3.8, 6.3 4.6, 6.4 4.0, 6.1 \n Range (censored) 3.6 to 6.3 3.3 to 6.5 3.3 to 6.4 \n Range (event) 0.5 to 6.4 0.9 to 6.5 0.6 to 6.6 \n6 Months duration \n Patients remaining at risk 10 18 7 \n Event Free Rate (%) 33.46 50.23 30.56 \n 95% CI (20.88, 46.05) (36.54, 63.92) (13.56, 47.57)\n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nADSL <- df_explicit_na(ADSL)\nADTTE <- df_explicit_na(ADTTE)\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% df_explicit_na()'),\n cdisc_dataset(\"ADTTE\", ADTTE, code = 'ADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\") %>% df_explicit_na()'),\n check = TRUE\n ),\n modules = modules(\n tm_t_tte(\n label = \"Time To Event Table\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(\n variable_choices(ADSL, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(ADTTE, \"PARAMCD\", \"PARAM\"),\n \"CRSD\"\n ),\n strata_var = choices_selected(\n variable_choices(ADSL, c(\"SEX\", \"BMRKR2\")),\n \"SEX\"\n ),\n time_points = choices_selected(c(6, 8), 6),\n event_desc_var = choices_selected(\n variable_choices(ADTTE, \"EVNTDESC\"),\n \"EVNTDESC\",\n fixed = TRUE\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:14:09.3930 pid:7395 token:[] teal.modules.clinical Initializing tm_t_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/efficacy/coxt02.html",
"href": "tables/efficacy/coxt02.html",
"title": "COXT02",
"section": "",
- "text": "Analysis based on multivariable Cox models is usually not performed for the Clinical Study Report (CSR) or regulatory documents, serving exploratory purposes only (e.g. for publication). In practice, the model usually includes only the main effects (without interaction terms). It produces the estimates for each of the covariates included in the model. The analysis follows the same principles (i.e. stratified vs. unstratified analysis and tie handling) as the general Cox model analysis also used in COXT01. Since there is usually no pre-specified hypothesis testing for such analysis, the p-values must be interpreted with caution.\n\n\nData Setup\nMultivariable Cox Regression\nMultivariable Cox Regression with Interaction Term\nMultivariable Cox Regression Specifying Covariates\nMultivariable Cox Regression Specifying Covariates from ADSUB\nMultivariable Cox Regression Setting Strata, Ties, Alpha Level, Statistics\nMultivariable Cox Regression with Selection Process for Covariates\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\nlibrary(broom)\n\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadtte <- df_explicit_na(adtte)\n\nanl <- adtte %>%\n filter(\n PARAMCD == \"OS\",\n SEX %in% c(\"F\", \"M\"),\n RACE %in% c(\"ASIAN\", \"BLACK OR AFRICAN AMERICAN\", \"WHITE\")\n ) %>%\n mutate(\n ARM = droplevels(relevel(ARM, \"B: Placebo\")),\n SEX = droplevels(SEX),\n RACE = droplevels(RACE)\n ) %>%\n mutate(EVENT = 1 - CNSR) %>%\n var_relabel(\n ARM = \"Planned Arm\",\n SEX = \"Sex\",\n RACE = \"Race\",\n AGE = \"Age\"\n )\n\n\n\n\nThe summarize_coxreg function fits, tidies and arranges a Cox regression model in a table layout using the rtables framework. For a multivariable Cox regression model, argument multivar must be set to TRUE. Arguments variables and control can be specified to set up the model (see ?summarize_coxreg for more details and customization options). All variables specified within variables must be present in the data used when building the table.\nTo see the same model as a data.frame object, these two arguments (as well as the data) can be passed to the fit_coxreg_multivar function, and the resulting list tidied using broom::tidy().\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"SEX\", \"AGE\")\n)\n\nlyt <- basic_table() %>%\n summarize_coxreg(variables = variables, multivar = TRUE) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Hazard Ratio 95% CI p-value\n——————————————————————————————————————————————————————————————————————————————\nTreatment: \n Planned Arm (reference = B: Placebo) 0.2643 \n A: Drug X 0.96 (0.66, 1.42) 0.8536 \n C: Combination 1.27 (0.88, 1.83) 0.2010 \nCovariate: \n Sex (reference = F) \n M 1.09 (0.80, 1.48) 0.5987 \n Age \n All 0.99 (0.97, 1.01) 0.5104 \n\n\n\n\nThe estimation of interaction terms is not supported.\nInteraction terms are not included in the GDSR. For this reason and because we must take precautions when fitting such models, this functionality has not been translated in fit_coxreg_multivar. Please remove interaction terms or, if required by the study, refer to the survival::coxph function. Aside from this, using tern the developer must add the necessary variables to the analysis dataset during pre-processing based on ADVS or ADSUB. An example can be found in DMT01.\n\n\nThis option is not supported.\nSee the Multivariable Cox Regression with Interaction Term tab for more details.\n\n\nThis option is not supported.\nSee the Multivariable Cox Regression with Interaction Term tab for more details.\n\n\nAdditional controls can be customized using control_coxreg (see ?control_coxreg) such as the ties calculation method and the confidence level. Stratification variables can be added via the strata element of the variables list.\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARMCD\",\n covariates = c(\"SEX\", \"AGE\"),\n strata = \"RACE\"\n)\n\ncontrol <- control_coxreg(\n conf_level = 0.9,\n ties = \"efron\"\n)\n\nlyt <- basic_table() %>%\n summarize_coxreg(\n variables = variables,\n control = control,\n multivar = TRUE,\n .stats = c(\"hr\", \"ci\")\n ) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Hazard Ratio 90% CI \n————————————————————————————————————————————————————————————————————\nTreatment: \n Planned Arm Code (reference = ARM A) \n ARM B 1.03 (0.74, 1.42)\n ARM C 1.30 (0.96, 1.77)\nCovariate: \n Sex (reference = F) \n M 1.08 (0.83, 1.40)\n Age \n All 0.99 (0.98, 1.01)\n\n\n\n\nSee the Multivariable Cox Regression with Interaction Term tab.\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'adsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADTTE\", adtte, code = 'adtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_coxreg(\n label = \"Cox Reg.\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\", \"ACTARMCD\"), \"ARM\"),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adtte, \"PARAMCD\", \"PARAM\"), \"OS\"\n ),\n strata_var = choices_selected(\n c(\"SEX\", \"STRATA1\", \"STRATA2\"), NULL\n ),\n cov_var = choices_selected(\n c(\"AGE\", \"SEX\", \"RACE\"), c(\"AGE\", \"SEX\")\n ),\n multivariate = TRUE\n )\n )\n)\n\n[INFO] 2023-09-08 19:50:27.4314 pid:7192 token:[] teal.modules.clinical Initializing tm_t_coxreg\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] broom_1.0.5 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] abind_1.4-5 multcomp_1.4-25 withr_2.5.0 \n[25] purrr_1.0.2 shinyWidgets_0.7.6 geepack_1.3.9 \n[28] grid_4.3.1 fansi_1.0.4 teal.logger_0.1.3.9000 \n[31] xtable_1.8-4 colorspace_2.1-0 ggplot2_3.4.3 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] stringr_1.5.0 splines_4.3.1 assertthat_0.2.1 \n[46] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[49] sandwich_3.0-2 jsonlite_1.8.7 carData_3.0-5 \n[52] callr_3.7.3 car_3.1-2 teal.widgets_0.4.0.9007\n[55] testthat_3.1.10 fontawesome_0.5.1 jquerylib_0.1.4 \n[58] tidyr_1.3.0 glue_1.6.2 ps_1.7.5 \n[61] codetools_0.2-19 stringi_1.7.12 gtable_0.3.3 \n[64] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[67] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[70] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[73] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[76] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[79] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[82] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[85] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[88] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Analysis based on multivariable Cox models is usually not performed for the Clinical Study Report (CSR) or regulatory documents, serving exploratory purposes only (e.g. for publication). In practice, the model usually includes only the main effects (without interaction terms). It produces the estimates for each of the covariates included in the model. The analysis follows the same principles (i.e. stratified vs. unstratified analysis and tie handling) as the general Cox model analysis also used in COXT01. Since there is usually no pre-specified hypothesis testing for such analysis, the p-values must be interpreted with caution.\n\n\nData Setup\nMultivariable Cox Regression\nMultivariable Cox Regression with Interaction Term\nMultivariable Cox Regression Specifying Covariates\nMultivariable Cox Regression Specifying Covariates from ADSUB\nMultivariable Cox Regression Setting Strata, Ties, Alpha Level, Statistics\nMultivariable Cox Regression with Selection Process for Covariates\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\nlibrary(broom)\n\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadtte <- df_explicit_na(adtte)\n\nanl <- adtte %>%\n filter(\n PARAMCD == \"OS\",\n SEX %in% c(\"F\", \"M\"),\n RACE %in% c(\"ASIAN\", \"BLACK OR AFRICAN AMERICAN\", \"WHITE\")\n ) %>%\n mutate(\n ARM = droplevels(relevel(ARM, \"B: Placebo\")),\n SEX = droplevels(SEX),\n RACE = droplevels(RACE)\n ) %>%\n mutate(EVENT = 1 - CNSR) %>%\n var_relabel(\n ARM = \"Planned Arm\",\n SEX = \"Sex\",\n RACE = \"Race\",\n AGE = \"Age\"\n )\n\n\n\n\nThe summarize_coxreg function fits, tidies and arranges a Cox regression model in a table layout using the rtables framework. For a multivariable Cox regression model, argument multivar must be set to TRUE. Arguments variables and control can be specified to set up the model (see ?summarize_coxreg for more details and customization options). All variables specified within variables must be present in the data used when building the table.\nTo see the same model as a data.frame object, these two arguments (as well as the data) can be passed to the fit_coxreg_multivar function, and the resulting list tidied using broom::tidy().\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"SEX\", \"AGE\")\n)\n\nlyt <- basic_table() %>%\n summarize_coxreg(variables = variables, multivar = TRUE) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Hazard Ratio 95% CI p-value\n——————————————————————————————————————————————————————————————————————————————\nTreatment: \n Planned Arm (reference = B: Placebo) 0.2643 \n A: Drug X 0.96 (0.66, 1.42) 0.8536 \n C: Combination 1.27 (0.88, 1.83) 0.2010 \nCovariate: \n Sex (reference = F) \n M 1.09 (0.80, 1.48) 0.5987 \n Age \n All 0.99 (0.97, 1.01) 0.5104 \n\n\n\n\nThe estimation of interaction terms is not supported.\nInteraction terms are not included in the GDSR. For this reason and because we must take precautions when fitting such models, this functionality has not been translated in fit_coxreg_multivar. Please remove interaction terms or, if required by the study, refer to the survival::coxph function. Aside from this, using tern the developer must add the necessary variables to the analysis dataset during pre-processing based on ADVS or ADSUB. An example can be found in DMT01.\n\n\nThis option is not supported.\nSee the Multivariable Cox Regression with Interaction Term tab for more details.\n\n\nThis option is not supported.\nSee the Multivariable Cox Regression with Interaction Term tab for more details.\n\n\nAdditional controls can be customized using control_coxreg (see ?control_coxreg) such as the ties calculation method and the confidence level. Stratification variables can be added via the strata element of the variables list.\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARMCD\",\n covariates = c(\"SEX\", \"AGE\"),\n strata = \"RACE\"\n)\n\ncontrol <- control_coxreg(\n conf_level = 0.9,\n ties = \"efron\"\n)\n\nlyt <- basic_table() %>%\n summarize_coxreg(\n variables = variables,\n control = control,\n multivar = TRUE,\n .stats = c(\"hr\", \"ci\")\n ) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Hazard Ratio 90% CI \n————————————————————————————————————————————————————————————————————\nTreatment: \n Planned Arm Code (reference = ARM A) \n ARM B 1.03 (0.74, 1.42)\n ARM C 1.30 (0.96, 1.77)\nCovariate: \n Sex (reference = F) \n M 1.08 (0.83, 1.40)\n Age \n All 0.99 (0.98, 1.01)\n\n\n\n\nSee the Multivariable Cox Regression with Interaction Term tab.\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'adsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADTTE\", adtte, code = 'adtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_coxreg(\n label = \"Cox Reg.\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\", \"ACTARMCD\"), \"ARM\"),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adtte, \"PARAMCD\", \"PARAM\"), \"OS\"\n ),\n strata_var = choices_selected(\n c(\"SEX\", \"STRATA1\", \"STRATA2\"), NULL\n ),\n cov_var = choices_selected(\n c(\"AGE\", \"SEX\", \"RACE\"), c(\"AGE\", \"SEX\")\n ),\n multivariate = TRUE\n )\n )\n)\n\n[INFO] 2023-09-09 18:12:29.0843 pid:7196 token:[] teal.modules.clinical Initializing tm_t_coxreg\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] broom_1.0.5 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] abind_1.4-5 multcomp_1.4-25 withr_2.5.0 \n[25] purrr_1.0.2 shinyWidgets_0.7.6 geepack_1.3.9 \n[28] grid_4.3.1 fansi_1.0.4 teal.logger_0.1.3.9001 \n[31] xtable_1.8-4 colorspace_2.1-0 ggplot2_3.4.3 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] stringr_1.5.0 splines_4.3.1 assertthat_0.2.1 \n[46] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[49] sandwich_3.0-2 jsonlite_1.8.7 carData_3.0-5 \n[52] callr_3.7.3 car_3.1-2 teal.widgets_0.4.0.9007\n[55] testthat_3.1.10 fontawesome_0.5.1 jquerylib_0.1.4 \n[58] tidyr_1.3.0 glue_1.6.2 ps_1.7.5 \n[61] codetools_0.2-19 stringi_1.7.12 gtable_0.3.3 \n[64] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[67] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[70] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[73] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[76] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[79] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[82] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[85] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[88] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/pharmacokinetic/pkpt03.html",
@@ -298,70 +298,70 @@
"href": "tables/adverse-events/aet04.html",
"title": "AET04",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Fill-In of Treatment Groups\nTable with Fill-In of Grades\nTable with Collapsing of Grades\nTable Using Worst Grade Flags from ADAE\nTable with an Incidence Rate \\(\\geq\\) 40%, Totals Restricted\nTable with an Incidence Rate \\(\\geq\\) X%, Totals Unrestricted\nTable with an Incidence Rate \\(\\geq\\) 58 Patients\nTable with a Difference in Incidence Rate \\(\\geq\\) 10%\nTable with an Incidence Rate \\(\\geq\\) 5%, SOCs < 5% Removed\nTable with an Incidence Rate \\(\\geq\\) 40%, All SOCs w/o Preferred Terms Removed\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl) %>% filter(TRT01A != \"<Missing>\")\nadae <- df_explicit_na(adae) %>%\n var_relabel(\n AEBODSYS = \"MedDRA System Organ Class\",\n AEDECOD = \"MedDRA Preferred Term\"\n ) %>%\n filter(\n ANL01FL == \"Y\",\n AETOXGR != \"<Missing>\"\n )\n\n# Pre-Processing\ngrade_groups <- list(\n \"Grade 1-2\" = c(\"1\", \"2\"),\n \"Grade 3-4\" = c(\"3\", \"4\"),\n \"Grade 5\" = \"5\"\n)\nadae$TOTAL_VAR <- \"- Any adverse events - \"\n\n# Helper function to avoid filtering also the first part of the table, where general information is given.\nmy_row_condition <- function(row_fnc_condition) {\n function(table_row) {\n if (indent_mod(table_row) == 0) {\n return(TRUE)\n } else {\n row_fnc_condition(table_row)\n }\n }\n}\n\n# Helper function to calculate sum from first nested row\nscore_all_sum <- function(tt) {\n cleaf <- collect_leaves(tt)[[1]]\n if (NROW(cleaf) == 0) {\n stop(\"score_all_sum score function used at subtable [\", obj_name(tt), \"] that has no content.\")\n }\n sum(sapply(row_values(cleaf), function(cv) cv[1]))\n}\n\n# Raw table used by variant 8/10\nraw_table <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\") %>%\n build_table(adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodeadae2 <- adae %>% filter(ACTARM == \"A: Drug X\")\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae2, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 0 0 \n Grade 1-2 10 (7.5%) 0 0 \n 1 5 (3.7%) 0 0 \n 2 5 (3.7%) 0 0 \n Grade 3-4 26 (19.4%) 0 0 \n 3 13 (9.7%) 0 0 \n 4 13 (9.7%) 0 0 \n Grade 5 64 (47.8%) 0 0 \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 0 0 \n Grade 1-2 68 (50.7%) 0 0 \n 1 27 (20.1%) 0 0 \n 2 41 (30.6%) 0 0 \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 0 0 \n Grade 1-2 45 (33.6%) 0 0 \n 1 45 (33.6%) 0 0 \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 0 0 \n Grade 1-2 41 (30.6%) 0 0 \n 2 41 (30.6%) 0 0 \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 0 0 \n Grade 3-4 22 (16.4%) 0 0 \n 3 22 (16.4%) 0 0 \n Grade 5 42 (31.3%) 0 0 \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 0 0 \n Grade 5 42 (31.3%) 0 0 \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 0 0 \n Grade 3-4 38 (28.4%) 0 0 \n 3 38 (28.4%) 0 0 \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 0 0 \n Grade 1-2 23 (17.2%) 0 0 \n 1 23 (17.2%) 0 0 \n Grade 3-4 39 (29.1%) 0 0 \n 3 39 (29.1%) 0 0 \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 0 0 \n Grade 3-4 39 (29.1%) 0 0 \n 3 39 (29.1%) 0 0 \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 0 0 \n Grade 1-2 38 (28.4%) 0 0 \n 1 38 (28.4%) 0 0 \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 0 0 \n Grade 5 38 (28.4%) 0 0 \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 0 0 \n Grade 5 38 (28.4%) 0 0 \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 0 0 \n Grade 1-2 37 (27.6%) 0 0 \n 1 37 (27.6%) 0 0 \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 0 0 \n Grade 1-2 37 (27.6%) 0 0 \n 1 37 (27.6%) 0 0 \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 0 0 \n Grade 3-4 36 (26.9%) 0 0 \n 4 36 (26.9%) 0 0 \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 0 0 \n Grade 3-4 36 (26.9%) 0 0 \n 4 36 (26.9%) 0 0 \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 0 0 \n Grade 1-2 28 (20.9%) 0 0 \n 2 28 (20.9%) 0 0 \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 0 0 \n Grade 1-2 28 (20.9%) 0 0 \n 2 28 (20.9%) 0 0 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae, alt_counts_df = adsl) %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 1 0 0 0 \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 2 0 0 0 \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 4 0 0 0 \n Grade 5 0 0 0 \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 4 0 0 0 \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 4 0 0 0 \n Grade 5 0 0 0 \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 1 0 0 0 \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 1 0 0 0 \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 3 0 0 0 \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 5 0 0 0 \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 3 0 0 0 \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 5 0 0 0 \n\n\n\n\n\nCodegrade_groups_1 <- list(\n \"Grade 1-2\" = c(\"1\", \"2\"),\n \"Grade 3-5\" = c(\"3\", \"4\", \"5\")\n)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups_1,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups_1,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-5 90 (67.2%) 83 (61.9%) 93 (70.5%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-5 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-5 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-5 64 (47.8%) 54 (40.3%) 68 (51.5%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 3-5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-5 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 3-5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 3-5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-5 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-5 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCode# No Worst Grade Flags found in the ADAE data set.\n\n\n\n\n\nCode# Simple wrapper to return subset ADAE to a threshold of xx%.\nget_adae_trimmed <- function(adsl, adae, cutoff_rate) {\n n_per_arm <- adsl %>%\n dplyr::count(ACTARM)\n\n anl_terms <- adae %>%\n dplyr::group_by(ACTARM, AEBODSYS, AEDECOD) %>%\n dplyr::count(\n unique_terms = n_distinct(USUBJID)\n ) %>%\n dplyr::select(-n) %>%\n dplyr::ungroup()\n\n anl_terms <- dplyr::left_join(\n anl_terms,\n n_per_arm,\n by = \"ACTARM\"\n ) %>%\n dplyr::mutate(\n ae_rate = unique_terms / n\n ) %>%\n dplyr::filter(ae_rate >= cutoff_rate) %>%\n dplyr::select(AEDECOD) %>%\n unique()\n\n anl <- dplyr::left_join(\n anl_terms,\n adae,\n by = \"AEDECOD\"\n )\n anl\n}\n\nadae6 <- get_adae_trimmed(adsl, adae, cutoff_rate = 0.4)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae6, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCode# Variant 7 was not created.\n# With this variant, the SOC level is not trimmed (even if there are no terms left).\n\n\n\n\n\nCodecutoff <- 58L\nrow_condition <- has_count_in_any_col(atleast = cutoff, col_names = levels(adsl$ACTARM))\n\nresult <- prune_table(raw_table, keep_content_rows(my_row_condition(row_condition)))\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodecutoff <- 0.1\nrow_condition <- has_fractions_difference(atleast = cutoff, col_names = levels(adsl$ACTARM))\n\nresult <- prune_table(raw_table, keep_content_rows(my_row_condition(row_condition)))\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCode# Variant 10 was not done\n# With this variant, SOC levels above the threshold are still in the table even if\n# there are no terms left.\n\n\n\n\n\nCodecutoff <- 0.4\nrow_condition <- has_fraction_in_any_col(atleast = cutoff, col_names = levels(adsl$ACTARM))\n\nresult <- prune_table(raw_table, keep_content_rows(my_row_condition(row_condition)))\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAE\", adae),\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_by_grade(\n label = \"Adverse Events by Grade Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n grade = choices_selected(\n choices = variable_choices(adae, c(\"AETOXGR\", \"AESEV\")),\n selected = \"AETOXGR\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:47:53.6125 pid:6281 token:[] teal.modules.clinical Initializing tm_t_events_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Fill-In of Treatment Groups\nTable with Fill-In of Grades\nTable with Collapsing of Grades\nTable Using Worst Grade Flags from ADAE\nTable with an Incidence Rate \\(\\geq\\) 40%, Totals Restricted\nTable with an Incidence Rate \\(\\geq\\) X%, Totals Unrestricted\nTable with an Incidence Rate \\(\\geq\\) 58 Patients\nTable with a Difference in Incidence Rate \\(\\geq\\) 10%\nTable with an Incidence Rate \\(\\geq\\) 5%, SOCs < 5% Removed\nTable with an Incidence Rate \\(\\geq\\) 40%, All SOCs w/o Preferred Terms Removed\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl) %>% filter(TRT01A != \"<Missing>\")\nadae <- df_explicit_na(adae) %>%\n var_relabel(\n AEBODSYS = \"MedDRA System Organ Class\",\n AEDECOD = \"MedDRA Preferred Term\"\n ) %>%\n filter(\n ANL01FL == \"Y\",\n AETOXGR != \"<Missing>\"\n )\n\n# Pre-Processing\ngrade_groups <- list(\n \"Grade 1-2\" = c(\"1\", \"2\"),\n \"Grade 3-4\" = c(\"3\", \"4\"),\n \"Grade 5\" = \"5\"\n)\nadae$TOTAL_VAR <- \"- Any adverse events - \"\n\n# Helper function to avoid filtering also the first part of the table, where general information is given.\nmy_row_condition <- function(row_fnc_condition) {\n function(table_row) {\n if (indent_mod(table_row) == 0) {\n return(TRUE)\n } else {\n row_fnc_condition(table_row)\n }\n }\n}\n\n# Helper function to calculate sum from first nested row\nscore_all_sum <- function(tt) {\n cleaf <- collect_leaves(tt)[[1]]\n if (NROW(cleaf) == 0) {\n stop(\"score_all_sum score function used at subtable [\", obj_name(tt), \"] that has no content.\")\n }\n sum(sapply(row_values(cleaf), function(cv) cv[1]))\n}\n\n# Raw table used by variant 8/10\nraw_table <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\") %>%\n build_table(adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodeadae2 <- adae %>% filter(ACTARM == \"A: Drug X\")\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae2, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 0 0 \n Grade 1-2 10 (7.5%) 0 0 \n 1 5 (3.7%) 0 0 \n 2 5 (3.7%) 0 0 \n Grade 3-4 26 (19.4%) 0 0 \n 3 13 (9.7%) 0 0 \n 4 13 (9.7%) 0 0 \n Grade 5 64 (47.8%) 0 0 \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 0 0 \n Grade 1-2 68 (50.7%) 0 0 \n 1 27 (20.1%) 0 0 \n 2 41 (30.6%) 0 0 \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 0 0 \n Grade 1-2 45 (33.6%) 0 0 \n 1 45 (33.6%) 0 0 \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 0 0 \n Grade 1-2 41 (30.6%) 0 0 \n 2 41 (30.6%) 0 0 \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 0 0 \n Grade 3-4 22 (16.4%) 0 0 \n 3 22 (16.4%) 0 0 \n Grade 5 42 (31.3%) 0 0 \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 0 0 \n Grade 5 42 (31.3%) 0 0 \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 0 0 \n Grade 3-4 38 (28.4%) 0 0 \n 3 38 (28.4%) 0 0 \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 0 0 \n Grade 1-2 23 (17.2%) 0 0 \n 1 23 (17.2%) 0 0 \n Grade 3-4 39 (29.1%) 0 0 \n 3 39 (29.1%) 0 0 \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 0 0 \n Grade 3-4 39 (29.1%) 0 0 \n 3 39 (29.1%) 0 0 \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 0 0 \n Grade 1-2 38 (28.4%) 0 0 \n 1 38 (28.4%) 0 0 \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 0 0 \n Grade 5 38 (28.4%) 0 0 \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 0 0 \n Grade 5 38 (28.4%) 0 0 \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 0 0 \n Grade 1-2 37 (27.6%) 0 0 \n 1 37 (27.6%) 0 0 \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 0 0 \n Grade 1-2 37 (27.6%) 0 0 \n 1 37 (27.6%) 0 0 \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 0 0 \n Grade 3-4 36 (26.9%) 0 0 \n 4 36 (26.9%) 0 0 \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 0 0 \n Grade 3-4 36 (26.9%) 0 0 \n 4 36 (26.9%) 0 0 \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 0 0 \n Grade 1-2 28 (20.9%) 0 0 \n 2 28 (20.9%) 0 0 \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 0 0 \n Grade 1-2 28 (20.9%) 0 0 \n 2 28 (20.9%) 0 0 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae, alt_counts_df = adsl) %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 1 0 0 0 \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 2 0 0 0 \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 4 0 0 0 \n Grade 5 0 0 0 \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 4 0 0 0 \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 4 0 0 0 \n Grade 5 0 0 0 \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 1 0 0 0 \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 1 0 0 0 \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 0 0 0 \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 3 0 0 0 \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 5 0 0 0 \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 1-2 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 3 0 0 0 \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 5 0 0 0 \n\n\n\n\n\nCodegrade_groups_1 <- list(\n \"Grade 1-2\" = c(\"1\", \"2\"),\n \"Grade 3-5\" = c(\"3\", \"4\", \"5\")\n)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups_1,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups_1,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-5 90 (67.2%) 83 (61.9%) 93 (70.5%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-5 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-5 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-5 64 (47.8%) 54 (40.3%) 68 (51.5%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 3-5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-5 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 3-5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 3-5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-5 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-5 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCode# No Worst Grade Flags found in the ADAE data set.\n\n\n\n\n\nCode# Simple wrapper to return subset ADAE to a threshold of xx%.\nget_adae_trimmed <- function(adsl, adae, cutoff_rate) {\n n_per_arm <- adsl %>%\n dplyr::count(ACTARM)\n\n anl_terms <- adae %>%\n dplyr::group_by(ACTARM, AEBODSYS, AEDECOD) %>%\n dplyr::count(\n unique_terms = n_distinct(USUBJID)\n ) %>%\n dplyr::select(-n) %>%\n dplyr::ungroup()\n\n anl_terms <- dplyr::left_join(\n anl_terms,\n n_per_arm,\n by = \"ACTARM\"\n ) %>%\n dplyr::mutate(\n ae_rate = unique_terms / n\n ) %>%\n dplyr::filter(ae_rate >= cutoff_rate) %>%\n dplyr::select(AEDECOD) %>%\n unique()\n\n anl <- dplyr::left_join(\n anl_terms,\n adae,\n by = \"AEDECOD\"\n )\n anl\n}\n\nadae6 <- get_adae_trimmed(adsl, adae, cutoff_rate = 0.4)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n var = \"TOTAL_VAR\",\n label_pos = \"hidden\",\n child_labels = \"visible\",\n indent_mod = -1L\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 7L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 6L\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = drop_split_levels,\n split_label = var_labels(adae)[[\"AEBODSYS\"]],\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n split_fun = add_overall_level(\"- Overall -\", trim = TRUE),\n split_label = var_labels(adae)[[\"AEDECOD\"]],\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"- Any Grade -\",\n .indent_mods = 6L\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n grade_groups = grade_groups,\n .indent_mods = 5L\n ) %>%\n append_topleft(\" Grade\")\n\nresult <- lyt %>%\n build_table(adae6, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = score_all_sum,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_all_sum,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCode# Variant 7 was not created.\n# With this variant, the SOC level is not trimmed (even if there are no terms left).\n\n\n\n\n\nCodecutoff <- 58L\nrow_condition <- has_count_in_any_col(atleast = cutoff, col_names = levels(adsl$ACTARM))\n\nresult <- prune_table(raw_table, keep_content_rows(my_row_condition(row_condition)))\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodecutoff <- 0.1\nrow_condition <- has_fractions_difference(atleast = cutoff, col_names = levels(adsl$ACTARM))\n\nresult <- prune_table(raw_table, keep_content_rows(my_row_condition(row_condition)))\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCode# Variant 10 was not done\n# With this variant, SOC levels above the threshold are still in the table even if\n# there are no terms left.\n\n\n\n\n\nCodecutoff <- 0.4\nrow_condition <- has_fraction_in_any_col(atleast = cutoff, col_names = levels(adsl$ACTARM))\n\nresult <- prune_table(raw_table, keep_content_rows(my_row_condition(row_condition)))\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Grade (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\n- Any adverse events - \n - Any Grade - 100 (74.6%) 98 (73.1%) 103 (78.0%) \n Grade 1-2 10 (7.5%) 15 (11.2%) 10 (7.6%) \n 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3-4 26 (19.4%) 31 (23.1%) 29 (22.0%) \n 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 64 (47.8%) 52 (38.8%) 64 (48.5%) \ncl A.1 \n - Overall - \n - Any Grade - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Grade 1-2 68 (50.7%) 58 (43.3%) 76 (57.6%) \n 1 27 (20.1%) 19 (14.2%) 34 (25.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n dcd A.1.1.1.1 \n - Any Grade - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n Grade 1-2 45 (33.6%) 31 (23.1%) 52 (39.4%) \n 1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 \n - Any Grade - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n Grade 1-2 41 (30.6%) 39 (29.1%) 42 (31.8%) \n 2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n - Overall - \n - Any Grade - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Grade 1-2 23 (17.2%) 22 (16.4%) 28 (21.2%) \n 1 23 (17.2%) 22 (16.4%) 28 (21.2%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \n dcd B.2.2.3.1 \n - Any Grade - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Grade 1-2 38 (28.4%) 40 (29.9%) 45 (34.1%) \n 1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Grade - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Grade 3-4 39 (29.1%) 34 (25.4%) 46 (34.8%) \n 3 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n - Overall - \n - Any Grade - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Grade 3-4 22 (16.4%) 22 (16.4%) 22 (16.7%) \n 3 22 (16.4%) 22 (16.4%) 22 (16.7%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.1.1 \n - Any Grade - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Grade 5 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 \n - Any Grade - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Grade 3-4 38 (28.4%) 34 (25.4%) 40 (30.3%) \n 3 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n - Overall - \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \n dcd D.2.1.5.3 \n - Any Grade - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Grade 1-2 37 (27.6%) 46 (34.3%) 50 (37.9%) \n 1 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n - Overall - \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n dcd C.2.1.2.1 \n - Any Grade - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Grade 1-2 28 (20.9%) 36 (26.9%) 48 (36.4%) \n 2 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n - Overall - \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \n dcd B.1.1.1.1 \n - Any Grade - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Grade 5 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n - Overall - \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Grade - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 3-4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAE\", adae),\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_by_grade(\n label = \"Adverse Events by Grade Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n grade = choices_selected(\n choices = variable_choices(adae, c(\"AETOXGR\", \"AESEV\")),\n selected = \"AETOXGR\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:08:46.7626 pid:6285 token:[] teal.modules.clinical Initializing tm_t_events_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet04_pi.html",
"href": "tables/adverse-events/aet04_pi.html",
"title": "AET04_PI",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Patients Treated with a Particular Treatment by Highest NCI CTCAE Grade (specifying a treatment for selecting preferred terms)\nAdverse Events Reported in \\(\\geq\\) 5% of Patients by Highest NCI CTCAE Grade (changing the threshold)\nAdverse Events Reported in \\(\\geq\\) 5% of Patients and \\(\\geq\\) 2% Difference Between Treatments by Highest NCI CTCAE Grade (using more than one condition)\nAdverse Events Reported in \\(\\geq\\) 10% of Patients for Any Grade or \\(\\geq\\) 5% of Patients for Grade 3-4 by Highest NCI CTCAE Grade (using different condition depending on the grade)\nStandard Table with Modified Grade Grouping\nStandard Table with Overlapping Grade Groupings\nStandard Table without SOCs\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\npreprocess_adae <- function(adae) {\n adae %>%\n dplyr::group_by(ACTARM, USUBJID, AEBODSYS, AEDECOD) %>%\n dplyr::summarize(\n MAXAETOXGR = max(as.numeric(AETOXGR)),\n .groups = \"drop\"\n ) %>%\n dplyr::ungroup() %>%\n dplyr::mutate(\n MAXAETOXGR = factor(MAXAETOXGR),\n AEDECOD = droplevels(as.factor(AEDECOD))\n )\n}\n\nfull_table_aet04_pi <- function(adsl, adae_max) {\n grade_groups <- list(\n \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n \"Grade 3-4 (%)\" = c(\"3\", \"4\"),\n \"Grade 5 (%)\" = \"5\"\n )\n\n col_counts <- rep(table(adsl$ACTARM), each = length(grade_groups))\n basic_table() %>%\n split_cols_by(\"ACTARM\") %>%\n split_cols_by_groups(\"MAXAETOXGR\", groups = grade_groups) %>%\n split_rows_by(\"AEBODSYS\",\n child_labels = \"visible\", nested = FALSE, indent_mod = -1L,\n split_fun = trim_levels_in_group(\"AEDECOD\")\n ) %>%\n append_topleft(\"MedDRA System Organ Class\") %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n analyze_vars(\n \"AEDECOD\",\n na.rm = FALSE,\n denom = \"N_col\",\n .stats = \"count_fraction\",\n .formats = c(count_fraction = format_fraction_threshold(0.01))\n ) %>%\n append_topleft(\" MedDRA Preferred Term\") %>%\n build_table(adae_max, col_counts = col_counts)\n}\n\ncriteria_fun <- function(tr) {\n is(tr, \"ContentRow\")\n}\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae_max <- synthetic_cdisc_dataset(\"latest\", \"adae\") %>%\n preprocess_adae() %>%\n df_explicit_na()\n\n\n\n\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_10percent_any <- has_fraction_in_any_col(atleast = 0.1, col_indices = c(1, 4, 7))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_10percent_any))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ndcd A.1.1.1.2 36 0 0 36 0 0 38 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 \ndcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 \ncl D.1 \ndcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 \ndcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 \ncl D.2 \ndcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 \ncl B.1 \ndcd B.1.1.1.1 35 0 35 37 0 37 33 0 33 \ncl C.2 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \ncl C.1 \ndcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses the “Any Grade” column for treatment A: Drug X with a filtering threshold at 0.37; AEs reported in greater than 37% of patients in treatment A: Drug X are shown. This can be changed by varying the parameter values in the has_fraction_in_cols function.\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_37percent_any_drugx <- has_fraction_in_cols(atleast = 0.37, col_indices = 1)\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_37percent_any_drugx))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ncl D.1 \ndcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses column indices 1, 4, and 7 with a filtering threshold at 0.40 to demonstrate the filtering ability; AEs reported in greater than 40% of patients are shown. This can be changed by varying the parameter values in the has_fraction_in_any_col function.\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_40percent_any <- has_fraction_in_any_col(atleast = 0.40, col_indices = c(1, 4, 7))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_40percent_any))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 \ncl D.2 \ndcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 \ncl C.2 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses column indices 1, 4, and 7 to filter for AEs reported in \\(\\geq\\) 30% of patients and AEs reported with a \\(\\geq\\) 15% difference between treatments to demonstrate the filtering ability; this can be changed by varying the parameter values in the has_fraction_in_any_col and has_fractions_difference functions.\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_30percent_any <- has_fraction_in_any_col(atleast = 0.3, col_indices = c(1, 4, 7))\n\nat_least_15percent_diff <- has_fractions_difference(atleast = 0.15, col_indices = c(1, 4, 7))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_30percent_any & at_least_15percent_diff))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl C.2 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example filters using column indices 1, 4, and 7 to include AEs reported in \\(\\geq\\) 40% of patients and using column indices 2, 5, and 8 to include grade 3-4 AEs reported in \\(\\geq\\) 20% of patients. These thresholds are chosen to demonstrate the filtering ability; they can be changed by varying parameter values in the has_fraction_in_any_col function.\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 4, 7))\n\nat_least_20percent_g34 <- has_fraction_in_any_col(atleast = 0.20, col_indices = c(2, 5, 8))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_40percent_any | at_least_20percent_g34))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 \ndcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 \ncl D.1 \ndcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 \ncl D.2 \ndcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 \ncl C.2 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \ncl C.1 \ndcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 \n\n\n\n\nNote: User can specify/modify the grouping of grades, as shown in this example. In addition, the user needs to specify the column index for filtering the table. The current example uses the “Any Grade” columns with a filtering threshold at 0.40; this can be changed by varying the parameter values in the has_fraction_in_any_col function.\n\nCodegrade_groups <- list(\n \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n \"Grade 1-2 (%)\" = c(\"1\", \"2\"),\n \"Grade 3-4 (%)\" = c(\"3\", \"4\"),\n \"Grade 5 (%)\" = \"5\"\n)\n\ncol_counts <- rep(table(adsl$ACTARM), each = length(grade_groups))\n\nfull_table <- basic_table() %>%\n split_cols_by(\"ACTARM\") %>%\n split_cols_by_groups(\"MAXAETOXGR\", groups = grade_groups) %>%\n split_rows_by(\"AEBODSYS\",\n child_labels = \"visible\", nested = FALSE, indent_mod = -1L,\n split_fun = trim_levels_in_group(\"AEDECOD\")\n ) %>%\n append_topleft(\"MedDRA System Organ Class\") %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n analyze_vars(\n \"AEDECOD\",\n na.rm = FALSE,\n denom = \"N_col\",\n .stats = \"count_fraction\",\n .formats = c(count_fraction = format_fraction_threshold(0.01))\n ) %>%\n append_topleft(\" MedDRA Preferred Term\") %>%\n build_table(adae_max, col_counts = col_counts) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 5, 9)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 5, 9)),\n decreasing = TRUE\n )\n\nat_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 5, 9))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_40percent_any))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 37 0 0 34 34 0 0 48 48 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 36 0 0 40 40 0 0 39 39 0 0 \ncl D.2 \ndcd D.2.1.5.3 35 35 0 0 43 43 0 0 43 43 0 0 \ncl C.2 \ndcd C.2.1.2.1 26 26 0 0 36 36 0 0 42 42 0 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses column indices 1, 5, and 9 with a filtering threshold at 0.40 to demonstrate the filtering ability; any grade AEs reported in greater than 40% of patients are shown. This can be changed by varying the parameter values in the has_fraction_in_any_col function.\n\nCodegrade_groups <- list(\n \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n \"Grade 3-4 (%)\" = c(\"3\", \"4\"),\n \"Grade 3-5 (%)\" = c(\"3\", \"4\", \"5\"),\n \"Grade 5 (%)\" = \"5\"\n)\n\ncol_counts <- rep(table(adsl$ACTARM), each = length(grade_groups))\nfull_table <- basic_table() %>%\n split_cols_by(\"ACTARM\") %>%\n split_cols_by_groups(\"MAXAETOXGR\", groups = grade_groups) %>%\n split_rows_by(\"AEBODSYS\",\n child_labels = \"visible\", nested = FALSE, indent_mod = -1L,\n split_fun = trim_levels_in_group(\"AEDECOD\")\n ) %>%\n append_topleft(\"MedDRA System Organ Class\") %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n analyze_vars(\n \"AEDECOD\",\n na.rm = FALSE,\n denom = \"N_col\",\n .stats = \"count_fraction\",\n .formats = c(count_fraction = format_fraction_threshold(0.01))\n ) %>%\n append_topleft(\" MedDRA Preferred Term\") %>%\n build_table(adae_max, col_counts = col_counts) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 5, 9)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 5, 9)),\n decreasing = TRUE\n )\n\nat_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 5, 9))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_40percent_any))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 0 34 0 0 0 48 0 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 0 0 0 40 0 0 0 39 0 0 0 \ncl D.2 \ndcd D.2.1.5.3 35 0 0 0 43 0 0 0 43 0 0 0 \ncl C.2 \ndcd C.2.1.2.1 26 0 0 0 36 0 0 0 42 0 0 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses column indices 1, 4, and 7 with a filtering threshold at 0.20 to demonstrate the filtering ability; any grade AEs (Preferred Terms Only) reported in greater than 20% of patients are shown. This can be changed by varying the parameter values in the has_fraction_in_any_col function.\n\nCodegrade_groups <- list(\n \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n \"Grade 3-4 (%)\" = c(\"3\", \"4\"),\n \"Grade 5 (%)\" = \"5\"\n)\n\ncol_counts <- rep(table(adsl$ACTARM), each = length(grade_groups))\n\nfull_table <- basic_table() %>%\n split_cols_by(\"ACTARM\") %>%\n split_cols_by_groups(\"MAXAETOXGR\", groups = grade_groups) %>%\n analyze_vars(\n \"AEDECOD\",\n na.rm = FALSE,\n denom = \"N_col\",\n .stats = \"count_fraction\",\n .formats = c(count_fraction = format_fraction_threshold(0.01))\n ) %>%\n append_topleft(\"MedDRA Preferred Term\") %>%\n build_table(adae_max, col_counts = col_counts)\n\nat_least_20percent_any <- has_fraction_in_any_col(atleast = 0.2, col_indices = c(1, 4, 7))\n\nresult <- full_table %>%\n prune_table(keep_rows(at_least_20percent_any)) %>%\n sort_at_path(\n path = c(\"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nresult\n\nMedDRA Preferred Term A: Drug X B: Placebo C: Combination \n Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ndcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ndcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 \ndcd A.1.1.1.2 36 0 0 36 0 0 38 0 0 \ndcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 \ndcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 \ndcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 \ndcd B.1.1.1.1 35 0 35 37 0 37 33 0 33 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \ndcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAE\", adae),\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_by_grade(\n label = \"Adverse Events by Grade Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n col_by_grade = TRUE,\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n grade = choices_selected(\n choices = variable_choices(adae, c(\"AETOXGR\", \"AESEV\")),\n selected = \"AETOXGR\"\n ),\n # List of column groups for grades used when `col_by_grade` = TRUE.\n grading_groups = list(\n `Any Grade (%)` = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n `Grade 3-4 (%)` = c(\"3\", \"4\"),\n `Grade 5 (%)` = \"5\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:46:39.2779 pid:6085 token:[] teal.modules.clinical Initializing tm_t_events_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Patients Treated with a Particular Treatment by Highest NCI CTCAE Grade (specifying a treatment for selecting preferred terms)\nAdverse Events Reported in \\(\\geq\\) 5% of Patients by Highest NCI CTCAE Grade (changing the threshold)\nAdverse Events Reported in \\(\\geq\\) 5% of Patients and \\(\\geq\\) 2% Difference Between Treatments by Highest NCI CTCAE Grade (using more than one condition)\nAdverse Events Reported in \\(\\geq\\) 10% of Patients for Any Grade or \\(\\geq\\) 5% of Patients for Grade 3-4 by Highest NCI CTCAE Grade (using different condition depending on the grade)\nStandard Table with Modified Grade Grouping\nStandard Table with Overlapping Grade Groupings\nStandard Table without SOCs\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\npreprocess_adae <- function(adae) {\n adae %>%\n dplyr::group_by(ACTARM, USUBJID, AEBODSYS, AEDECOD) %>%\n dplyr::summarize(\n MAXAETOXGR = max(as.numeric(AETOXGR)),\n .groups = \"drop\"\n ) %>%\n dplyr::ungroup() %>%\n dplyr::mutate(\n MAXAETOXGR = factor(MAXAETOXGR),\n AEDECOD = droplevels(as.factor(AEDECOD))\n )\n}\n\nfull_table_aet04_pi <- function(adsl, adae_max) {\n grade_groups <- list(\n \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n \"Grade 3-4 (%)\" = c(\"3\", \"4\"),\n \"Grade 5 (%)\" = \"5\"\n )\n\n col_counts <- rep(table(adsl$ACTARM), each = length(grade_groups))\n basic_table() %>%\n split_cols_by(\"ACTARM\") %>%\n split_cols_by_groups(\"MAXAETOXGR\", groups = grade_groups) %>%\n split_rows_by(\"AEBODSYS\",\n child_labels = \"visible\", nested = FALSE, indent_mod = -1L,\n split_fun = trim_levels_in_group(\"AEDECOD\")\n ) %>%\n append_topleft(\"MedDRA System Organ Class\") %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n analyze_vars(\n \"AEDECOD\",\n na.rm = FALSE,\n denom = \"N_col\",\n .stats = \"count_fraction\",\n .formats = c(count_fraction = format_fraction_threshold(0.01))\n ) %>%\n append_topleft(\" MedDRA Preferred Term\") %>%\n build_table(adae_max, col_counts = col_counts)\n}\n\ncriteria_fun <- function(tr) {\n is(tr, \"ContentRow\")\n}\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae_max <- synthetic_cdisc_dataset(\"latest\", \"adae\") %>%\n preprocess_adae() %>%\n df_explicit_na()\n\n\n\n\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_10percent_any <- has_fraction_in_any_col(atleast = 0.1, col_indices = c(1, 4, 7))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_10percent_any))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ndcd A.1.1.1.2 36 0 0 36 0 0 38 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 \ndcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 \ncl D.1 \ndcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 \ndcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 \ncl D.2 \ndcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 \ncl B.1 \ndcd B.1.1.1.1 35 0 35 37 0 37 33 0 33 \ncl C.2 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \ncl C.1 \ndcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses the “Any Grade” column for treatment A: Drug X with a filtering threshold at 0.37; AEs reported in greater than 37% of patients in treatment A: Drug X are shown. This can be changed by varying the parameter values in the has_fraction_in_cols function.\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_37percent_any_drugx <- has_fraction_in_cols(atleast = 0.37, col_indices = 1)\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_37percent_any_drugx))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ncl D.1 \ndcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses column indices 1, 4, and 7 with a filtering threshold at 0.40 to demonstrate the filtering ability; AEs reported in greater than 40% of patients are shown. This can be changed by varying the parameter values in the has_fraction_in_any_col function.\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_40percent_any <- has_fraction_in_any_col(atleast = 0.40, col_indices = c(1, 4, 7))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_40percent_any))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 \ncl D.2 \ndcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 \ncl C.2 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses column indices 1, 4, and 7 to filter for AEs reported in \\(\\geq\\) 30% of patients and AEs reported with a \\(\\geq\\) 15% difference between treatments to demonstrate the filtering ability; this can be changed by varying the parameter values in the has_fraction_in_any_col and has_fractions_difference functions.\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_30percent_any <- has_fraction_in_any_col(atleast = 0.3, col_indices = c(1, 4, 7))\n\nat_least_15percent_diff <- has_fractions_difference(atleast = 0.15, col_indices = c(1, 4, 7))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_30percent_any & at_least_15percent_diff))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl C.2 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example filters using column indices 1, 4, and 7 to include AEs reported in \\(\\geq\\) 40% of patients and using column indices 2, 5, and 8 to include grade 3-4 AEs reported in \\(\\geq\\) 20% of patients. These thresholds are chosen to demonstrate the filtering ability; they can be changed by varying parameter values in the has_fraction_in_any_col function.\n\nCodefull_table <- full_table_aet04_pi(adsl, adae_max) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nat_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 4, 7))\n\nat_least_20percent_g34 <- has_fraction_in_any_col(atleast = 0.20, col_indices = c(2, 5, 8))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_40percent_any | at_least_20percent_g34))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 \ndcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 \ncl D.1 \ndcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 \ncl D.2 \ndcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 \ncl C.2 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \ncl C.1 \ndcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 \n\n\n\n\nNote: User can specify/modify the grouping of grades, as shown in this example. In addition, the user needs to specify the column index for filtering the table. The current example uses the “Any Grade” columns with a filtering threshold at 0.40; this can be changed by varying the parameter values in the has_fraction_in_any_col function.\n\nCodegrade_groups <- list(\n \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n \"Grade 1-2 (%)\" = c(\"1\", \"2\"),\n \"Grade 3-4 (%)\" = c(\"3\", \"4\"),\n \"Grade 5 (%)\" = \"5\"\n)\n\ncol_counts <- rep(table(adsl$ACTARM), each = length(grade_groups))\n\nfull_table <- basic_table() %>%\n split_cols_by(\"ACTARM\") %>%\n split_cols_by_groups(\"MAXAETOXGR\", groups = grade_groups) %>%\n split_rows_by(\"AEBODSYS\",\n child_labels = \"visible\", nested = FALSE, indent_mod = -1L,\n split_fun = trim_levels_in_group(\"AEDECOD\")\n ) %>%\n append_topleft(\"MedDRA System Organ Class\") %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n analyze_vars(\n \"AEDECOD\",\n na.rm = FALSE,\n denom = \"N_col\",\n .stats = \"count_fraction\",\n .formats = c(count_fraction = format_fraction_threshold(0.01))\n ) %>%\n append_topleft(\" MedDRA Preferred Term\") %>%\n build_table(adae_max, col_counts = col_counts) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 5, 9)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 5, 9)),\n decreasing = TRUE\n )\n\nat_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 5, 9))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_40percent_any))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 37 0 0 34 34 0 0 48 48 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 36 0 0 40 40 0 0 39 39 0 0 \ncl D.2 \ndcd D.2.1.5.3 35 35 0 0 43 43 0 0 43 43 0 0 \ncl C.2 \ndcd C.2.1.2.1 26 26 0 0 36 36 0 0 42 42 0 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses column indices 1, 5, and 9 with a filtering threshold at 0.40 to demonstrate the filtering ability; any grade AEs reported in greater than 40% of patients are shown. This can be changed by varying the parameter values in the has_fraction_in_any_col function.\n\nCodegrade_groups <- list(\n \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n \"Grade 3-4 (%)\" = c(\"3\", \"4\"),\n \"Grade 3-5 (%)\" = c(\"3\", \"4\", \"5\"),\n \"Grade 5 (%)\" = \"5\"\n)\n\ncol_counts <- rep(table(adsl$ACTARM), each = length(grade_groups))\nfull_table <- basic_table() %>%\n split_cols_by(\"ACTARM\") %>%\n split_cols_by_groups(\"MAXAETOXGR\", groups = grade_groups) %>%\n split_rows_by(\"AEBODSYS\",\n child_labels = \"visible\", nested = FALSE, indent_mod = -1L,\n split_fun = trim_levels_in_group(\"AEDECOD\")\n ) %>%\n append_topleft(\"MedDRA System Organ Class\") %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n analyze_vars(\n \"AEDECOD\",\n na.rm = FALSE,\n denom = \"N_col\",\n .stats = \"count_fraction\",\n .formats = c(count_fraction = format_fraction_threshold(0.01))\n ) %>%\n append_topleft(\" MedDRA Preferred Term\") %>%\n build_table(adae_max, col_counts = col_counts) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = score_occurrences_cont_cols(col_indices = c(1, 5, 9)),\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 5, 9)),\n decreasing = TRUE\n )\n\nat_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 5, 9))\n\nresult <- full_table %>%\n trim_rows(criteria = criteria_fun) %>%\n prune_table(keep_rows(at_least_40percent_any))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination \n MedDRA Preferred Term Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ncl A.1 \ndcd A.1.1.1.1 37 0 0 0 34 0 0 0 48 0 0 0 \ncl B.2 \ndcd B.2.2.3.1 36 0 0 0 40 0 0 0 39 0 0 0 \ncl D.2 \ndcd D.2.1.5.3 35 0 0 0 43 0 0 0 43 0 0 0 \ncl C.2 \ndcd C.2.1.2.1 26 0 0 0 36 0 0 0 42 0 0 0 \n\n\n\n\nNote: User needs to specify the column index for filtering the table. The current example uses column indices 1, 4, and 7 with a filtering threshold at 0.20 to demonstrate the filtering ability; any grade AEs (Preferred Terms Only) reported in greater than 20% of patients are shown. This can be changed by varying the parameter values in the has_fraction_in_any_col function.\n\nCodegrade_groups <- list(\n \"Any Grade (%)\" = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n \"Grade 3-4 (%)\" = c(\"3\", \"4\"),\n \"Grade 5 (%)\" = \"5\"\n)\n\ncol_counts <- rep(table(adsl$ACTARM), each = length(grade_groups))\n\nfull_table <- basic_table() %>%\n split_cols_by(\"ACTARM\") %>%\n split_cols_by_groups(\"MAXAETOXGR\", groups = grade_groups) %>%\n analyze_vars(\n \"AEDECOD\",\n na.rm = FALSE,\n denom = \"N_col\",\n .stats = \"count_fraction\",\n .formats = c(count_fraction = format_fraction_threshold(0.01))\n ) %>%\n append_topleft(\"MedDRA Preferred Term\") %>%\n build_table(adae_max, col_counts = col_counts)\n\nat_least_20percent_any <- has_fraction_in_any_col(atleast = 0.2, col_indices = c(1, 4, 7))\n\nresult <- full_table %>%\n prune_table(keep_rows(at_least_20percent_any)) %>%\n sort_at_path(\n path = c(\"AEDECOD\"),\n scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)),\n decreasing = TRUE\n )\n\nresult\n\nMedDRA Preferred Term A: Drug X B: Placebo C: Combination \n Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%)\n (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\ndcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 \ndcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 \ndcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 \ndcd A.1.1.1.2 36 0 0 36 0 0 38 0 0 \ndcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 \ndcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 \ndcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 \ndcd B.1.1.1.1 35 0 35 37 0 37 33 0 33 \ndcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 \ndcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAE\", adae),\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_by_grade(\n label = \"Adverse Events by Grade Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n col_by_grade = TRUE,\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n grade = choices_selected(\n choices = variable_choices(adae, c(\"AETOXGR\", \"AESEV\")),\n selected = \"AETOXGR\"\n ),\n # List of column groups for grades used when `col_by_grade` = TRUE.\n grading_groups = list(\n `Any Grade (%)` = c(\"1\", \"2\", \"3\", \"4\", \"5\"),\n `Grade 3-4 (%)` = c(\"3\", \"4\"),\n `Grade 5 (%)` = \"5\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:07:10.5734 pid:6089 token:[] teal.modules.clinical Initializing tm_t_events_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet10.html",
"href": "tables/adverse-events/aet10.html",
"title": "AET10",
"section": "",
- "text": "Data Setup\nStandard Table\nMost Common (\\(\\geq\\) 35%) Adverse Events (setting threshold)\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\n\n\n\nThe “All Patients” column is not required in this table but for illustrative purposes we include it to show correct sorting.\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n var = \"ARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(vars = \"AEDECOD\")\n\ntbl1 <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n)\n\ntbl2 <- prune_table(\n tt = tbl1,\n prune_func = keep_rows(\n has_fraction_in_any_col(\n atleast = 0.05, # specify threshold\n col_names = levels(adsl$ARM)\n )\n )\n)\n\nresult <- sort_at_path(\n tbl2,\n path = c(\"AEDECOD\"),\n scorefun = score_occurrences\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————\ndcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \ndcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) \ndcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) \ndcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) \ndcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) \ndcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \ndcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) \ndcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \ndcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \ndcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n var = \"ARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(vars = \"AEDECOD\")\n\ntbl1 <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n)\n\ntbl2 <- prune_table(\n tt = tbl1,\n prune_func = keep_rows(\n has_fraction_in_any_col(\n atleast = 0.35, # specify threshold\n col_names = levels(adsl$ARM)\n )\n )\n)\n\nresult <- sort_at_path(\n tbl2,\n path = c(\"AEDECOD\"),\n scorefun = score_occurrences\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————\ndcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \ndcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) \ndcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) \ndcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) \ndcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) \ndcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \ndcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) \ndcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \ndcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \n\n\n\n\nThe desired frequency is specified in prune_freq. For illustration, frequency is set to \\(\\geq\\) 35%.\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adae\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Event Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = NULL\n ),\n add_total = TRUE,\n event_type = \"adverse event\",\n prune_freq = 35,\n )\n )\n)\n\n[INFO] 2023-09-08 19:45:35.7476 pid:5888 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nMost Common (\\(\\geq\\) 35%) Adverse Events (setting threshold)\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\n\n\n\nThe “All Patients” column is not required in this table but for illustrative purposes we include it to show correct sorting.\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n var = \"ARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(vars = \"AEDECOD\")\n\ntbl1 <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n)\n\ntbl2 <- prune_table(\n tt = tbl1,\n prune_func = keep_rows(\n has_fraction_in_any_col(\n atleast = 0.05, # specify threshold\n col_names = levels(adsl$ARM)\n )\n )\n)\n\nresult <- sort_at_path(\n tbl2,\n path = c(\"AEDECOD\"),\n scorefun = score_occurrences\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————\ndcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \ndcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) \ndcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) \ndcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) \ndcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) \ndcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \ndcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) \ndcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \ndcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \ndcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n var = \"ARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(vars = \"AEDECOD\")\n\ntbl1 <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n)\n\ntbl2 <- prune_table(\n tt = tbl1,\n prune_func = keep_rows(\n has_fraction_in_any_col(\n atleast = 0.35, # specify threshold\n col_names = levels(adsl$ARM)\n )\n )\n)\n\nresult <- sort_at_path(\n tbl2,\n path = c(\"AEDECOD\"),\n scorefun = score_occurrences\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————\ndcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \ndcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) \ndcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) \ndcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) \ndcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) \ndcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \ndcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) \ndcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \ndcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \n\n\n\n\nThe desired frequency is specified in prune_freq. For illustration, frequency is set to \\(\\geq\\) 35%.\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adae\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Event Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = NULL\n ),\n add_total = TRUE,\n event_type = \"adverse event\",\n prune_freq = 35,\n )\n )\n)\n\n[INFO] 2023-09-09 18:05:49.2643 pid:5893 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet01_aesi.html",
"href": "tables/adverse-events/aet01_aesi.html",
"title": "AET01_AESI",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Optional Lines\nTable For Studies with Multiple Drugs\nTable of AEs by SMQ\nteal App\nReproducibility\n\n\n\nTo illustrate, additional variables such as flags (TRUE/FALSE) for selected AEs of interest. Please consult your SAP on how to handle missing AE grades.\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadsl <- filter(adsl, SAFFL == \"Y\")\nadae <- filter(adae, ANL01FL == \"Y\" & SAFFL == \"Y\")\n\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nnot_resolved <- adae %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>%\n mutate(NOT_RESOLVED = \"Y\")\n\nadae <- adae %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"Total number of patients with all non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"Total number of patients with at least one unresolved or ongoing non-fatal AE\")\n )\n\nadae <- adae %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"Total number of patients with study drug withdrawn due to AE\"),\n DSM = with_label(\n AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Total number of patients with dose modified/interrupted due to AE\"\n ),\n CONTRT = with_label(AECONTRT == \"Y\", \"Total number of patients with treatment received for AE\"),\n SER = with_label(AESER == \"Y\", \"Total number of patients with at least one serious AE\"),\n REL = with_label(AEREL == \"Y\", \"Total number of patients with at least one related AE\"),\n ALL_RESOLVED_WD = with_label(WD == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with study drug withdrawn due to resolved AE\"),\n ALL_RESOLVED_DSM = with_label(DSM == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with dose modified/interrupted due to resolved AE\"),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with treatment received for resolved AE\"),\n NOT_RESOLVED_WD = with_label(WD == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with study drug withdrawn due to unresolved or ongoing AE\"),\n NOT_RESOLVED_DSM = with_label(DSM == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with dose modified/interrupted due to unresolved or ongoing AE\"),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with treatment received for unresolved or ongoing AE\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"No. of patients with study drug withdrawn due to serious AE\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"No. of patients with dose modified/interrupted due to serious AE\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"No. of patients with treatment received for serious AE\"\n ),\n RELWD = with_label(AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"No. of patients with study drug withdrawn due to related AE\"),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose modified/interrupted due to related AE\"\n ),\n RELCONTRT = with_label(AECONTRT == \"Y\" & AEREL == \"Y\", \"No. of patients with treatment received for related AE\"),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"No. of patients with serious, related AE\")\n )\n\nadae <- adae %>%\n mutate(\n AETOXGR = forcats::fct_recode(AETOXGR,\n \"Grade 1\" = \"1\",\n \"Grade 2\" = \"2\",\n \"Grade 3\" = \"3\",\n \"Grade 4\" = \"4\",\n \"Grade 5 (fatal outcome)\" = \"5\"\n )\n )\n\n\n\n\n\nCodeaesi_vars <- c(\"WD\", \"DSM\", \"CONTRT\", \"ALL_RESOLVED\", \"NOT_RESOLVED\", \"SER\", \"REL\")\n\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n vars = \"USUBJID\",\n filters = c(\"ANL01FL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients with at least one AE\")\n ) %>%\n count_values(\n \"ANL01FL\",\n values = \"Y\",\n .stats = \"count\",\n .labels = c(count = \"Total number of AEs\"),\n table_names = \"total_aes\"\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n var_labels = \"Total number of patients with at least one AE by worst grade\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\"USUBJID\", flag_variables = aesi_vars, denom = \"N_col\")\n\nresult <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of patients with at least one AE by worst grade \n Grade 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n Grade 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n Grade 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 (fatal outcome) 64 (47.8%) 52 (38.8%) 64 (48.5%) \nTotal number of patients with study drug withdrawn due to AE 22 (16.4%) 21 (15.7%) 28 (21.2%) \nTotal number of patients with dose modified/interrupted due to AE 55 (41.0%) 62 (46.3%) 64 (48.5%) \nTotal number of patients with treatment received for AE 80 (59.7%) 80 (59.7%) 89 (67.4%) \nTotal number of patients with all non-fatal AEs resolved 17 (12.7%) 12 (9.0%) 11 (8.3%) \nTotal number of patients with at least one unresolved or ongoing non-fatal AE 83 (61.9%) 86 (64.2%) 92 (69.7%) \nTotal number of patients with at least one serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \nTotal number of patients with at least one related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n\n\n\n\n\nCodeaesi_vars <- c(\"WD\", \"DSM\", \"CONTRT\")\naesi_resolved <- c(\"ALL_RESOLVED\", \"ALL_RESOLVED_WD\", \"ALL_RESOLVED_DSM\", \"ALL_RESOLVED_CONTRT\")\naesi_not_resolved <- c(\"NOT_RESOLVED\", \"NOT_RESOLVED_WD\", \"NOT_RESOLVED_DSM\", \"NOT_RESOLVED_CONTRT\")\naesi_ser <- c(\"SER\", \"SERWD\", \"SERDSM\", \"SERCONTRT\")\naesi_rel <- c(\"REL\", \"RELWD\", \"RELDSM\", \"RELCONTRT\", \"RELSER\")\n\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n vars = \"USUBJID\",\n filters = c(\"ANL01FL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients with at least one AE\")\n ) %>%\n count_values(\n \"ANL01FL\",\n values = \"Y\",\n .stats = \"count\",\n .labels = c(count = \"Total number of AEs\"),\n table_names = \"total_aes\"\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n var_labels = \"Total number of patients with at least one AE by worst grade\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = c(aesi_vars, aesi_resolved[1]), denom = \"N_col\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_resolved[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_res\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_not_resolved[1], denom = \"N_col\", table_names = \"fl_notres_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_not_resolved[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_notres\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_ser[1], denom = \"N_col\", table_names = \"fl_ser_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_ser[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_ser\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel[1], denom = \"N_col\", table_names = \"fl_rel_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_rel\"\n )\n\nresult <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of patients with at least one AE by worst grade \n Grade 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n Grade 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n Grade 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 (fatal outcome) 64 (47.8%) 52 (38.8%) 64 (48.5%) \nTotal number of patients with study drug withdrawn due to AE 22 (16.4%) 21 (15.7%) 28 (21.2%) \nTotal number of patients with dose modified/interrupted due to AE 55 (41.0%) 62 (46.3%) 64 (48.5%) \nTotal number of patients with treatment received for AE 80 (59.7%) 80 (59.7%) 89 (67.4%) \nTotal number of patients with all non-fatal AEs resolved 17 (12.7%) 12 (9.0%) 11 (8.3%) \n No. of patients with study drug withdrawn due to resolved AE 0 1 (0.7%) 2 (1.5%) \n No. of patients with dose modified/interrupted due to resolved AE 3 (2.2%) 4 (3.0%) 2 (1.5%) \n No. of patients with treatment received for resolved AE 9 (6.7%) 7 (5.2%) 7 (5.3%) \nTotal number of patients with at least one unresolved or ongoing non-fatal AE 83 (61.9%) 86 (64.2%) 92 (69.7%) \n No. of patients with study drug withdrawn due to unresolved or ongoing AE 22 (16.4%) 20 (14.9%) 26 (19.7%) \n No. of patients with dose modified/interrupted due to unresolved or ongoing AE 52 (38.8%) 58 (43.3%) 62 (47.0%) \n No. of patients with treatment received for unresolved or ongoing AE 71 (53.0%) 73 (54.5%) 82 (62.1%) \nTotal number of patients with at least one serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n No. of patients with study drug withdrawn due to serious AE 9 (6.7%) 4 (3.0%) 10 (7.6%) \n No. of patients with treatment received for serious AE 21 (15.7%) 22 (16.4%) 28 (21.2%) \n No. of patients with dose modified/interrupted due to serious AE 59 (44.0%) 58 (43.3%) 53 (40.2%) \nTotal number of patients with at least one related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n No. of patients with study drug withdrawn due to related AE 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with dose modified/interrupted due to related AE 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with treatment received for related AE 53 (39.6%) 58 (43.3%) 60 (45.5%) \n No. of patients with serious, related AE 64 (47.8%) 52 (38.8%) 64 (48.5%) \n\n\n\n\n\nCodeadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae_mult <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadsl <- filter(adsl, SAFFL == \"Y\")\nadae_mult <- filter(adae_mult, ANL01FL == \"Y\" & SAFFL == \"Y\")\n\nadsl <- df_explicit_na(adsl)\nadae_mult <- df_explicit_na(adae_mult)\n\n# for illustration purposes only, create AEREL1, AEREL2, AEACN1, AEACN2 from respective variables\nadae_mult <- adae_mult %>%\n mutate(\n AEREL1 = AEREL,\n AEREL2 = AEREL,\n AEACN1 = AEACN,\n AEACN2 = AEACN\n )\n\nnot_resolved <- adae_mult %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>%\n mutate(NOT_RESOLVED = \"Y\")\n\nadae_mult <- adae_mult %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"Total number of patients with all non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"Total number of patients with at least one non-fatal unresolved or ongoing AE\")\n )\n\nadae_mult <- adae_mult %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD1 = with_label(AEACN1 == \"DRUG WITHDRAWN\", \"Total number of patients with study drug 1 withdrawn due to AE\"),\n WD2 = with_label(AEACN2 == \"DRUG WITHDRAWN\", \"Total number of patients with study drug 2 withdrawn due to AE\"),\n DSM1 = with_label(\n AEACN1 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"Total number of patients with dose of study drug 1 modified/interrupted due to AE\"\n ),\n DSM2 = with_label(\n AEACN2 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"Total number of patients with dose of study drug 2 modified/interrupted due to AE\"\n ),\n CONTRT = with_label(AECONTRT == \"Y\", \"Total number of patients with treatment received for AE\"),\n SER = with_label(AESER == \"Y\", \"Total number of patients with at least one serious AE\"),\n REL1 = with_label(AEREL1 == \"Y\", \"Total number of patients with at least one AE related to study drug 1\"),\n REL2 = with_label(AEREL2 == \"Y\", \"Total number of patients with at least one AE related to study drug 2\"),\n ALL_RESOLVED_WD1 = with_label(WD1 == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with study drug 1 withdrawn due to resolved AE\"),\n ALL_RESOLVED_DSM1 = with_label(\n DSM1 == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with dose of study drug 1 modified/interrupted due to resolved AE\"\n ),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with treatment received for resolved AE\"),\n ALL_RESOLVED_WD2 = with_label(WD2 == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with study drug 2 withdrawn due to resolved AE\"),\n ALL_RESOLVED_DSM2 = with_label(\n DSM2 == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with dose of study drug 2 modified/interrupted due to resolved AE\"\n ),\n NOT_RESOLVED_WD1 = with_label(WD1 == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with study drug 1 withdrawn due to unresolved or ongoing AE\"),\n NOT_RESOLVED_DSM1 = with_label(\n DSM1 == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with dose of study drug 1 modified/interrupted due to unresolved or ongoing AE\"\n ),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with treatment received for unresolved or ongoing AE\"),\n NOT_RESOLVED_WD2 = with_label(WD2 == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with study drug 2 withdrawn due to unresolved or ongoing AE\"),\n NOT_RESOLVED_DSM2 = with_label(\n DSM2 == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with dose of study drug 2 modified/interrupted due to unresolved or ongoing AE\"\n ),\n SERWD1 = with_label(AESER == \"Y\" & AEACN1 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 1 withdrawn due to serious AE\"),\n SERWD2 = with_label(AESER == \"Y\" & AEACN2 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 2 withdrawn due to serious AE\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"No. of patients with treatment received for serious AE\"),\n SERDSM1 = with_label(\n AESER == \"Y\" & AEACN1 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 1 modified/interrupted due to serious AE\"\n ),\n SERDSM2 = with_label(\n AESER == \"Y\" & AEACN2 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 2 modified/interrupted due to serious AE\"\n ),\n REL1WD1 = with_label(AEREL1 == \"Y\" & AEACN1 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 1 withdrawn due to AE related to study drug 1\"),\n REL1WD2 = with_label(AEREL1 == \"Y\" & AEACN2 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 1 withdrawn due to AE related to study drug 2\"),\n REL2WD1 = with_label(AEREL1 == \"Y\" & AEACN1 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 2 withdrawn due to AE related to study drug 1\"),\n REL2WD2 = with_label(AEREL1 == \"Y\" & AEACN2 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 2 withdrawn due to AE related to study drug 2\"),\n REL1DSM1 = with_label(\n AEREL1 == \"Y\" & AEACN1 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 1 modified/interrupted due to AE related to study drug 1\"\n ),\n REL2DSM1 = with_label(\n AEREL2 == \"Y\" & AEACN1 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 2 modified/interrupted due to AE related to study drug 1\"\n ),\n REL1DSM2 = with_label(\n AEREL1 == \"Y\" & AEACN2 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 1 modified/interrupted due to AE related to study drug 2\"\n ),\n REL2DSM2 = with_label(\n AEREL2 == \"Y\" & AEACN2 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 2 modified/interrupted due to AE related to study drug 2\"\n ),\n REL1CONTRT = with_label(AECONTRT == \"Y\" & AEREL1 == \"Y\", \"No. of patients with treatment received for AE related to study drug 1\"),\n REL2CONTRT = with_label(AECONTRT == \"Y\" & AEREL2 == \"Y\", \"No. of patients with treatment received for AE related to study drug 2\"),\n REL1SER = with_label(AESER == \"Y\" & AEREL1 == \"Y\", \"No. of patients with serious AE related to study drug 1\"),\n REL2SER = with_label(AESER == \"Y\" & AEREL2 == \"Y\", \"No. of patients with serious AE related to study drug 2\")\n )\n\nadae_mult <- adae_mult %>%\n mutate(AETOXGR = forcats::fct_recode(\n AETOXGR,\n \"Grade 1\" = \"1\",\n \"Grade 2\" = \"2\",\n \"Grade 3\" = \"3\",\n \"Grade 4\" = \"4\",\n \"Grade 5 (fatal outcome)\" = \"5\"\n ))\n\naesi_vars <- c(\"WD1\", \"WD2\", \"DSM1\", \"DSM2\", \"CONTRT\")\naesi_res <- c(\"ALL_RESOLVED\", \"ALL_RESOLVED_WD1\", \"ALL_RESOLVED_WD2\", \"ALL_RESOLVED_DSM1\", \"ALL_RESOLVED_DSM2\", \"ALL_RESOLVED_CONTRT\")\naesi_not_res <- c(\"NOT_RESOLVED\", \"NOT_RESOLVED_WD1\", \"NOT_RESOLVED_WD2\", \"NOT_RESOLVED_DSM1\", \"NOT_RESOLVED_DSM2\", \"NOT_RESOLVED_CONTRT\")\naesi_ser <- c(\"SER\", \"SERWD1\", \"SERWD2\", \"SERDSM1\", \"SERDSM2\", \"SERCONTRT\")\naesi_rel1 <- c(\"REL1\", \"REL1WD1\", \"REL1WD2\", \"REL1DSM1\", \"REL1DSM2\", \"REL1CONTRT\", \"REL1SER\")\naesi_rel2 <- c(\"REL2\", \"REL2WD1\", \"REL2WD2\", \"REL2DSM1\", \"REL2DSM2\", \"REL2CONTRT\", \"REL2SER\")\n\nlyt_adae_mult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n vars = \"USUBJID\",\n filters = c(\"ANL01FL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients with at least one AE\")\n ) %>%\n count_values(\n \"ANL01FL\",\n values = \"Y\",\n .stats = \"count\",\n .labels = c(count = \"Total number of AEs\"),\n table_names = \"total_aes\"\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n var_labels = \"Total number of patients with at least one AE by worst grade\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = c(aesi_vars, aesi_res[1]), denom = \"N_col\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_res[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_res\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_not_res[1], denom = \"N_col\", table_names = \"fl_notres_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_not_res[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_notres\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_ser[1], denom = \"N_col\", table_names = \"fl_ser_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_ser[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_ser\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel1[1], denom = \"N_col\", table_names = \"fl_rel1_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel1[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_rel1\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel2[1], denom = \"N_col\", table_names = \"fl_rel2_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel2[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_rel2\"\n )\n\nresult <- build_table(lyt_adae_mult, df = adae_mult, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of patients with at least one AE by worst grade \n Grade 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n Grade 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n Grade 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 (fatal outcome) 64 (47.8%) 52 (38.8%) 64 (48.5%) \nTotal number of patients with study drug 1 withdrawn due to AE 22 (16.4%) 21 (15.7%) 28 (21.2%) \nTotal number of patients with study drug 2 withdrawn due to AE 22 (16.4%) 21 (15.7%) 28 (21.2%) \nTotal number of patients with dose of study drug 1 modified/interrupted due to AE 55 (41.0%) 62 (46.3%) 64 (48.5%) \nTotal number of patients with dose of study drug 2 modified/interrupted due to AE 55 (41.0%) 62 (46.3%) 64 (48.5%) \nTotal number of patients with treatment received for AE 80 (59.7%) 80 (59.7%) 89 (67.4%) \nTotal number of patients with all non-fatal AEs resolved 17 (12.7%) 12 (9.0%) 11 (8.3%) \n No. of patients with study drug 1 withdrawn due to resolved AE 0 1 (0.7%) 2 (1.5%) \n No. of patients with study drug 2 withdrawn due to resolved AE 0 1 (0.7%) 2 (1.5%) \n No. of patients with dose of study drug 1 modified/interrupted due to resolved AE 3 (2.2%) 4 (3.0%) 2 (1.5%) \n No. of patients with dose of study drug 2 modified/interrupted due to resolved AE 3 (2.2%) 4 (3.0%) 2 (1.5%) \n No. of patients with treatment received for resolved AE 9 (6.7%) 7 (5.2%) 7 (5.3%) \nTotal number of patients with at least one non-fatal unresolved or ongoing AE 83 (61.9%) 86 (64.2%) 92 (69.7%) \n No. of patients with study drug 1 withdrawn due to unresolved or ongoing AE 22 (16.4%) 20 (14.9%) 26 (19.7%) \n No. of patients with study drug 2 withdrawn due to unresolved or ongoing AE 22 (16.4%) 20 (14.9%) 26 (19.7%) \n No. of patients with dose of study drug 1 modified/interrupted due to unresolved or ongoing AE 52 (38.8%) 58 (43.3%) 62 (47.0%) \n No. of patients with dose of study drug 2 modified/interrupted due to unresolved or ongoing AE 52 (38.8%) 58 (43.3%) 62 (47.0%) \n No. of patients with treatment received for unresolved or ongoing AE 71 (53.0%) 73 (54.5%) 82 (62.1%) \nTotal number of patients with at least one serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n No. of patients with study drug 1 withdrawn due to serious AE 9 (6.7%) 4 (3.0%) 10 (7.6%) \n No. of patients with study drug 2 withdrawn due to serious AE 9 (6.7%) 4 (3.0%) 10 (7.6%) \n No. of patients with dose of study drug 1 modified/interrupted due to serious AE 21 (15.7%) 22 (16.4%) 28 (21.2%) \n No. of patients with dose of study drug 2 modified/interrupted due to serious AE 21 (15.7%) 22 (16.4%) 28 (21.2%) \n No. of patients with treatment received for serious AE 59 (44.0%) 58 (43.3%) 53 (40.2%) \nTotal number of patients with at least one AE related to study drug 1 86 (64.2%) 85 (63.4%) 92 (69.7%) \n No. of patients with study drug 1 withdrawn due to AE related to study drug 1 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with study drug 1 withdrawn due to AE related to study drug 2 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with dose of study drug 1 modified/interrupted due to AE related to study drug 1 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with dose of study drug 1 modified/interrupted due to AE related to study drug 2 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with treatment received for AE related to study drug 1 53 (39.6%) 58 (43.3%) 60 (45.5%) \n No. of patients with serious AE related to study drug 1 64 (47.8%) 52 (38.8%) 64 (48.5%) \nTotal number of patients with at least one AE related to study drug 2 86 (64.2%) 85 (63.4%) 92 (69.7%) \n No. of patients with study drug 2 withdrawn due to AE related to study drug 1 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with study drug 2 withdrawn due to AE related to study drug 2 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with dose of study drug 2 modified/interrupted due to AE related to study drug 1 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with dose of study drug 2 modified/interrupted due to AE related to study drug 2 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with treatment received for AE related to study drug 2 53 (39.6%) 58 (43.3%) 60 (45.5%) \n No. of patients with serious AE related to study drug 2 64 (47.8%) 52 (38.8%) 64 (48.5%) \n\n\n\n\n\nCodeadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadsl <- filter(adsl, SAFFL == \"Y\")\nadae <- filter(adae, ANL01FL == \"Y\" & SAFFL == \"Y\")\n\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nstack_adae_by_smq <- function(adae, smq) {\n adae_labels <- c(var_labels(adae), \"Standardized MedDRA Query\")\n l_df <- lapply(smq, function(ae_grp) {\n ae_scope <- gsub(\"NAM\", \"SC\", ae_grp)\n keep <- adae[[ae_grp]] != \"<Missing>\"\n df <- adae[keep, ]\n if (substr(ae_grp, 1, 3) == \"SMQ\") {\n df[[\"SMQ\"]] <- aesi_label(as.character(df[[ae_grp]]), scope = as.character(df[[ae_scope]]))\n } else {\n df[[\"SMQ\"]] <- df[[ae_grp]]\n }\n df\n })\n result <- do.call(rbind, l_df)\n var_labels(result) <- adae_labels\n result\n}\n\nadae_smq <- stack_adae_by_smq(adae, c(\"SMQ01NAM\", \"SMQ02NAM\", \"CQ01NAM\"))\n\nnot_resolved <- adae_smq %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>%\n mutate(NOT_RESOLVED = \"Y\")\n\nadae_smq <- adae_smq %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"Total number of patients with all non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"Total number of patients with at least one non-fatal unresolved or ongoing AE\")\n )\n\nadae_smq <- adae_smq %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"Total number of patients with study drug withdrawn due to AE\"),\n DSM = with_label(\n AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Total number of patients with dose modified/interrupted due to AE\"\n ),\n CONTRT = with_label(AECONTRT == \"Y\", \"Total number of patients with treatment received for AE\"),\n SER = with_label(AESER == \"Y\", \"Total number of patients with at least one serious AE\"),\n REL = with_label(AEREL == \"Y\", \"Total number of patients with at least one related AE\"),\n ALL_RESOLVED_WD = with_label(WD == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with study drug withdrawn due to resolved AE\"),\n ALL_RESOLVED_DSM = with_label(DSM == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with dose modified/interrupted due to resolved AE\"),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with treatment received for resolved AE\"),\n NOT_RESOLVED_WD = with_label(WD == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with study drug withdrawn due to unresolved or ongoing AE\"),\n NOT_RESOLVED_DSM = with_label(DSM == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with dose modified/interrupted due to unresolved or ongoing AE\"),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with treatment received for unresolved or ongoing AE\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"No. of patients with study drug withdrawn due to serious AE\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"No. of patients with treatment received for serious AE\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose modified/interrupted due to serious AE\"\n ),\n RELWD = with_label(AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"No. of patients with study drug withdrawn due to related AE\"),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose modified/interrupted due to related AE\"\n ),\n RELCONTRT = with_label(AECONTRT == \"Y\" & AEREL == \"Y\", \"No. of patients with treatment received for related AE\"),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"No. of patients with serious, related AE\")\n )\n\nadae_smq <- adae_smq %>%\n mutate(\n AETOXGR = forcats::fct_recode(AETOXGR,\n \"Grade 1\" = \"1\",\n \"Grade 2\" = \"2\",\n \"Grade 3\" = \"3\",\n \"Grade 4\" = \"4\",\n \"Grade 5 (fatal outcome)\" = \"5\"\n )\n )\n\nsplit_fun <- remove_split_levels(\"<Missing>\")\naesi_vars <- c(\"WD\", \"DSM\", \"CONTRT\", \"ALL_RESOLVED\", \"NOT_RESOLVED\", \"SER\", \"REL\")\n\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n split_fun = split_fun,\n split_label = \"Standardized MedDRA Query\",\n label_pos = \"topleft\"\n ) %>%\n count_patients_with_event(\n vars = \"USUBJID\",\n filters = c(\"ANL01FL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients with at least one AE\")\n ) %>%\n count_values(\n \"ANL01FL\",\n values = \"Y\",\n .stats = \"count\",\n .labels = c(count = \"Total number of AEs\"),\n table_names = \"total_aes\"\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n var_labels = \"Total number of patients with at least one AE by worst grade\",\n .show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\"USUBJID\", flag_variables = aesi_vars, denom = \"N_col\")\n\nresult <- build_table(lyt_adae, df = adae_smq, alt_counts_df = adsl)\nresult\n\nStandardized MedDRA Query A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nC.1.1.1.3/B.2.2.3.1 AESI (BROAD) \n Total number of patients with at least one AE 58 (43.3%) 60 (44.8%) 66 (50.0%) \n Total number of AEs 97 106 122 \n Total number of patients with at least one AE by worst grade \n Grade 1 22 (16.4%) 26 (19.4%) 30 (22.7%) \n Grade 2 0 0 0 \n Grade 3 0 0 0 \n Grade 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 5 (fatal outcome) 0 0 0 \n Total number of patients with study drug withdrawn due to AE 5 (3.7%) 6 (4.5%) 9 (6.8%) \n Total number of patients with dose modified/interrupted due to AE 21 (15.7%) 21 (15.7%) 24 (18.2%) \n Total number of patients with treatment received for AE 32 (23.9%) 35 (26.1%) 44 (33.3%) \n Total number of patients with all non-fatal AEs resolved 7 (5.2%) 9 (6.7%) 8 (6.1%) \n Total number of patients with at least one non-fatal unresolved or ongoing AE 51 (38.1%) 51 (38.1%) 58 (43.9%) \n Total number of patients with at least one serious AE 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Total number of patients with at least one related AE 36 (26.9%) 34 (25.4%) 36 (27.3%) \nD.2.1.5.3/A.1.1.1.1 AESI \n Total number of patients with at least one AE 62 (46.3%) 61 (45.5%) 76 (57.6%) \n Total number of AEs 106 100 139 \n Total number of patients with at least one AE by worst grade \n Grade 1 62 (46.3%) 61 (45.5%) 76 (57.6%) \n Grade 2 0 0 0 \n Grade 3 0 0 0 \n Grade 4 0 0 0 \n Grade 5 (fatal outcome) 0 0 0 \n Total number of patients with study drug withdrawn due to AE 6 (4.5%) 8 (6.0%) 4 (3.0%) \n Total number of patients with dose modified/interrupted due to AE 23 (17.2%) 20 (14.9%) 26 (19.7%) \n Total number of patients with treatment received for AE 33 (24.6%) 37 (27.6%) 33 (25.0%) \n Total number of patients with all non-fatal AEs resolved 4 (3.0%) 5 (3.7%) 14 (10.6%) \n Total number of patients with at least one non-fatal unresolved or ongoing AE 58 (43.3%) 56 (41.8%) 62 (47.0%) \n Total number of patients with at least one serious AE 0 0 0 \n Total number of patients with at least one related AE 37 (27.6%) 46 (34.3%) 50 (37.9%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\nadae <- filter(adae, ANL01FL == \"Y\" & SAFFL == \"Y\")\n\nnot_resolved <- adae %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>%\n mutate(NOT_RESOLVED = \"Y\")\n\nadae <- adae %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"All non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"At least one non-fatal unresolved or ongoing AE\")\n )\n\nadae <- adae %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"AE that led to study drug withdrawal\"),\n DSM = with_label(AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"AE that led to study drug dose modified/interrupted\"),\n CONTRT = with_label(AECONTRT == \"Y\", \"AE that required treatment\"),\n SER = with_label(AESER == \"Y\", \"Serious AE\"),\n REL = with_label(AEREL == \"Y\", \"Related AE\"),\n ALL_RESOLVED_WD = with_label(WD == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that led to study drug withdrawal\"),\n ALL_RESOLVED_DSM = with_label(DSM == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that led to study drug dose modified/interrupted\"),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that required treatment\"),\n NOT_RESOLVED_WD = with_label(WD == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that led to study drug withdrawal\"),\n NOT_RESOLVED_DSM = with_label(DSM == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that led to study drug dose modified/interrupted\"),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that required treatment\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Serious AE that led to study drug withdrawal\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"Serious AE that required treatment\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Serious AE that led to study drug dose modified/interrupted\"\n ),\n RELWD = with_label(\n AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Related AE that led to study drug withdrawal\"\n ),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Related AE that led to study drug dose modified/interrupted\"\n ),\n RELCONTRT = with_label(AECONTRT == \"Y\" & AEREL == \"Y\", \"Related AE that required treatment\"),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"Serious related AE\")\n )\n\naesi_vars <- c(\n \"WD\", \"DSM\", \"CONTRT\", \"ALL_RESOLVED_WD\", \"ALL_RESOLVED_DSM\", \"ALL_RESOLVED_CONTRT\",\n \"NOT_RESOLVED_WD\", \"NOT_RESOLVED_DSM\", \"NOT_RESOLVED_CONTRT\", \"SER\", \"SERWD\", \"SERDSM\",\n \"SERCONTRT\", \"REL\", \"RELWD\", \"RELDSM\", \"RELCONTRT\", \"RELSER\"\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n ADAE <- filter(ADAE, ANL01FL == \"Y\" & SAFFL == \"Y\")\n not_resolved <- ADAE %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>% mutate(NOT_RESOLVED = \"Y\")\n\n ADAE <- ADAE %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"All non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"At least one non-fatal unresolved or ongoing AE\")\n )\n\n ADAE <- ADAE %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"AE that led to study drug withdrawal\"),\n DSM = with_label(AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"AE that led to study drug dose modified/interrupted\"),\n CONTRT = with_label(AECONTRT == \"Y\", \"AE that required treatment\"),\n SER = with_label(AESER == \"Y\", \"Serious AE\"),\n REL = with_label(AEREL == \"Y\", \"Related AE\"),\n ALL_RESOLVED_WD = with_label(WD == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that led to study drug withdrawal\"),\n ALL_RESOLVED_DSM = with_label(DSM == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that led to study drug dose modified/interrupted\"),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that required treatment\"),\n NOT_RESOLVED_WD = with_label(WD == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that led to study drug withdrawal\"),\n NOT_RESOLVED_DSM = with_label(DSM == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that led to study drug dose modified/interrupted\"),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that required treatment\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Serious AE that led to study drug withdrawal\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"Serious AE that required treatment\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Serious AE that led to study drug dose modified/interrupted\"\n ),\n RELWD = with_label(\n AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Related AE that led to study drug withdrawal\"\n ),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Related AE that led to study drug dose modified/interrupted\"\n ),\n RELCONTRT = with_label(AECONTRT == \"Y\" & AEREL == \"Y\", \"Related AE that required treatment\"),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"Serious related AE\")\n )'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events_summary(\n label = \"Adverse Events Summary\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(\"ADSL\", c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n flag_var_anl = choices_selected(\n choices = variable_choices(\"ADAE\", aesi_vars),\n selected = aesi_vars[1],\n keep_order = TRUE,\n fixed = FALSE\n ),\n add_total = TRUE\n )\n )\n)\n\n[INFO] 2023-09-08 19:44:42.7248 pid:5692 token:[] teal.modules.clinical Initializing tm_t_events_summary\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Optional Lines\nTable For Studies with Multiple Drugs\nTable of AEs by SMQ\nteal App\nReproducibility\n\n\n\nTo illustrate, additional variables such as flags (TRUE/FALSE) for selected AEs of interest. Please consult your SAP on how to handle missing AE grades.\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadsl <- filter(adsl, SAFFL == \"Y\")\nadae <- filter(adae, ANL01FL == \"Y\" & SAFFL == \"Y\")\n\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nnot_resolved <- adae %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>%\n mutate(NOT_RESOLVED = \"Y\")\n\nadae <- adae %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"Total number of patients with all non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"Total number of patients with at least one unresolved or ongoing non-fatal AE\")\n )\n\nadae <- adae %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"Total number of patients with study drug withdrawn due to AE\"),\n DSM = with_label(\n AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Total number of patients with dose modified/interrupted due to AE\"\n ),\n CONTRT = with_label(AECONTRT == \"Y\", \"Total number of patients with treatment received for AE\"),\n SER = with_label(AESER == \"Y\", \"Total number of patients with at least one serious AE\"),\n REL = with_label(AEREL == \"Y\", \"Total number of patients with at least one related AE\"),\n ALL_RESOLVED_WD = with_label(WD == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with study drug withdrawn due to resolved AE\"),\n ALL_RESOLVED_DSM = with_label(DSM == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with dose modified/interrupted due to resolved AE\"),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with treatment received for resolved AE\"),\n NOT_RESOLVED_WD = with_label(WD == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with study drug withdrawn due to unresolved or ongoing AE\"),\n NOT_RESOLVED_DSM = with_label(DSM == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with dose modified/interrupted due to unresolved or ongoing AE\"),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with treatment received for unresolved or ongoing AE\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"No. of patients with study drug withdrawn due to serious AE\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"No. of patients with dose modified/interrupted due to serious AE\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"No. of patients with treatment received for serious AE\"\n ),\n RELWD = with_label(AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"No. of patients with study drug withdrawn due to related AE\"),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose modified/interrupted due to related AE\"\n ),\n RELCONTRT = with_label(AECONTRT == \"Y\" & AEREL == \"Y\", \"No. of patients with treatment received for related AE\"),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"No. of patients with serious, related AE\")\n )\n\nadae <- adae %>%\n mutate(\n AETOXGR = forcats::fct_recode(AETOXGR,\n \"Grade 1\" = \"1\",\n \"Grade 2\" = \"2\",\n \"Grade 3\" = \"3\",\n \"Grade 4\" = \"4\",\n \"Grade 5 (fatal outcome)\" = \"5\"\n )\n )\n\n\n\n\n\nCodeaesi_vars <- c(\"WD\", \"DSM\", \"CONTRT\", \"ALL_RESOLVED\", \"NOT_RESOLVED\", \"SER\", \"REL\")\n\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n vars = \"USUBJID\",\n filters = c(\"ANL01FL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients with at least one AE\")\n ) %>%\n count_values(\n \"ANL01FL\",\n values = \"Y\",\n .stats = \"count\",\n .labels = c(count = \"Total number of AEs\"),\n table_names = \"total_aes\"\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n var_labels = \"Total number of patients with at least one AE by worst grade\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\"USUBJID\", flag_variables = aesi_vars, denom = \"N_col\")\n\nresult <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of patients with at least one AE by worst grade \n Grade 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n Grade 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n Grade 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 (fatal outcome) 64 (47.8%) 52 (38.8%) 64 (48.5%) \nTotal number of patients with study drug withdrawn due to AE 22 (16.4%) 21 (15.7%) 28 (21.2%) \nTotal number of patients with dose modified/interrupted due to AE 55 (41.0%) 62 (46.3%) 64 (48.5%) \nTotal number of patients with treatment received for AE 80 (59.7%) 80 (59.7%) 89 (67.4%) \nTotal number of patients with all non-fatal AEs resolved 17 (12.7%) 12 (9.0%) 11 (8.3%) \nTotal number of patients with at least one unresolved or ongoing non-fatal AE 83 (61.9%) 86 (64.2%) 92 (69.7%) \nTotal number of patients with at least one serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \nTotal number of patients with at least one related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n\n\n\n\n\nCodeaesi_vars <- c(\"WD\", \"DSM\", \"CONTRT\")\naesi_resolved <- c(\"ALL_RESOLVED\", \"ALL_RESOLVED_WD\", \"ALL_RESOLVED_DSM\", \"ALL_RESOLVED_CONTRT\")\naesi_not_resolved <- c(\"NOT_RESOLVED\", \"NOT_RESOLVED_WD\", \"NOT_RESOLVED_DSM\", \"NOT_RESOLVED_CONTRT\")\naesi_ser <- c(\"SER\", \"SERWD\", \"SERDSM\", \"SERCONTRT\")\naesi_rel <- c(\"REL\", \"RELWD\", \"RELDSM\", \"RELCONTRT\", \"RELSER\")\n\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n vars = \"USUBJID\",\n filters = c(\"ANL01FL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients with at least one AE\")\n ) %>%\n count_values(\n \"ANL01FL\",\n values = \"Y\",\n .stats = \"count\",\n .labels = c(count = \"Total number of AEs\"),\n table_names = \"total_aes\"\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n var_labels = \"Total number of patients with at least one AE by worst grade\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = c(aesi_vars, aesi_resolved[1]), denom = \"N_col\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_resolved[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_res\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_not_resolved[1], denom = \"N_col\", table_names = \"fl_notres_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_not_resolved[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_notres\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_ser[1], denom = \"N_col\", table_names = \"fl_ser_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_ser[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_ser\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel[1], denom = \"N_col\", table_names = \"fl_rel_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_rel\"\n )\n\nresult <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of patients with at least one AE by worst grade \n Grade 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n Grade 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n Grade 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 (fatal outcome) 64 (47.8%) 52 (38.8%) 64 (48.5%) \nTotal number of patients with study drug withdrawn due to AE 22 (16.4%) 21 (15.7%) 28 (21.2%) \nTotal number of patients with dose modified/interrupted due to AE 55 (41.0%) 62 (46.3%) 64 (48.5%) \nTotal number of patients with treatment received for AE 80 (59.7%) 80 (59.7%) 89 (67.4%) \nTotal number of patients with all non-fatal AEs resolved 17 (12.7%) 12 (9.0%) 11 (8.3%) \n No. of patients with study drug withdrawn due to resolved AE 0 1 (0.7%) 2 (1.5%) \n No. of patients with dose modified/interrupted due to resolved AE 3 (2.2%) 4 (3.0%) 2 (1.5%) \n No. of patients with treatment received for resolved AE 9 (6.7%) 7 (5.2%) 7 (5.3%) \nTotal number of patients with at least one unresolved or ongoing non-fatal AE 83 (61.9%) 86 (64.2%) 92 (69.7%) \n No. of patients with study drug withdrawn due to unresolved or ongoing AE 22 (16.4%) 20 (14.9%) 26 (19.7%) \n No. of patients with dose modified/interrupted due to unresolved or ongoing AE 52 (38.8%) 58 (43.3%) 62 (47.0%) \n No. of patients with treatment received for unresolved or ongoing AE 71 (53.0%) 73 (54.5%) 82 (62.1%) \nTotal number of patients with at least one serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n No. of patients with study drug withdrawn due to serious AE 9 (6.7%) 4 (3.0%) 10 (7.6%) \n No. of patients with treatment received for serious AE 21 (15.7%) 22 (16.4%) 28 (21.2%) \n No. of patients with dose modified/interrupted due to serious AE 59 (44.0%) 58 (43.3%) 53 (40.2%) \nTotal number of patients with at least one related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n No. of patients with study drug withdrawn due to related AE 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with dose modified/interrupted due to related AE 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with treatment received for related AE 53 (39.6%) 58 (43.3%) 60 (45.5%) \n No. of patients with serious, related AE 64 (47.8%) 52 (38.8%) 64 (48.5%) \n\n\n\n\n\nCodeadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae_mult <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadsl <- filter(adsl, SAFFL == \"Y\")\nadae_mult <- filter(adae_mult, ANL01FL == \"Y\" & SAFFL == \"Y\")\n\nadsl <- df_explicit_na(adsl)\nadae_mult <- df_explicit_na(adae_mult)\n\n# for illustration purposes only, create AEREL1, AEREL2, AEACN1, AEACN2 from respective variables\nadae_mult <- adae_mult %>%\n mutate(\n AEREL1 = AEREL,\n AEREL2 = AEREL,\n AEACN1 = AEACN,\n AEACN2 = AEACN\n )\n\nnot_resolved <- adae_mult %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>%\n mutate(NOT_RESOLVED = \"Y\")\n\nadae_mult <- adae_mult %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"Total number of patients with all non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"Total number of patients with at least one non-fatal unresolved or ongoing AE\")\n )\n\nadae_mult <- adae_mult %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD1 = with_label(AEACN1 == \"DRUG WITHDRAWN\", \"Total number of patients with study drug 1 withdrawn due to AE\"),\n WD2 = with_label(AEACN2 == \"DRUG WITHDRAWN\", \"Total number of patients with study drug 2 withdrawn due to AE\"),\n DSM1 = with_label(\n AEACN1 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"Total number of patients with dose of study drug 1 modified/interrupted due to AE\"\n ),\n DSM2 = with_label(\n AEACN2 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"Total number of patients with dose of study drug 2 modified/interrupted due to AE\"\n ),\n CONTRT = with_label(AECONTRT == \"Y\", \"Total number of patients with treatment received for AE\"),\n SER = with_label(AESER == \"Y\", \"Total number of patients with at least one serious AE\"),\n REL1 = with_label(AEREL1 == \"Y\", \"Total number of patients with at least one AE related to study drug 1\"),\n REL2 = with_label(AEREL2 == \"Y\", \"Total number of patients with at least one AE related to study drug 2\"),\n ALL_RESOLVED_WD1 = with_label(WD1 == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with study drug 1 withdrawn due to resolved AE\"),\n ALL_RESOLVED_DSM1 = with_label(\n DSM1 == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with dose of study drug 1 modified/interrupted due to resolved AE\"\n ),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with treatment received for resolved AE\"),\n ALL_RESOLVED_WD2 = with_label(WD2 == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with study drug 2 withdrawn due to resolved AE\"),\n ALL_RESOLVED_DSM2 = with_label(\n DSM2 == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with dose of study drug 2 modified/interrupted due to resolved AE\"\n ),\n NOT_RESOLVED_WD1 = with_label(WD1 == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with study drug 1 withdrawn due to unresolved or ongoing AE\"),\n NOT_RESOLVED_DSM1 = with_label(\n DSM1 == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with dose of study drug 1 modified/interrupted due to unresolved or ongoing AE\"\n ),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with treatment received for unresolved or ongoing AE\"),\n NOT_RESOLVED_WD2 = with_label(WD2 == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with study drug 2 withdrawn due to unresolved or ongoing AE\"),\n NOT_RESOLVED_DSM2 = with_label(\n DSM2 == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with dose of study drug 2 modified/interrupted due to unresolved or ongoing AE\"\n ),\n SERWD1 = with_label(AESER == \"Y\" & AEACN1 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 1 withdrawn due to serious AE\"),\n SERWD2 = with_label(AESER == \"Y\" & AEACN2 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 2 withdrawn due to serious AE\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"No. of patients with treatment received for serious AE\"),\n SERDSM1 = with_label(\n AESER == \"Y\" & AEACN1 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 1 modified/interrupted due to serious AE\"\n ),\n SERDSM2 = with_label(\n AESER == \"Y\" & AEACN2 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 2 modified/interrupted due to serious AE\"\n ),\n REL1WD1 = with_label(AEREL1 == \"Y\" & AEACN1 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 1 withdrawn due to AE related to study drug 1\"),\n REL1WD2 = with_label(AEREL1 == \"Y\" & AEACN2 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 1 withdrawn due to AE related to study drug 2\"),\n REL2WD1 = with_label(AEREL1 == \"Y\" & AEACN1 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 2 withdrawn due to AE related to study drug 1\"),\n REL2WD2 = with_label(AEREL1 == \"Y\" & AEACN2 == \"DRUG WITHDRAWN\", \"No. of patients with study drug 2 withdrawn due to AE related to study drug 2\"),\n REL1DSM1 = with_label(\n AEREL1 == \"Y\" & AEACN1 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 1 modified/interrupted due to AE related to study drug 1\"\n ),\n REL2DSM1 = with_label(\n AEREL2 == \"Y\" & AEACN1 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 2 modified/interrupted due to AE related to study drug 1\"\n ),\n REL1DSM2 = with_label(\n AEREL1 == \"Y\" & AEACN2 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 1 modified/interrupted due to AE related to study drug 2\"\n ),\n REL2DSM2 = with_label(\n AEREL2 == \"Y\" & AEACN2 %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose of study drug 2 modified/interrupted due to AE related to study drug 2\"\n ),\n REL1CONTRT = with_label(AECONTRT == \"Y\" & AEREL1 == \"Y\", \"No. of patients with treatment received for AE related to study drug 1\"),\n REL2CONTRT = with_label(AECONTRT == \"Y\" & AEREL2 == \"Y\", \"No. of patients with treatment received for AE related to study drug 2\"),\n REL1SER = with_label(AESER == \"Y\" & AEREL1 == \"Y\", \"No. of patients with serious AE related to study drug 1\"),\n REL2SER = with_label(AESER == \"Y\" & AEREL2 == \"Y\", \"No. of patients with serious AE related to study drug 2\")\n )\n\nadae_mult <- adae_mult %>%\n mutate(AETOXGR = forcats::fct_recode(\n AETOXGR,\n \"Grade 1\" = \"1\",\n \"Grade 2\" = \"2\",\n \"Grade 3\" = \"3\",\n \"Grade 4\" = \"4\",\n \"Grade 5 (fatal outcome)\" = \"5\"\n ))\n\naesi_vars <- c(\"WD1\", \"WD2\", \"DSM1\", \"DSM2\", \"CONTRT\")\naesi_res <- c(\"ALL_RESOLVED\", \"ALL_RESOLVED_WD1\", \"ALL_RESOLVED_WD2\", \"ALL_RESOLVED_DSM1\", \"ALL_RESOLVED_DSM2\", \"ALL_RESOLVED_CONTRT\")\naesi_not_res <- c(\"NOT_RESOLVED\", \"NOT_RESOLVED_WD1\", \"NOT_RESOLVED_WD2\", \"NOT_RESOLVED_DSM1\", \"NOT_RESOLVED_DSM2\", \"NOT_RESOLVED_CONTRT\")\naesi_ser <- c(\"SER\", \"SERWD1\", \"SERWD2\", \"SERDSM1\", \"SERDSM2\", \"SERCONTRT\")\naesi_rel1 <- c(\"REL1\", \"REL1WD1\", \"REL1WD2\", \"REL1DSM1\", \"REL1DSM2\", \"REL1CONTRT\", \"REL1SER\")\naesi_rel2 <- c(\"REL2\", \"REL2WD1\", \"REL2WD2\", \"REL2DSM1\", \"REL2DSM2\", \"REL2CONTRT\", \"REL2SER\")\n\nlyt_adae_mult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n vars = \"USUBJID\",\n filters = c(\"ANL01FL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients with at least one AE\")\n ) %>%\n count_values(\n \"ANL01FL\",\n values = \"Y\",\n .stats = \"count\",\n .labels = c(count = \"Total number of AEs\"),\n table_names = \"total_aes\"\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n var_labels = \"Total number of patients with at least one AE by worst grade\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = c(aesi_vars, aesi_res[1]), denom = \"N_col\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_res[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_res\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_not_res[1], denom = \"N_col\", table_names = \"fl_notres_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_not_res[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_notres\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_ser[1], denom = \"N_col\", table_names = \"fl_ser_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_ser[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_ser\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel1[1], denom = \"N_col\", table_names = \"fl_rel1_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel1[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_rel1\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel2[1], denom = \"N_col\", table_names = \"fl_rel2_main\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_rel2[-1], denom = \"N_col\", .indent_mods = 1L, table_names = \"fl_rel2\"\n )\n\nresult <- build_table(lyt_adae_mult, df = adae_mult, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of patients with at least one AE by worst grade \n Grade 1 5 (3.7%) 7 (5.2%) 4 (3.0%) \n Grade 2 5 (3.7%) 8 (6.0%) 6 (4.5%) \n Grade 3 13 (9.7%) 13 (9.7%) 14 (10.6%) \n Grade 4 13 (9.7%) 18 (13.4%) 15 (11.4%) \n Grade 5 (fatal outcome) 64 (47.8%) 52 (38.8%) 64 (48.5%) \nTotal number of patients with study drug 1 withdrawn due to AE 22 (16.4%) 21 (15.7%) 28 (21.2%) \nTotal number of patients with study drug 2 withdrawn due to AE 22 (16.4%) 21 (15.7%) 28 (21.2%) \nTotal number of patients with dose of study drug 1 modified/interrupted due to AE 55 (41.0%) 62 (46.3%) 64 (48.5%) \nTotal number of patients with dose of study drug 2 modified/interrupted due to AE 55 (41.0%) 62 (46.3%) 64 (48.5%) \nTotal number of patients with treatment received for AE 80 (59.7%) 80 (59.7%) 89 (67.4%) \nTotal number of patients with all non-fatal AEs resolved 17 (12.7%) 12 (9.0%) 11 (8.3%) \n No. of patients with study drug 1 withdrawn due to resolved AE 0 1 (0.7%) 2 (1.5%) \n No. of patients with study drug 2 withdrawn due to resolved AE 0 1 (0.7%) 2 (1.5%) \n No. of patients with dose of study drug 1 modified/interrupted due to resolved AE 3 (2.2%) 4 (3.0%) 2 (1.5%) \n No. of patients with dose of study drug 2 modified/interrupted due to resolved AE 3 (2.2%) 4 (3.0%) 2 (1.5%) \n No. of patients with treatment received for resolved AE 9 (6.7%) 7 (5.2%) 7 (5.3%) \nTotal number of patients with at least one non-fatal unresolved or ongoing AE 83 (61.9%) 86 (64.2%) 92 (69.7%) \n No. of patients with study drug 1 withdrawn due to unresolved or ongoing AE 22 (16.4%) 20 (14.9%) 26 (19.7%) \n No. of patients with study drug 2 withdrawn due to unresolved or ongoing AE 22 (16.4%) 20 (14.9%) 26 (19.7%) \n No. of patients with dose of study drug 1 modified/interrupted due to unresolved or ongoing AE 52 (38.8%) 58 (43.3%) 62 (47.0%) \n No. of patients with dose of study drug 2 modified/interrupted due to unresolved or ongoing AE 52 (38.8%) 58 (43.3%) 62 (47.0%) \n No. of patients with treatment received for unresolved or ongoing AE 71 (53.0%) 73 (54.5%) 82 (62.1%) \nTotal number of patients with at least one serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n No. of patients with study drug 1 withdrawn due to serious AE 9 (6.7%) 4 (3.0%) 10 (7.6%) \n No. of patients with study drug 2 withdrawn due to serious AE 9 (6.7%) 4 (3.0%) 10 (7.6%) \n No. of patients with dose of study drug 1 modified/interrupted due to serious AE 21 (15.7%) 22 (16.4%) 28 (21.2%) \n No. of patients with dose of study drug 2 modified/interrupted due to serious AE 21 (15.7%) 22 (16.4%) 28 (21.2%) \n No. of patients with treatment received for serious AE 59 (44.0%) 58 (43.3%) 53 (40.2%) \nTotal number of patients with at least one AE related to study drug 1 86 (64.2%) 85 (63.4%) 92 (69.7%) \n No. of patients with study drug 1 withdrawn due to AE related to study drug 1 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with study drug 1 withdrawn due to AE related to study drug 2 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with dose of study drug 1 modified/interrupted due to AE related to study drug 1 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with dose of study drug 1 modified/interrupted due to AE related to study drug 2 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with treatment received for AE related to study drug 1 53 (39.6%) 58 (43.3%) 60 (45.5%) \n No. of patients with serious AE related to study drug 1 64 (47.8%) 52 (38.8%) 64 (48.5%) \nTotal number of patients with at least one AE related to study drug 2 86 (64.2%) 85 (63.4%) 92 (69.7%) \n No. of patients with study drug 2 withdrawn due to AE related to study drug 1 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with study drug 2 withdrawn due to AE related to study drug 2 5 (3.7%) 10 (7.5%) 7 (5.3%) \n No. of patients with dose of study drug 2 modified/interrupted due to AE related to study drug 1 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with dose of study drug 2 modified/interrupted due to AE related to study drug 2 24 (17.9%) 32 (23.9%) 34 (25.8%) \n No. of patients with treatment received for AE related to study drug 2 53 (39.6%) 58 (43.3%) 60 (45.5%) \n No. of patients with serious AE related to study drug 2 64 (47.8%) 52 (38.8%) 64 (48.5%) \n\n\n\n\n\nCodeadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadsl <- filter(adsl, SAFFL == \"Y\")\nadae <- filter(adae, ANL01FL == \"Y\" & SAFFL == \"Y\")\n\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nstack_adae_by_smq <- function(adae, smq) {\n adae_labels <- c(var_labels(adae), \"Standardized MedDRA Query\")\n l_df <- lapply(smq, function(ae_grp) {\n ae_scope <- gsub(\"NAM\", \"SC\", ae_grp)\n keep <- adae[[ae_grp]] != \"<Missing>\"\n df <- adae[keep, ]\n if (substr(ae_grp, 1, 3) == \"SMQ\") {\n df[[\"SMQ\"]] <- aesi_label(as.character(df[[ae_grp]]), scope = as.character(df[[ae_scope]]))\n } else {\n df[[\"SMQ\"]] <- df[[ae_grp]]\n }\n df\n })\n result <- do.call(rbind, l_df)\n var_labels(result) <- adae_labels\n result\n}\n\nadae_smq <- stack_adae_by_smq(adae, c(\"SMQ01NAM\", \"SMQ02NAM\", \"CQ01NAM\"))\n\nnot_resolved <- adae_smq %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>%\n mutate(NOT_RESOLVED = \"Y\")\n\nadae_smq <- adae_smq %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"Total number of patients with all non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"Total number of patients with at least one non-fatal unresolved or ongoing AE\")\n )\n\nadae_smq <- adae_smq %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"Total number of patients with study drug withdrawn due to AE\"),\n DSM = with_label(\n AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Total number of patients with dose modified/interrupted due to AE\"\n ),\n CONTRT = with_label(AECONTRT == \"Y\", \"Total number of patients with treatment received for AE\"),\n SER = with_label(AESER == \"Y\", \"Total number of patients with at least one serious AE\"),\n REL = with_label(AEREL == \"Y\", \"Total number of patients with at least one related AE\"),\n ALL_RESOLVED_WD = with_label(WD == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with study drug withdrawn due to resolved AE\"),\n ALL_RESOLVED_DSM = with_label(DSM == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with dose modified/interrupted due to resolved AE\"),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"No. of patients with treatment received for resolved AE\"),\n NOT_RESOLVED_WD = with_label(WD == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with study drug withdrawn due to unresolved or ongoing AE\"),\n NOT_RESOLVED_DSM = with_label(DSM == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with dose modified/interrupted due to unresolved or ongoing AE\"),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"No. of patients with treatment received for unresolved or ongoing AE\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"No. of patients with study drug withdrawn due to serious AE\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"No. of patients with treatment received for serious AE\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose modified/interrupted due to serious AE\"\n ),\n RELWD = with_label(AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"No. of patients with study drug withdrawn due to related AE\"),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"No. of patients with dose modified/interrupted due to related AE\"\n ),\n RELCONTRT = with_label(AECONTRT == \"Y\" & AEREL == \"Y\", \"No. of patients with treatment received for related AE\"),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"No. of patients with serious, related AE\")\n )\n\nadae_smq <- adae_smq %>%\n mutate(\n AETOXGR = forcats::fct_recode(AETOXGR,\n \"Grade 1\" = \"1\",\n \"Grade 2\" = \"2\",\n \"Grade 3\" = \"3\",\n \"Grade 4\" = \"4\",\n \"Grade 5 (fatal outcome)\" = \"5\"\n )\n )\n\nsplit_fun <- remove_split_levels(\"<Missing>\")\naesi_vars <- c(\"WD\", \"DSM\", \"CONTRT\", \"ALL_RESOLVED\", \"NOT_RESOLVED\", \"SER\", \"REL\")\n\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n split_fun = split_fun,\n split_label = \"Standardized MedDRA Query\",\n label_pos = \"topleft\"\n ) %>%\n count_patients_with_event(\n vars = \"USUBJID\",\n filters = c(\"ANL01FL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients with at least one AE\")\n ) %>%\n count_values(\n \"ANL01FL\",\n values = \"Y\",\n .stats = \"count\",\n .labels = c(count = \"Total number of AEs\"),\n table_names = \"total_aes\"\n ) %>%\n count_occurrences_by_grade(\n var = \"AETOXGR\",\n var_labels = \"Total number of patients with at least one AE by worst grade\",\n .show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\"USUBJID\", flag_variables = aesi_vars, denom = \"N_col\")\n\nresult <- build_table(lyt_adae, df = adae_smq, alt_counts_df = adsl)\nresult\n\nStandardized MedDRA Query A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nC.1.1.1.3/B.2.2.3.1 AESI (BROAD) \n Total number of patients with at least one AE 58 (43.3%) 60 (44.8%) 66 (50.0%) \n Total number of AEs 97 106 122 \n Total number of patients with at least one AE by worst grade \n Grade 1 22 (16.4%) 26 (19.4%) 30 (22.7%) \n Grade 2 0 0 0 \n Grade 3 0 0 0 \n Grade 4 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Grade 5 (fatal outcome) 0 0 0 \n Total number of patients with study drug withdrawn due to AE 5 (3.7%) 6 (4.5%) 9 (6.8%) \n Total number of patients with dose modified/interrupted due to AE 21 (15.7%) 21 (15.7%) 24 (18.2%) \n Total number of patients with treatment received for AE 32 (23.9%) 35 (26.1%) 44 (33.3%) \n Total number of patients with all non-fatal AEs resolved 7 (5.2%) 9 (6.7%) 8 (6.1%) \n Total number of patients with at least one non-fatal unresolved or ongoing AE 51 (38.1%) 51 (38.1%) 58 (43.9%) \n Total number of patients with at least one serious AE 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Total number of patients with at least one related AE 36 (26.9%) 34 (25.4%) 36 (27.3%) \nD.2.1.5.3/A.1.1.1.1 AESI \n Total number of patients with at least one AE 62 (46.3%) 61 (45.5%) 76 (57.6%) \n Total number of AEs 106 100 139 \n Total number of patients with at least one AE by worst grade \n Grade 1 62 (46.3%) 61 (45.5%) 76 (57.6%) \n Grade 2 0 0 0 \n Grade 3 0 0 0 \n Grade 4 0 0 0 \n Grade 5 (fatal outcome) 0 0 0 \n Total number of patients with study drug withdrawn due to AE 6 (4.5%) 8 (6.0%) 4 (3.0%) \n Total number of patients with dose modified/interrupted due to AE 23 (17.2%) 20 (14.9%) 26 (19.7%) \n Total number of patients with treatment received for AE 33 (24.6%) 37 (27.6%) 33 (25.0%) \n Total number of patients with all non-fatal AEs resolved 4 (3.0%) 5 (3.7%) 14 (10.6%) \n Total number of patients with at least one non-fatal unresolved or ongoing AE 58 (43.3%) 56 (41.8%) 62 (47.0%) \n Total number of patients with at least one serious AE 0 0 0 \n Total number of patients with at least one related AE 37 (27.6%) 46 (34.3%) 50 (37.9%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\nadae <- filter(adae, ANL01FL == \"Y\" & SAFFL == \"Y\")\n\nnot_resolved <- adae %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>%\n mutate(NOT_RESOLVED = \"Y\")\n\nadae <- adae %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"All non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"At least one non-fatal unresolved or ongoing AE\")\n )\n\nadae <- adae %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"AE that led to study drug withdrawal\"),\n DSM = with_label(AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"AE that led to study drug dose modified/interrupted\"),\n CONTRT = with_label(AECONTRT == \"Y\", \"AE that required treatment\"),\n SER = with_label(AESER == \"Y\", \"Serious AE\"),\n REL = with_label(AEREL == \"Y\", \"Related AE\"),\n ALL_RESOLVED_WD = with_label(WD == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that led to study drug withdrawal\"),\n ALL_RESOLVED_DSM = with_label(DSM == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that led to study drug dose modified/interrupted\"),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that required treatment\"),\n NOT_RESOLVED_WD = with_label(WD == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that led to study drug withdrawal\"),\n NOT_RESOLVED_DSM = with_label(DSM == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that led to study drug dose modified/interrupted\"),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that required treatment\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Serious AE that led to study drug withdrawal\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"Serious AE that required treatment\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Serious AE that led to study drug dose modified/interrupted\"\n ),\n RELWD = with_label(\n AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Related AE that led to study drug withdrawal\"\n ),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Related AE that led to study drug dose modified/interrupted\"\n ),\n RELCONTRT = with_label(AECONTRT == \"Y\" & AEREL == \"Y\", \"Related AE that required treatment\"),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"Serious related AE\")\n )\n\naesi_vars <- c(\n \"WD\", \"DSM\", \"CONTRT\", \"ALL_RESOLVED_WD\", \"ALL_RESOLVED_DSM\", \"ALL_RESOLVED_CONTRT\",\n \"NOT_RESOLVED_WD\", \"NOT_RESOLVED_DSM\", \"NOT_RESOLVED_CONTRT\", \"SER\", \"SERWD\", \"SERDSM\",\n \"SERCONTRT\", \"REL\", \"RELWD\", \"RELDSM\", \"RELCONTRT\", \"RELSER\"\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n ADAE <- filter(ADAE, ANL01FL == \"Y\" & SAFFL == \"Y\")\n not_resolved <- ADAE %>%\n filter(!(AEOUT %in% c(\"RECOVERED/RESOLVED\", \"FATAL\", \"RECOVERED/RESOLVED WITH SEQUELAE\"))) %>%\n distinct(USUBJID) %>% mutate(NOT_RESOLVED = \"Y\")\n\n ADAE <- ADAE %>%\n left_join(not_resolved, by = c(\"USUBJID\")) %>%\n mutate(\n ALL_RESOLVED = with_label(is.na(NOT_RESOLVED), \"All non-fatal AEs resolved\"),\n NOT_RESOLVED = with_label(!is.na(NOT_RESOLVED), \"At least one non-fatal unresolved or ongoing AE\")\n )\n\n ADAE <- ADAE %>%\n mutate(\n AEDECOD = as.character(AEDECOD),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"AE that led to study drug withdrawal\"),\n DSM = with_label(AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"AE that led to study drug dose modified/interrupted\"),\n CONTRT = with_label(AECONTRT == \"Y\", \"AE that required treatment\"),\n SER = with_label(AESER == \"Y\", \"Serious AE\"),\n REL = with_label(AEREL == \"Y\", \"Related AE\"),\n ALL_RESOLVED_WD = with_label(WD == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that led to study drug withdrawal\"),\n ALL_RESOLVED_DSM = with_label(DSM == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that led to study drug dose modified/interrupted\"),\n ALL_RESOLVED_CONTRT = with_label(CONTRT == TRUE & ALL_RESOLVED == TRUE, \"Resolved AE that required treatment\"),\n NOT_RESOLVED_WD = with_label(WD == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that led to study drug withdrawal\"),\n NOT_RESOLVED_DSM = with_label(DSM == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that led to study drug dose modified/interrupted\"),\n NOT_RESOLVED_CONTRT = with_label(CONTRT == TRUE & NOT_RESOLVED == TRUE, \"Unresolved AE that required treatment\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Serious AE that led to study drug withdrawal\"),\n SERCONTRT = with_label(AECONTRT == \"Y\" & AESER == \"Y\", \"Serious AE that required treatment\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Serious AE that led to study drug dose modified/interrupted\"\n ),\n RELWD = with_label(\n AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Related AE that led to study drug withdrawal\"\n ),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"Related AE that led to study drug dose modified/interrupted\"\n ),\n RELCONTRT = with_label(AECONTRT == \"Y\" & AEREL == \"Y\", \"Related AE that required treatment\"),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"Serious related AE\")\n )'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events_summary(\n label = \"Adverse Events Summary\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(\"ADSL\", c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n flag_var_anl = choices_selected(\n choices = variable_choices(\"ADAE\", aesi_vars),\n selected = aesi_vars[1],\n keep_order = TRUE,\n fixed = FALSE\n ),\n add_total = TRUE\n )\n )\n)\n\n[INFO] 2023-09-09 18:04:42.5432 pid:5697 token:[] teal.modules.clinical Initializing tm_t_events_summary\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet05.html",
"href": "tables/adverse-events/aet05.html",
"title": "AET05",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Setting Type of Confidence Interval\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadaette <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadaette <- df_explicit_na(adaette)\n\nanl <- adaette %>%\n dplyr::filter(PARAM == \"Time to first occurrence of any adverse event\") %>%\n dplyr::mutate(is_event = CNSR == 0) %>%\n dplyr::mutate(n_events = as.integer(is_event))\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n estimate_incidence_rate(\n vars = \"AVAL\",\n n_events = \"n_events\",\n control = control_incidence_rate(num_pt_year = 100)\n )\n\nresult <- build_table(lyt, anl, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\nTotal patient-years at risk 162.4 103.9 172.6 \nNumber of adverse events observed 78 104 67 \nAE rate per 100 patient-years 48.03 100.14 38.82 \n95% CI (37.37, 58.69) (80.89, 119.38) (29.53, 48.12)\n\n\n\n\nThe type of confidence interval can be specified through the conf_type argument.\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n estimate_incidence_rate(\n vars = \"AVAL\",\n n_events = \"n_events\",\n control = control_incidence_rate(\n conf_level = 0.95,\n conf_type = \"exact\",\n num_pt_year = 100\n )\n )\n\nresult <- build_table(lyt, anl, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\nTotal patient-years at risk 162.4 103.9 172.6 \nNumber of adverse events observed 78 104 67 \nAE rate per 100 patient-years 48.03 100.14 38.82 \n95% CI (37.97, 59.94) (81.82, 121.34) (30.09, 49.30)\n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadaette <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadaette <- df_explicit_na(adaette)\n\nadaette <- adaette %>%\n dplyr::filter(PARAMCD %in% c(\"AETTE1\", \"AETTE2\", \"AETTE3\")) %>%\n dplyr::mutate(is_event = CNSR == 0) %>%\n dplyr::mutate(n_events = as.integer(is_event))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAETTE\", adaette),\n code =\n 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\n ADAETTE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adaette\"))\n ADAETTE <- ADAETTE %>%\n dplyr::filter(PARAMCD %in% c(\"AETTE1\", \"AETTE2\", \"AETTE3\")) %>%\n dplyr::mutate(is_event = CNSR == 0) %>%\n dplyr::mutate(n_events = as.integer(is_event))',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_patyear(\n label = \"AE rate adjusted for patient-years at risk Table\",\n dataname = \"ADAETTE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARMCD\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adaette, \"PARAMCD\", \"PARAM\"),\n selected = \"AETTE1\"\n ),\n events_var = choices_selected(\n choices = variable_choices(adaette, \"n_events\"),\n selected = \"n_events\",\n fixed = TRUE\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:43:48.3150 pid:5496 token:[] teal.modules.clinical Initializing tm_t_events_patyear\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] scda_0.1.6.9012 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Setting Type of Confidence Interval\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadaette <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadaette <- df_explicit_na(adaette)\n\nanl <- adaette %>%\n dplyr::filter(PARAM == \"Time to first occurrence of any adverse event\") %>%\n dplyr::mutate(is_event = CNSR == 0) %>%\n dplyr::mutate(n_events = as.integer(is_event))\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n estimate_incidence_rate(\n vars = \"AVAL\",\n n_events = \"n_events\",\n control = control_incidence_rate(num_pt_year = 100)\n )\n\nresult <- build_table(lyt, anl, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\nTotal patient-years at risk 162.4 103.9 172.6 \nNumber of adverse events observed 78 104 67 \nAE rate per 100 patient-years 48.03 100.14 38.82 \n95% CI (37.37, 58.69) (80.89, 119.38) (29.53, 48.12)\n\n\n\n\nThe type of confidence interval can be specified through the conf_type argument.\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n estimate_incidence_rate(\n vars = \"AVAL\",\n n_events = \"n_events\",\n control = control_incidence_rate(\n conf_level = 0.95,\n conf_type = \"exact\",\n num_pt_year = 100\n )\n )\n\nresult <- build_table(lyt, anl, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\nTotal patient-years at risk 162.4 103.9 172.6 \nNumber of adverse events observed 78 104 67 \nAE rate per 100 patient-years 48.03 100.14 38.82 \n95% CI (37.97, 59.94) (81.82, 121.34) (30.09, 49.30)\n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadaette <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadaette <- df_explicit_na(adaette)\n\nadaette <- adaette %>%\n dplyr::filter(PARAMCD %in% c(\"AETTE1\", \"AETTE2\", \"AETTE3\")) %>%\n dplyr::mutate(is_event = CNSR == 0) %>%\n dplyr::mutate(n_events = as.integer(is_event))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAETTE\", adaette),\n code =\n 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\n ADAETTE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adaette\"))\n ADAETTE <- ADAETTE %>%\n dplyr::filter(PARAMCD %in% c(\"AETTE1\", \"AETTE2\", \"AETTE3\")) %>%\n dplyr::mutate(is_event = CNSR == 0) %>%\n dplyr::mutate(n_events = as.integer(is_event))',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_patyear(\n label = \"AE rate adjusted for patient-years at risk Table\",\n dataname = \"ADAETTE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARMCD\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adaette, \"PARAMCD\", \"PARAM\"),\n selected = \"AETTE1\"\n ),\n events_var = choices_selected(\n choices = variable_choices(adaette, \"n_events\"),\n selected = \"n_events\",\n fixed = TRUE\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:03:33.7099 pid:5501 token:[] teal.modules.clinical Initializing tm_t_events_patyear\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] scda_0.1.6.9012 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet03.html",
"href": "tables/adverse-events/aet03.html",
"title": "AET03",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae) %>%\n var_relabel(\n AEBODSYS = \"MedDRA System Organ Class\",\n AEDECOD = \"MedDRA Preferred Term\"\n ) %>%\n filter(ANL01FL == \"Y\")\n\n\nFor illustrative purposes, we will create a new factor variable in ADAE, ASEV, with all intensity levels including \"LIFE THREATENING\".\n\nCodeadae <- adae %>% mutate(ASEV = as.character(AESEV))\nadae$ASEV[1:15] <- \"LIFE THREATENING\"\nadae <- adae %>% mutate(ASEV = factor(ASEV, levels = c(\"MILD\", \"MODERATE\", \"SEVERE\", \"LIFE THREATENING\")))\n\n\n\n\n\nCodegrade_groups <- list(\"- Any Intensity -\" = c(\"MILD\", \"MODERATE\", \"SEVERE\", \"LIFE THREATENING\"))\n\nsplit_fun <- trim_levels_in_group\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_occurrences_by_grade(\n var = \"ASEV\",\n grade_groups = grade_groups\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun(\"ASEV\"),\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_occurrences_by_grade(\n var = \"ASEV\",\n grade_groups = grade_groups\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n nested = TRUE,\n indent_mod = -1L,\n split_fun = split_fun(\"ASEV\"),\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEDECOD)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = c(\"- Any Intensity -\")\n ) %>%\n count_occurrences_by_grade(\n var = \"ASEV\",\n .indent_mods = -1L\n ) %>%\n append_varlabels(adae, \"AESEV\", indent = 2L)\n\nresult <- lyt %>%\n build_table(\n adae,\n alt_counts_df = adsl\n ) %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = cont_n_allcols,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = cont_n_allcols,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Severity/Intensity (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————\n- Any Intensity - 100 (74.6%) 98 (73.1%) 103 (78.0%) \nMILD 5 (3.7%) 7 (5.2%) 4 (3.0%) \nMODERATE 17 (12.7%) 21 (15.7%) 20 (15.2%) \nSEVERE 77 (57.5%) 69 (51.5%) 77 (58.3%) \nLIFE THREATENING 1 (0.7%) 1 (0.7%) 2 (1.5%) \ncl A.1 \n - Any Intensity - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n MILD 27 (20.1%) 19 (14.2%) 34 (25.8%) \n MODERATE 40 (29.9%) 39 (29.1%) 41 (31.1%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \n dcd A.1.1.1.1 \n - Any Intensity - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n MILD 45 (33.6%) 31 (23.1%) 51 (38.6%) \n LIFE THREATENING 0 0 1 (0.8%) \n dcd A.1.1.1.2 \n - Any Intensity - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n MODERATE 40 (29.9%) 39 (29.1%) 41 (31.1%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \ncl B.2 \n - Any Intensity - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n MILD 23 (17.2%) 22 (16.4%) 28 (21.2%) \n MODERATE 38 (28.4%) 34 (25.4%) 45 (34.1%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \n dcd B.2.2.3.1 \n - Any Intensity - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n MILD 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Intensity - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n MODERATE 38 (28.4%) 34 (25.4%) 45 (34.1%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \ncl D.1 \n - Any Intensity - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n MODERATE 21 (15.7%) 22 (16.4%) 22 (16.7%) \n SEVERE 42 (31.3%) 32 (23.9%) 44 (33.3%) \n LIFE THREATENING 1 (0.7%) 0 2 (1.5%) \n dcd D.1.1.1.1 \n - Any Intensity - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n SEVERE 42 (31.3%) 32 (23.9%) 45 (34.1%) \n LIFE THREATENING 0 0 1 (0.8%) \n dcd D.1.1.4.2 \n - Any Intensity - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n MODERATE 37 (27.6%) 34 (25.4%) 39 (29.5%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \ncl D.2 \n - Any Intensity - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n MILD 37 (27.6%) 46 (34.3%) 49 (37.1%) \n LIFE THREATENING 0 0 1 (0.8%) \n dcd D.2.1.5.3 \n - Any Intensity - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n MILD 37 (27.6%) 46 (34.3%) 49 (37.1%) \n LIFE THREATENING 0 0 1 (0.8%) \ncl C.2 \n - Any Intensity - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n MODERATE 28 (20.9%) 36 (26.9%) 47 (35.6%) \n LIFE THREATENING 0 0 1 (0.8%) \n dcd C.2.1.2.1 \n - Any Intensity - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n MODERATE 28 (20.9%) 36 (26.9%) 47 (35.6%) \n LIFE THREATENING 0 0 1 (0.8%) \ncl B.1 \n - Any Intensity - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n SEVERE 38 (28.4%) 36 (26.9%) 36 (27.3%) \n LIFE THREATENING 0 1 (0.7%) 0 \n dcd B.1.1.1.1 \n - Any Intensity - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n SEVERE 38 (28.4%) 36 (26.9%) 36 (27.3%) \n LIFE THREATENING 0 1 (0.7%) 0 \ncl C.1 \n - Any Intensity - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n SEVERE 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Intensity - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n SEVERE 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAE\", adae),\n code =\n 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_by_grade(\n label = \"Adverse Events by Grade Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n grade = choices_selected(\n choices = variable_choices(adae, c(\"AETOXGR\", \"AESEV\")),\n selected = \"AESEV\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:42:41.8261 pid:5300 token:[] teal.modules.clinical Initializing tm_t_events_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae) %>%\n var_relabel(\n AEBODSYS = \"MedDRA System Organ Class\",\n AEDECOD = \"MedDRA Preferred Term\"\n ) %>%\n filter(ANL01FL == \"Y\")\n\n\nFor illustrative purposes, we will create a new factor variable in ADAE, ASEV, with all intensity levels including \"LIFE THREATENING\".\n\nCodeadae <- adae %>% mutate(ASEV = as.character(AESEV))\nadae$ASEV[1:15] <- \"LIFE THREATENING\"\nadae <- adae %>% mutate(ASEV = factor(ASEV, levels = c(\"MILD\", \"MODERATE\", \"SEVERE\", \"LIFE THREATENING\")))\n\n\n\n\n\nCodegrade_groups <- list(\"- Any Intensity -\" = c(\"MILD\", \"MODERATE\", \"SEVERE\", \"LIFE THREATENING\"))\n\nsplit_fun <- trim_levels_in_group\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_occurrences_by_grade(\n var = \"ASEV\",\n grade_groups = grade_groups\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun(\"ASEV\"),\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_occurrences_by_grade(\n var = \"ASEV\",\n grade_groups = grade_groups\n ) %>%\n split_rows_by(\n \"AEDECOD\",\n child_labels = \"visible\",\n nested = TRUE,\n indent_mod = -1L,\n split_fun = split_fun(\"ASEV\"),\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEDECOD)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = c(\"- Any Intensity -\")\n ) %>%\n count_occurrences_by_grade(\n var = \"ASEV\",\n .indent_mods = -1L\n ) %>%\n append_varlabels(adae, \"AESEV\", indent = 2L)\n\nresult <- lyt %>%\n build_table(\n adae,\n alt_counts_df = adsl\n ) %>%\n sort_at_path(\n path = \"AEBODSYS\",\n scorefun = cont_n_allcols,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = cont_n_allcols,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA System Organ Class \n MedDRA Preferred Term A: Drug X B: Placebo C: Combination\n Severity/Intensity (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————\n- Any Intensity - 100 (74.6%) 98 (73.1%) 103 (78.0%) \nMILD 5 (3.7%) 7 (5.2%) 4 (3.0%) \nMODERATE 17 (12.7%) 21 (15.7%) 20 (15.2%) \nSEVERE 77 (57.5%) 69 (51.5%) 77 (58.3%) \nLIFE THREATENING 1 (0.7%) 1 (0.7%) 2 (1.5%) \ncl A.1 \n - Any Intensity - 68 (50.7%) 58 (43.3%) 76 (57.6%) \n MILD 27 (20.1%) 19 (14.2%) 34 (25.8%) \n MODERATE 40 (29.9%) 39 (29.1%) 41 (31.1%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \n dcd A.1.1.1.1 \n - Any Intensity - 45 (33.6%) 31 (23.1%) 52 (39.4%) \n MILD 45 (33.6%) 31 (23.1%) 51 (38.6%) \n LIFE THREATENING 0 0 1 (0.8%) \n dcd A.1.1.1.2 \n - Any Intensity - 41 (30.6%) 39 (29.1%) 42 (31.8%) \n MODERATE 40 (29.9%) 39 (29.1%) 41 (31.1%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \ncl B.2 \n - Any Intensity - 62 (46.3%) 56 (41.8%) 74 (56.1%) \n MILD 23 (17.2%) 22 (16.4%) 28 (21.2%) \n MODERATE 38 (28.4%) 34 (25.4%) 45 (34.1%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \n dcd B.2.2.3.1 \n - Any Intensity - 38 (28.4%) 40 (29.9%) 45 (34.1%) \n MILD 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 \n - Any Intensity - 39 (29.1%) 34 (25.4%) 46 (34.8%) \n MODERATE 38 (28.4%) 34 (25.4%) 45 (34.1%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \ncl D.1 \n - Any Intensity - 64 (47.8%) 54 (40.3%) 68 (51.5%) \n MODERATE 21 (15.7%) 22 (16.4%) 22 (16.7%) \n SEVERE 42 (31.3%) 32 (23.9%) 44 (33.3%) \n LIFE THREATENING 1 (0.7%) 0 2 (1.5%) \n dcd D.1.1.1.1 \n - Any Intensity - 42 (31.3%) 32 (23.9%) 46 (34.8%) \n SEVERE 42 (31.3%) 32 (23.9%) 45 (34.1%) \n LIFE THREATENING 0 0 1 (0.8%) \n dcd D.1.1.4.2 \n - Any Intensity - 38 (28.4%) 34 (25.4%) 40 (30.3%) \n MODERATE 37 (27.6%) 34 (25.4%) 39 (29.5%) \n LIFE THREATENING 1 (0.7%) 0 1 (0.8%) \ncl D.2 \n - Any Intensity - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n MILD 37 (27.6%) 46 (34.3%) 49 (37.1%) \n LIFE THREATENING 0 0 1 (0.8%) \n dcd D.2.1.5.3 \n - Any Intensity - 37 (27.6%) 46 (34.3%) 50 (37.9%) \n MILD 37 (27.6%) 46 (34.3%) 49 (37.1%) \n LIFE THREATENING 0 0 1 (0.8%) \ncl C.2 \n - Any Intensity - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n MODERATE 28 (20.9%) 36 (26.9%) 47 (35.6%) \n LIFE THREATENING 0 0 1 (0.8%) \n dcd C.2.1.2.1 \n - Any Intensity - 28 (20.9%) 36 (26.9%) 48 (36.4%) \n MODERATE 28 (20.9%) 36 (26.9%) 47 (35.6%) \n LIFE THREATENING 0 0 1 (0.8%) \ncl B.1 \n - Any Intensity - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n SEVERE 38 (28.4%) 36 (26.9%) 36 (27.3%) \n LIFE THREATENING 0 1 (0.7%) 0 \n dcd B.1.1.1.1 \n - Any Intensity - 38 (28.4%) 37 (27.6%) 36 (27.3%) \n SEVERE 38 (28.4%) 36 (26.9%) 36 (27.3%) \n LIFE THREATENING 0 1 (0.7%) 0 \ncl C.1 \n - Any Intensity - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n SEVERE 36 (26.9%) 34 (25.4%) 36 (27.3%) \n dcd C.1.1.1.3 \n - Any Intensity - 36 (26.9%) 34 (25.4%) 36 (27.3%) \n SEVERE 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAE\", adae),\n code =\n 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_by_grade(\n label = \"Adverse Events by Grade Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n grade = choices_selected(\n choices = variable_choices(adae, c(\"AETOXGR\", \"AESEV\")),\n selected = \"AESEV\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:02:10.3187 pid:5305 token:[] teal.modules.clinical Initializing tm_t_events_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet02_smq.html",
"href": "tables/adverse-events/aet02_smq.html",
"title": "AET02_SMQ",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Customized Queries\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(stringr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\n# Simulate a random AAG dataset.\naag <- data.frame(\n NAMVAR = c(\"SMQ01NAM\", \"SMQ01NAM\", \"SMQ02NAM\", \"CQ01NAM\", \"CQ01NAM\"),\n SRCVAR = rep(\"AEDECOD\", 5),\n GRPTYPE = c(\"SMQ\", \"SMQ\", \"SMQ\", \"CUSTOM\", \"CUSTOM\"),\n REFID = c(1, 1, 2, 3, 3),\n REFNAME = c(rep(\"C.1.1.1.3/B.2.2.3.1 AESI\", 2), \"non observed SMQ02NAM level\", rep(\"D.2.1.5.3/A.1.1.1.1 AESI\", 2)),\n SCOPE = c(\"BROAD\", \"BROAD\", \"BROAD\", \"\", \"\"),\n REFTERM = c(\"C.1.1.1.3\", \"B.2.2.3.1\", \"Z.9.9.9.9\", \"D.2.1.5.3\", \"A.1.1.1.1\"),\n stringsAsFactors = FALSE\n)\n\n# Create summary AAG dataset (used for labelling).\n# Note it's important to incorporate SCOPE into the basket names for SMQs so as to\n# match the flags present in ADAE.\naag_summary <- aag %>%\n select(NAMVAR, REFNAME, SCOPE) %>%\n unique() %>%\n mutate(\n REFNAME_SCOPE = ifelse(SCOPE == \"\", REFNAME, paste0(REFNAME, \"(\", SCOPE, \")\"))\n ) %>%\n rename(basket = NAMVAR, basket_name = REFNAME_SCOPE) %>%\n select(basket, basket_name)\n\n# Make a summary of the full ADAE based on AAG by using h_stack_by_baskets helper function\nadae_smq_all <- h_stack_by_baskets(df = adae, aag_summary = aag_summary, keys = c(\"STUDYID\", \"USUBJID\", \"ACTARMCD\", \"AEDECOD\"))\n\n# Post-process adae_smq_all to keep only certain baskets of interest for variant 1\n# Not need to drop baskets for variant 2 as all baskets will be considered.\nbaskets_to_drop_variant <- aag_summary$basket_name[!aag_summary$basket %in% c(\"SMQ01NAM\")]\n\n# Adjust the analysis dataset based on basket subset for variant 1.\nadae_smq_1 <- adae_smq_all %>%\n filter(!adae_smq_all$SMQ %in% baskets_to_drop_variant) %>%\n mutate(\n SMQ = tern::fct_discard(SMQ, discard = baskets_to_drop_variant)\n )\n\n\n\n\n\nCodecriteria_fun <- function(tr) !is(tr, \"ContentRow\") && all_zero_or_na(tr)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = -1L,\n drop = FALSE\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt,\n df = adae_smq_1,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%)\n Total number of events 119 139 141 \n dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%)\n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)\n\n\n\n\n\nCodecriteria_fun <- function(tr) {\n !is(tr, \"ContentRow\") && all_zero_or_na(tr) && !grepl(\"Total number of\", obj_label(tr))\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n drop = FALSE\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nscore_ae_pts <- function(tt) {\n count_vals <- cell_values(tree_children(tt)[[\"USUBJID\"]])[[1]]\n sum(matrix(unlist(count_vals), nrow = length(count_vals), byrow = TRUE)[, 1])\n}\n\nresult <- build_table(\n lyt,\n df = adae_smq_all,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = score_ae_pts) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 95 (70.9%) 103 (76.9%) 108 (81.8%)\nD.2.1.5.3/A.1.1.1.1 AESI \n Total number of patients with at least one adverse event 74 (55.2%) 80 (59.7%) 87 (65.9%) \n Total number of events 126 134 162 \n dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) \n dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) \nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%) \n Total number of events 119 139 141 \n dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) \nnon observed SMQ02NAM level(BROAD) \n Total number of patients with at least one adverse event 0 0 0 \n Total number of events 0 0 0 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nnames_baskets <- grep(\"^(SMQ|CQ).*NAM$\", names(adae), value = TRUE)\nnames_scopes <- grep(\"^SMQ.*SC$\", names(adae), value = TRUE)\n\ncs_baskets <- choices_selected(\n choices = variable_choices(adae, subset = names_baskets),\n selected = names_baskets\n)\ncs_scopes <- choices_selected(\n choices = variable_choices(adae, subset = names_scopes),\n selected = names_scopes,\n fixed = TRUE\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'\n ),\n cdisc_dataset(\"ADAE\", adae,\n code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_smq(\n label = \"Adverse events by `SMQ` Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"SEX\")),\n selected = \"ARM\"\n ),\n add_total = FALSE,\n baskets = cs_baskets,\n scopes = cs_scopes,\n llt = choices_selected(\n choices = variable_choices(adae, subset = c(\"AEDECOD\")),\n selected = \"AEDECOD\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:41:32.1045 pid:5104 token:[] teal.modules.clinical Initializing tm_t_smq\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] stringr_1.5.0 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] stringi_1.7.12 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Customized Queries\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(stringr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\n# Simulate a random AAG dataset.\naag <- data.frame(\n NAMVAR = c(\"SMQ01NAM\", \"SMQ01NAM\", \"SMQ02NAM\", \"CQ01NAM\", \"CQ01NAM\"),\n SRCVAR = rep(\"AEDECOD\", 5),\n GRPTYPE = c(\"SMQ\", \"SMQ\", \"SMQ\", \"CUSTOM\", \"CUSTOM\"),\n REFID = c(1, 1, 2, 3, 3),\n REFNAME = c(rep(\"C.1.1.1.3/B.2.2.3.1 AESI\", 2), \"non observed SMQ02NAM level\", rep(\"D.2.1.5.3/A.1.1.1.1 AESI\", 2)),\n SCOPE = c(\"BROAD\", \"BROAD\", \"BROAD\", \"\", \"\"),\n REFTERM = c(\"C.1.1.1.3\", \"B.2.2.3.1\", \"Z.9.9.9.9\", \"D.2.1.5.3\", \"A.1.1.1.1\"),\n stringsAsFactors = FALSE\n)\n\n# Create summary AAG dataset (used for labelling).\n# Note it's important to incorporate SCOPE into the basket names for SMQs so as to\n# match the flags present in ADAE.\naag_summary <- aag %>%\n select(NAMVAR, REFNAME, SCOPE) %>%\n unique() %>%\n mutate(\n REFNAME_SCOPE = ifelse(SCOPE == \"\", REFNAME, paste0(REFNAME, \"(\", SCOPE, \")\"))\n ) %>%\n rename(basket = NAMVAR, basket_name = REFNAME_SCOPE) %>%\n select(basket, basket_name)\n\n# Make a summary of the full ADAE based on AAG by using h_stack_by_baskets helper function\nadae_smq_all <- h_stack_by_baskets(df = adae, aag_summary = aag_summary, keys = c(\"STUDYID\", \"USUBJID\", \"ACTARMCD\", \"AEDECOD\"))\n\n# Post-process adae_smq_all to keep only certain baskets of interest for variant 1\n# Not need to drop baskets for variant 2 as all baskets will be considered.\nbaskets_to_drop_variant <- aag_summary$basket_name[!aag_summary$basket %in% c(\"SMQ01NAM\")]\n\n# Adjust the analysis dataset based on basket subset for variant 1.\nadae_smq_1 <- adae_smq_all %>%\n filter(!adae_smq_all$SMQ %in% baskets_to_drop_variant) %>%\n mutate(\n SMQ = tern::fct_discard(SMQ, discard = baskets_to_drop_variant)\n )\n\n\n\n\n\nCodecriteria_fun <- function(tr) !is(tr, \"ContentRow\") && all_zero_or_na(tr)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = -1L,\n drop = FALSE\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt,\n df = adae_smq_1,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%)\n Total number of events 119 139 141 \n dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%)\n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)\n\n\n\n\n\nCodecriteria_fun <- function(tr) {\n !is(tr, \"ContentRow\") && all_zero_or_na(tr) && !grepl(\"Total number of\", obj_label(tr))\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n drop = FALSE\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nscore_ae_pts <- function(tt) {\n count_vals <- cell_values(tree_children(tt)[[\"USUBJID\"]])[[1]]\n sum(matrix(unlist(count_vals), nrow = length(count_vals), byrow = TRUE)[, 1])\n}\n\nresult <- build_table(\n lyt,\n df = adae_smq_all,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = score_ae_pts) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 95 (70.9%) 103 (76.9%) 108 (81.8%)\nD.2.1.5.3/A.1.1.1.1 AESI \n Total number of patients with at least one adverse event 74 (55.2%) 80 (59.7%) 87 (65.9%) \n Total number of events 126 134 162 \n dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) \n dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) \nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 72 (53.7%) 79 (59.0%) 75 (56.8%) \n Total number of events 119 139 141 \n dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) \nnon observed SMQ02NAM level(BROAD) \n Total number of patients with at least one adverse event 0 0 0 \n Total number of events 0 0 0 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nnames_baskets <- grep(\"^(SMQ|CQ).*NAM$\", names(adae), value = TRUE)\nnames_scopes <- grep(\"^SMQ.*SC$\", names(adae), value = TRUE)\n\ncs_baskets <- choices_selected(\n choices = variable_choices(adae, subset = names_baskets),\n selected = names_baskets\n)\ncs_scopes <- choices_selected(\n choices = variable_choices(adae, subset = names_scopes),\n selected = names_scopes,\n fixed = TRUE\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'\n ),\n cdisc_dataset(\"ADAE\", adae,\n code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_smq(\n label = \"Adverse events by `SMQ` Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"SEX\")),\n selected = \"ARM\"\n ),\n add_total = FALSE,\n baskets = cs_baskets,\n scopes = cs_scopes,\n llt = choices_selected(\n choices = variable_choices(adae, subset = c(\"AEDECOD\")),\n selected = \"AEDECOD\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:00:40.4665 pid:5109 token:[] teal.modules.clinical Initializing tm_t_smq\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] stringr_1.5.0 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] stringi_1.7.12 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet05_all.html",
"href": "tables/adverse-events/aet05_all.html",
"title": "AET05_ALL",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Setting Type of Confidence Interval\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadaette <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadaette <- df_explicit_na(adaette)\n\n# Create analysis dataset anl from the 2 parameters AEREPTTE & AETOT1\nanl_events <- adaette %>%\n filter(PARAMCD == \"AETOT1\") %>%\n select(USUBJID, ARM, ARMCD, n_events = AVAL) %>%\n mutate(n_events = as.integer(n_events))\n\nanl_tte <- adaette %>%\n filter(PARAMCD == \"AEREPTTE\") %>%\n select(USUBJID, ARM, ARMCD, AVAL)\n\nanl <- full_join(anl_tte, anl_events, by = c(\"USUBJID\", \"ARM\", \"ARMCD\"))\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n estimate_incidence_rate(\n vars = \"AVAL\",\n n_events = \"n_events\",\n control = control_incidence_rate(num_pt_year = 100)\n )\n\nresult <- build_table(lyt, anl, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————\nTotal patient-years at risk 337.9 331.8 341.6 \nNumber of adverse events observed 343 380 397 \nAE rate per 100 patient-years 101.51 114.51 116.22 \n95% CI (90.77, 112.25) (103.00, 126.02) (104.79, 127.65)\n\n\n\n\nThe type of confidence interval can be specified through the conf_type argument.\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n estimate_incidence_rate(\n vars = \"AVAL\",\n n_events = \"n_events\",\n control = control_incidence_rate(conf_type = \"exact\", num_pt_year = 100)\n )\n\nresult <- build_table(lyt, anl, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————\nTotal patient-years at risk 337.9 331.8 341.6 \nNumber of adverse events observed 343 380 397 \nAE rate per 100 patient-years 101.51 114.51 116.22 \n95% CI (91.05, 112.84) (103.28, 126.62) (105.07, 128.24)\n\n\n\n\n\nCodelibrary(teal)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadaette <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadaette <- df_explicit_na(adaette)\n\n# Create analysis dataset anl from the 2 parameters AEREPTTE & AETOT1\nanl_events <- adaette %>%\n filter(PARAMCD %in% c(\"AETOT1\", \"AETOT2\", \"AETOT3\")) %>%\n select(USUBJID, STUDYID, PARAMCD, ARM, ARMCD, n_events = AVAL) %>%\n mutate(n_events = as.integer(n_events))\n\nanl_tte <- adaette %>%\n filter(PARAMCD == \"AEREPTTE\") %>%\n select(USUBJID, STUDYID, ARM, ARMCD, AVAL, AVALU)\n\nadaette <- full_join(anl_tte, anl_events, by = c(\"USUBJID\", \"STUDYID\", \"ARM\", \"ARMCD\"))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAETTE\", adaette),\n code =\n 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADAETTE <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n ADSL <- df_explicit_na(ADSL)\n ADAETTE <- df_explicit_na(ADAETTE)\n anl_events <- ADAETTE %>%\n filter(PARAMCD %in% c(\"AETOT1\", \"AETOT2\", \"AETOT3\")) %>%\n select(USUBJID, STUDYID, PARAMCD, ARM, ARMCD, n_events = AVAL) %>%\n mutate(n_events = as.integer(n_events))\n anl_tte <- ADAETTE %>%\n filter(PARAMCD == \"AEREPTTE\") %>%\n select(USUBJID, STUDYID, ARM, ARMCD, AVAL, AVALU)\n ADAETTE <- full_join(anl_tte, anl_events, by = c(\"USUBJID\", \"STUDYID\", \"ARM\", \"ARMCD\"))',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_patyear(\n label = \"AE Rate Adjusted for Patient-Years at Risk - All Occurrences Table\",\n dataname = \"ADAETTE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARMCD\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adaette, \"PARAMCD\"),\n selected = \"AETOT1\"\n ),\n events_var = choices_selected(\n choices = variable_choices(adaette, \"n_events\"),\n selected = \"n_events\",\n fixed = TRUE\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:40:43.3543 pid:4908 token:[] teal.modules.clinical Initializing tm_t_events_patyear\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Setting Type of Confidence Interval\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadaette <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadaette <- df_explicit_na(adaette)\n\n# Create analysis dataset anl from the 2 parameters AEREPTTE & AETOT1\nanl_events <- adaette %>%\n filter(PARAMCD == \"AETOT1\") %>%\n select(USUBJID, ARM, ARMCD, n_events = AVAL) %>%\n mutate(n_events = as.integer(n_events))\n\nanl_tte <- adaette %>%\n filter(PARAMCD == \"AEREPTTE\") %>%\n select(USUBJID, ARM, ARMCD, AVAL)\n\nanl <- full_join(anl_tte, anl_events, by = c(\"USUBJID\", \"ARM\", \"ARMCD\"))\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n estimate_incidence_rate(\n vars = \"AVAL\",\n n_events = \"n_events\",\n control = control_incidence_rate(num_pt_year = 100)\n )\n\nresult <- build_table(lyt, anl, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————\nTotal patient-years at risk 337.9 331.8 341.6 \nNumber of adverse events observed 343 380 397 \nAE rate per 100 patient-years 101.51 114.51 116.22 \n95% CI (90.77, 112.25) (103.00, 126.02) (104.79, 127.65)\n\n\n\n\nThe type of confidence interval can be specified through the conf_type argument.\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n estimate_incidence_rate(\n vars = \"AVAL\",\n n_events = \"n_events\",\n control = control_incidence_rate(conf_type = \"exact\", num_pt_year = 100)\n )\n\nresult <- build_table(lyt, anl, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————\nTotal patient-years at risk 337.9 331.8 341.6 \nNumber of adverse events observed 343 380 397 \nAE rate per 100 patient-years 101.51 114.51 116.22 \n95% CI (91.05, 112.84) (103.28, 126.62) (105.07, 128.24)\n\n\n\n\n\nCodelibrary(teal)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadaette <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadaette <- df_explicit_na(adaette)\n\n# Create analysis dataset anl from the 2 parameters AEREPTTE & AETOT1\nanl_events <- adaette %>%\n filter(PARAMCD %in% c(\"AETOT1\", \"AETOT2\", \"AETOT3\")) %>%\n select(USUBJID, STUDYID, PARAMCD, ARM, ARMCD, n_events = AVAL) %>%\n mutate(n_events = as.integer(n_events))\n\nanl_tte <- adaette %>%\n filter(PARAMCD == \"AEREPTTE\") %>%\n select(USUBJID, STUDYID, ARM, ARMCD, AVAL, AVALU)\n\nadaette <- full_join(anl_tte, anl_events, by = c(\"USUBJID\", \"STUDYID\", \"ARM\", \"ARMCD\"))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADAETTE\", adaette),\n code =\n 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADAETTE <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n ADSL <- df_explicit_na(ADSL)\n ADAETTE <- df_explicit_na(ADAETTE)\n anl_events <- ADAETTE %>%\n filter(PARAMCD %in% c(\"AETOT1\", \"AETOT2\", \"AETOT3\")) %>%\n select(USUBJID, STUDYID, PARAMCD, ARM, ARMCD, n_events = AVAL) %>%\n mutate(n_events = as.integer(n_events))\n anl_tte <- ADAETTE %>%\n filter(PARAMCD == \"AEREPTTE\") %>%\n select(USUBJID, STUDYID, ARM, ARMCD, AVAL, AVALU)\n ADAETTE <- full_join(anl_tte, anl_events, by = c(\"USUBJID\", \"STUDYID\", \"ARM\", \"ARMCD\"))',\n check = TRUE\n ),\n modules = modules(\n tm_t_events_patyear(\n label = \"AE Rate Adjusted for Patient-Years at Risk - All Occurrences Table\",\n dataname = \"ADAETTE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARMCD\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adaette, \"PARAMCD\"),\n selected = \"AETOT1\"\n ),\n events_var = choices_selected(\n choices = variable_choices(adaette, \"n_events\"),\n selected = \"n_events\",\n fixed = TRUE\n )\n )\n )\n)\n\n[INFO] 2023-09-09 17:59:38.3701 pid:4913 token:[] teal.modules.clinical Initializing tm_t_events_patyear\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/dst01.html",
"href": "tables/safety/dst01.html",
"title": "DST01",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Grouping of Reasons\nTable Adding Optional Rows\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nset.seed(1, kind = \"Mersenne-Twister\")\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n\n# reorder EOSSTT factor levels so DISCONTINUED is the last level\nadsl <- df_explicit_na(adsl) %>%\n mutate(EOSSTT = factor(EOSSTT, levels = c(\"COMPLETED\", \"ONGOING\", \"DISCONTINUED\")))\n\nadsl_gp_added <- adsl %>%\n mutate(DCSREASGP = case_when(\n DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\") ~ \"Safety\",\n (DCSREAS != \"<Missing>\" & !DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\")) ~ \"Non-Safety\",\n DCSREAS == \"<Missing>\" ~ \"<Missing>\"\n ) %>% factor(levels = c(\"Safety\", \"Non-Safety\", \"<Missing>\")))\n\nadsl_eotstt_added <- adsl_gp_added %>%\n mutate(\n EOTSTT = sample(\n c(\"ONGOING\", \"COMPLETED\", \"DISCONTINUED\"),\n size = nrow(adsl),\n replace = TRUE\n ) %>% factor(levels = c(\"COMPLETED\", \"ONGOING\", \"DISCONTINUED\"))\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n \"ACTARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(\n \"EOSSTT\",\n .stats = \"count_fraction\",\n show_labels = \"hidden\"\n ) %>%\n analyze_vars(\n \"DCSREAS\",\n .stats = \"count_fraction\",\n denom = \"N_col\",\n show_labels = \"hidden\",\n .indent_mods = c(count_fraction = 1L)\n )\n\nresult1 <- build_table(lyt = lyt, df = adsl)\nresult1\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————————\nCOMPLETED 68 (50.7%) 66 (49.3%) 73 (55.3%) 207 (51.7%) \nONGOING 24 (17.9%) 28 (20.9%) 21 (15.9%) 73 (18.2%) \nDISCONTINUED 42 (31.3%) 40 (29.9%) 38 (28.8%) 120 (30.0%) \n ADVERSE EVENT 3 (2.2%) 6 (4.5%) 5 (3.8%) 14 (3.5%) \n DEATH 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) \n LACK OF EFFICACY 2 (1.5%) 2 (1.5%) 3 (2.3%) 7 (1.8%) \n PHYSICIAN DECISION 2 (1.5%) 3 (2.2%) 2 (1.5%) 7 (1.8%) \n PROTOCOL VIOLATION 5 (3.7%) 3 (2.2%) 4 (3%) 12 (3%) \n WITHDRAWAL BY PARENT/GUARDIAN 4 (3%) 2 (1.5%) 1 (0.8%) 7 (1.8%) \n WITHDRAWAL BY SUBJECT 1 (0.7%) 1 (0.7%) 1 (0.8%) 3 (0.8%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n \"ACTARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(\n \"EOSSTT\",\n .stats = \"count_fraction\",\n show_labels = \"hidden\"\n ) %>%\n split_rows_by(\"DCSREASGP\", indent_mod = 1L) %>%\n analyze_vars(\n \"DCSREAS\",\n .stats = \"count_fraction\",\n denom = \"N_col\",\n show_labels = \"hidden\"\n )\n\ntbl <- build_table(lyt = lyt, df = adsl_gp_added)\nresult2 <- prune_table(tbl) # remove rows containing all zeros\n\nresult2\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————\nCOMPLETED 68 (50.7%) 66 (49.3%) 73 (55.3%) 207 (51.7%) \nONGOING 24 (17.9%) 28 (20.9%) 21 (15.9%) 73 (18.2%) \nDISCONTINUED 42 (31.3%) 40 (29.9%) 38 (28.8%) 120 (30.0%) \n Safety \n ADVERSE EVENT 3 (2.2%) 6 (4.5%) 5 (3.8%) 14 (3.5%) \n DEATH 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) \n Non-Safety \n LACK OF EFFICACY 2 (1.5%) 2 (1.5%) 3 (2.3%) 7 (1.8%) \n PHYSICIAN DECISION 2 (1.5%) 3 (2.2%) 2 (1.5%) 7 (1.8%) \n PROTOCOL VIOLATION 5 (3.7%) 3 (2.2%) 4 (3%) 12 (3%) \n WITHDRAWAL BY PARENT/GUARDIAN 4 (3%) 2 (1.5%) 1 (0.8%) 7 (1.8%) \n WITHDRAWAL BY SUBJECT 1 (0.7%) 1 (0.7%) 1 (0.8%) 3 (0.8%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n \"ACTARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(\n \"EOTSTT\",\n .stats = \"count_fraction\",\n show_labels = \"hidden\"\n )\n\ntbl <- build_table(lyt = lyt, df = adsl_eotstt_added)\ntbl <- prune_table(tbl) # remove rows containing all zeros\n\n# Combine tables\ncol_info(result2) <- col_info(tbl)\nresult3 <- rbind(result2, tbl)\n\nresult3\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————\nCOMPLETED 68 (50.7%) 66 (49.3%) 73 (55.3%) 207 (51.7%) \nONGOING 24 (17.9%) 28 (20.9%) 21 (15.9%) 73 (18.2%) \nDISCONTINUED 42 (31.3%) 40 (29.9%) 38 (28.8%) 120 (30.0%) \n Safety \n ADVERSE EVENT 3 (2.2%) 6 (4.5%) 5 (3.8%) 14 (3.5%) \n DEATH 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) \n Non-Safety \n LACK OF EFFICACY 2 (1.5%) 2 (1.5%) 3 (2.3%) 7 (1.8%) \n PHYSICIAN DECISION 2 (1.5%) 3 (2.2%) 2 (1.5%) 7 (1.8%) \n PROTOCOL VIOLATION 5 (3.7%) 3 (2.2%) 4 (3%) 12 (3%) \n WITHDRAWAL BY PARENT/GUARDIAN 4 (3%) 2 (1.5%) 1 (0.8%) 7 (1.8%) \n WITHDRAWAL BY SUBJECT 1 (0.7%) 1 (0.7%) 1 (0.8%) 3 (0.8%) \nCOMPLETED 46 (34.3%) 38 (28.4%) 41 (31.1%) 125 (31.2%) \nONGOING 50 (37.3%) 51 (38.1%) 46 (34.8%) 147 (36.8%) \nDISCONTINUED 38 (28.4%) 45 (33.6%) 45 (34.1%) 128 (32.0%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nset.seed(1, kind = \"Mersenne-Twister\")\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsl <- df_explicit_na(adsl)\nadsl <- adsl %>%\n mutate(\n DCSREASGP = case_when(\n DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\") ~ \"Safety\",\n (DCSREAS != \"<Missing>\" & !DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\")) ~ \"Non-Safety\",\n DCSREAS == \"<Missing>\" ~ \"<Missing>\"\n ) %>% as.factor(),\n EOTSTT = sample(\n c(\"ONGOING\", \"COMPLETED\", \"DISCONTINUED\"),\n size = nrow(adsl),\n replace = TRUE\n ) %>% as.factor()\n ) %>%\n var_relabel(\n EOTSTT = \"End Of Treatment Status\"\n )\n\ndate_vars_asl <- names(adsl)[vapply(adsl, function(x) inherits(x, c(\"Date\", \"POSIXct\", \"POSIXlt\")), logical(1))]\ndemog_vars_asl <- names(adsl)[!(names(adsl) %in% c(\"USUBJID\", \"STUDYID\", date_vars_asl))]\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n code = '\n set.seed(1, kind = \"Mersenne-Twister\")\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)\n ADSL <- ADSL %>%\n mutate(\n DCSREASGP = case_when(\n DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\") ~ \"Safety\",\n (DCSREAS != \"<Missing>\" & !DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\")) ~ \"Non-Safety\",\n DCSREAS == \"<Missing>\" ~ \"<Missing>\"\n ) %>% as.factor(),\n EOTSTT = sample(\n c(\"ONGOING\", \"COMPLETED\", \"DISCONTINUED\"),\n size = nrow(ADSL),\n replace = TRUE\n ) %>% as.factor()\n ) %>% var_relabel(\n EOTSTT = \"End Of Treatment Status\"\n )\n ',\n check = TRUE\n ),\n modules = modules(\n tm_t_summary(\n label = \"Disposition Table\",\n dataname = \"ADSL\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n summarize_vars = choices_selected(\n variable_choices(adsl, demog_vars_asl),\n c(\"EOSSTT\", \"DCSREAS\", \"EOTSTT\")\n ),\n useNA = \"ifany\"\n )\n )\n)\n\n[INFO] 2023-09-08 19:39:47.1364 pid:4712 token:[] teal.modules.clinical Initializing tm_t_summary\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Grouping of Reasons\nTable Adding Optional Rows\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nset.seed(1, kind = \"Mersenne-Twister\")\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n\n# reorder EOSSTT factor levels so DISCONTINUED is the last level\nadsl <- df_explicit_na(adsl) %>%\n mutate(EOSSTT = factor(EOSSTT, levels = c(\"COMPLETED\", \"ONGOING\", \"DISCONTINUED\")))\n\nadsl_gp_added <- adsl %>%\n mutate(DCSREASGP = case_when(\n DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\") ~ \"Safety\",\n (DCSREAS != \"<Missing>\" & !DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\")) ~ \"Non-Safety\",\n DCSREAS == \"<Missing>\" ~ \"<Missing>\"\n ) %>% factor(levels = c(\"Safety\", \"Non-Safety\", \"<Missing>\")))\n\nadsl_eotstt_added <- adsl_gp_added %>%\n mutate(\n EOTSTT = sample(\n c(\"ONGOING\", \"COMPLETED\", \"DISCONTINUED\"),\n size = nrow(adsl),\n replace = TRUE\n ) %>% factor(levels = c(\"COMPLETED\", \"ONGOING\", \"DISCONTINUED\"))\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n \"ACTARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(\n \"EOSSTT\",\n .stats = \"count_fraction\",\n show_labels = \"hidden\"\n ) %>%\n analyze_vars(\n \"DCSREAS\",\n .stats = \"count_fraction\",\n denom = \"N_col\",\n show_labels = \"hidden\",\n .indent_mods = c(count_fraction = 1L)\n )\n\nresult1 <- build_table(lyt = lyt, df = adsl)\nresult1\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————————\nCOMPLETED 68 (50.7%) 66 (49.3%) 73 (55.3%) 207 (51.7%) \nONGOING 24 (17.9%) 28 (20.9%) 21 (15.9%) 73 (18.2%) \nDISCONTINUED 42 (31.3%) 40 (29.9%) 38 (28.8%) 120 (30.0%) \n ADVERSE EVENT 3 (2.2%) 6 (4.5%) 5 (3.8%) 14 (3.5%) \n DEATH 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) \n LACK OF EFFICACY 2 (1.5%) 2 (1.5%) 3 (2.3%) 7 (1.8%) \n PHYSICIAN DECISION 2 (1.5%) 3 (2.2%) 2 (1.5%) 7 (1.8%) \n PROTOCOL VIOLATION 5 (3.7%) 3 (2.2%) 4 (3%) 12 (3%) \n WITHDRAWAL BY PARENT/GUARDIAN 4 (3%) 2 (1.5%) 1 (0.8%) 7 (1.8%) \n WITHDRAWAL BY SUBJECT 1 (0.7%) 1 (0.7%) 1 (0.8%) 3 (0.8%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n \"ACTARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(\n \"EOSSTT\",\n .stats = \"count_fraction\",\n show_labels = \"hidden\"\n ) %>%\n split_rows_by(\"DCSREASGP\", indent_mod = 1L) %>%\n analyze_vars(\n \"DCSREAS\",\n .stats = \"count_fraction\",\n denom = \"N_col\",\n show_labels = \"hidden\"\n )\n\ntbl <- build_table(lyt = lyt, df = adsl_gp_added)\nresult2 <- prune_table(tbl) # remove rows containing all zeros\n\nresult2\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————\nCOMPLETED 68 (50.7%) 66 (49.3%) 73 (55.3%) 207 (51.7%) \nONGOING 24 (17.9%) 28 (20.9%) 21 (15.9%) 73 (18.2%) \nDISCONTINUED 42 (31.3%) 40 (29.9%) 38 (28.8%) 120 (30.0%) \n Safety \n ADVERSE EVENT 3 (2.2%) 6 (4.5%) 5 (3.8%) 14 (3.5%) \n DEATH 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) \n Non-Safety \n LACK OF EFFICACY 2 (1.5%) 2 (1.5%) 3 (2.3%) 7 (1.8%) \n PHYSICIAN DECISION 2 (1.5%) 3 (2.2%) 2 (1.5%) 7 (1.8%) \n PROTOCOL VIOLATION 5 (3.7%) 3 (2.2%) 4 (3%) 12 (3%) \n WITHDRAWAL BY PARENT/GUARDIAN 4 (3%) 2 (1.5%) 1 (0.8%) 7 (1.8%) \n WITHDRAWAL BY SUBJECT 1 (0.7%) 1 (0.7%) 1 (0.8%) 3 (0.8%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n \"ACTARM\",\n split_fun = add_overall_level(\"All Patients\", first = FALSE)\n ) %>%\n count_occurrences(\n \"EOTSTT\",\n .stats = \"count_fraction\",\n show_labels = \"hidden\"\n )\n\ntbl <- build_table(lyt = lyt, df = adsl_eotstt_added)\ntbl <- prune_table(tbl) # remove rows containing all zeros\n\n# Combine tables\ncol_info(result2) <- col_info(tbl)\nresult3 <- rbind(result2, tbl)\n\nresult3\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————\nCOMPLETED 68 (50.7%) 66 (49.3%) 73 (55.3%) 207 (51.7%) \nONGOING 24 (17.9%) 28 (20.9%) 21 (15.9%) 73 (18.2%) \nDISCONTINUED 42 (31.3%) 40 (29.9%) 38 (28.8%) 120 (30.0%) \n Safety \n ADVERSE EVENT 3 (2.2%) 6 (4.5%) 5 (3.8%) 14 (3.5%) \n DEATH 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) \n Non-Safety \n LACK OF EFFICACY 2 (1.5%) 2 (1.5%) 3 (2.3%) 7 (1.8%) \n PHYSICIAN DECISION 2 (1.5%) 3 (2.2%) 2 (1.5%) 7 (1.8%) \n PROTOCOL VIOLATION 5 (3.7%) 3 (2.2%) 4 (3%) 12 (3%) \n WITHDRAWAL BY PARENT/GUARDIAN 4 (3%) 2 (1.5%) 1 (0.8%) 7 (1.8%) \n WITHDRAWAL BY SUBJECT 1 (0.7%) 1 (0.7%) 1 (0.8%) 3 (0.8%) \nCOMPLETED 46 (34.3%) 38 (28.4%) 41 (31.1%) 125 (31.2%) \nONGOING 50 (37.3%) 51 (38.1%) 46 (34.8%) 147 (36.8%) \nDISCONTINUED 38 (28.4%) 45 (33.6%) 45 (34.1%) 128 (32.0%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nset.seed(1, kind = \"Mersenne-Twister\")\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsl <- df_explicit_na(adsl)\nadsl <- adsl %>%\n mutate(\n DCSREASGP = case_when(\n DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\") ~ \"Safety\",\n (DCSREAS != \"<Missing>\" & !DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\")) ~ \"Non-Safety\",\n DCSREAS == \"<Missing>\" ~ \"<Missing>\"\n ) %>% as.factor(),\n EOTSTT = sample(\n c(\"ONGOING\", \"COMPLETED\", \"DISCONTINUED\"),\n size = nrow(adsl),\n replace = TRUE\n ) %>% as.factor()\n ) %>%\n var_relabel(\n EOTSTT = \"End Of Treatment Status\"\n )\n\ndate_vars_asl <- names(adsl)[vapply(adsl, function(x) inherits(x, c(\"Date\", \"POSIXct\", \"POSIXlt\")), logical(1))]\ndemog_vars_asl <- names(adsl)[!(names(adsl) %in% c(\"USUBJID\", \"STUDYID\", date_vars_asl))]\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n code = '\n set.seed(1, kind = \"Mersenne-Twister\")\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)\n ADSL <- ADSL %>%\n mutate(\n DCSREASGP = case_when(\n DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\") ~ \"Safety\",\n (DCSREAS != \"<Missing>\" & !DCSREAS %in% c(\"ADVERSE EVENT\", \"DEATH\")) ~ \"Non-Safety\",\n DCSREAS == \"<Missing>\" ~ \"<Missing>\"\n ) %>% as.factor(),\n EOTSTT = sample(\n c(\"ONGOING\", \"COMPLETED\", \"DISCONTINUED\"),\n size = nrow(ADSL),\n replace = TRUE\n ) %>% as.factor()\n ) %>% var_relabel(\n EOTSTT = \"End Of Treatment Status\"\n )\n ',\n check = TRUE\n ),\n modules = modules(\n tm_t_summary(\n label = \"Disposition Table\",\n dataname = \"ADSL\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n summarize_vars = choices_selected(\n variable_choices(adsl, demog_vars_asl),\n c(\"EOSSTT\", \"DCSREAS\", \"EOTSTT\")\n ),\n useNA = \"ifany\"\n )\n )\n)\n\n[INFO] 2023-09-09 17:58:29.0876 pid:4717 token:[] teal.modules.clinical Initializing tm_t_summary\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/cmt01a.html",
"href": "tables/safety/cmt01a.html",
"title": "CMT01A",
"section": "",
- "text": "Data Setup\nStandard Table, Safety-Evaluable Patients\nTable Changing ATC Class Level\nTable with Classes Sorted by Frequency\nTable with Total Number of Treatments per Medication Class Suppressed\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.factor(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\n# Keep only safety-evaluable patients and concomitant medications\nadsl <- adsl %>%\n filter(SAFFL == \"Y\")\n\nadcm <- adcm %>%\n filter(SAFFL == \"Y\" & ATIREL == \"CONCOMITANT\") %>%\n var_relabel(CMDECOD = \"Other Treatment\")\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC2\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 2 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS2 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS2 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC1\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC1)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC1\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 1 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS1 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS1 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(path = c(\"ATC2\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"ATC2\", \"*\", \"CMDECOD\"), scorefun = score_occurrences)\n\nresult\n\nATC Level 2 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS2 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS2 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \nATCCLAS2 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC2\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 2 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS2 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS2 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\nadcm$CMSEQ <- as.integer(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm_keys <- c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"CMSEQ\", \"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)\n '),\n cdisc_dataset(\"ADCM\", adcm,\n code = '\n ADCM <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n ADCM$CMSEQ <- as.factor(ADCM$CMSEQ)\n ADCM <- df_explicit_na(ADCM)\n ',\n keys = adcm_keys\n )\n ),\n modules = modules(\n tm_t_mult_events(\n label = \"Concomitant Medications by Medication Class and Preferred Name\",\n dataname = \"ADCM\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n seq_var = choices_selected(\"CMSEQ\", selected = \"CMSEQ\", fixed = TRUE),\n hlt = choices_selected(\n choices = variable_choices(adcm, c(\"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")),\n selected = c(\"ATC2\")\n ),\n llt = choices_selected(\n choices = variable_choices(adcm, c(\"CMDECOD\")),\n selected = c(\"CMDECOD\")\n ),\n add_total = FALSE,\n event_type = \"treatment\"\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\"),\n ADCM = list(ATIREL = \"CONCOMITANT\")\n )\n)\n\n[INFO] 2023-09-08 19:38:58.2234 pid:4516 token:[] teal.modules.clinical Initializing tm_t_mult_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table, Safety-Evaluable Patients\nTable Changing ATC Class Level\nTable with Classes Sorted by Frequency\nTable with Total Number of Treatments per Medication Class Suppressed\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.factor(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\n# Keep only safety-evaluable patients and concomitant medications\nadsl <- adsl %>%\n filter(SAFFL == \"Y\")\n\nadcm <- adcm %>%\n filter(SAFFL == \"Y\" & ATIREL == \"CONCOMITANT\") %>%\n var_relabel(CMDECOD = \"Other Treatment\")\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC2\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 2 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS2 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS2 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC1\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC1)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC1\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 1 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS1 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS1 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(path = c(\"ATC2\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"ATC2\", \"*\", \"CMDECOD\"), scorefun = score_occurrences)\n\nresult\n\nATC Level 2 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS2 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS2 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \nATCCLAS2 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC2\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 2 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS2 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS2 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS2 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS2 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS2 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\nadcm$CMSEQ <- as.integer(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm_keys <- c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"CMSEQ\", \"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)\n '),\n cdisc_dataset(\"ADCM\", adcm,\n code = '\n ADCM <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n ADCM$CMSEQ <- as.factor(ADCM$CMSEQ)\n ADCM <- df_explicit_na(ADCM)\n ',\n keys = adcm_keys\n )\n ),\n modules = modules(\n tm_t_mult_events(\n label = \"Concomitant Medications by Medication Class and Preferred Name\",\n dataname = \"ADCM\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n seq_var = choices_selected(\"CMSEQ\", selected = \"CMSEQ\", fixed = TRUE),\n hlt = choices_selected(\n choices = variable_choices(adcm, c(\"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")),\n selected = c(\"ATC2\")\n ),\n llt = choices_selected(\n choices = variable_choices(adcm, c(\"CMDECOD\")),\n selected = c(\"CMDECOD\")\n ),\n add_total = FALSE,\n event_type = \"treatment\"\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\"),\n ADCM = list(ATIREL = \"CONCOMITANT\")\n )\n)\n\n[INFO] 2023-09-09 17:57:26.3553 pid:4521 token:[] teal.modules.clinical Initializing tm_t_mult_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/eudrat01.html",
@@ -375,35 +375,35 @@
"href": "tables/safety/egt02.html",
"title": "EGT02",
"section": "",
- "text": "Data Setup\nECG Abnormalities Regardless of Abnormality at Baseline\nECG Abnormalities Among Subjects Without Abnormality at Baseline\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\n\n# Note: We keep only post-baseline for analysis.\nadeg_f <- adeg %>%\n filter(ONTRTFL == \"Y\") %>%\n filter(PARAM %in% c(\"Heart Rate\", \"QT Duration\", \"RR Duration\")) %>%\n filter(ANRIND != \"<Missing>\") %>%\n var_relabel(\n PARAM = \"Assessment\",\n ANRIND = \"Abnormality\"\n )\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adeg_f$PARAM)\n ) %>%\n count_abnormal(\"ANRIND\", abnormal = list(Low = \"LOW\", High = \"HIGH\"), exclude_base_abn = FALSE) %>%\n append_varlabels(adeg_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adeg_f, alt_counts_df = adsl)\nresult\n\nAssessment A: Drug X B: Placebo C: Combination\n Abnormality (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————\nHeart Rate \n Low 40/134 (29.9%) 43/134 (32.1%) 37/132 (28%) \n High 39/134 (29.1%) 45/134 (33.6%) 36/132 (27.3%)\nQT Duration \n Low 33/134 (24.6%) 44/134 (32.8%) 47/132 (35.6%)\n High 30/134 (22.4%) 42/134 (31.3%) 34/132 (25.8%)\nRR Duration \n Low 45/134 (33.6%) 26/134 (19.4%) 38/132 (28.8%)\n High 29/134 (21.6%) 49/134 (36.6%) 27/132 (20.5%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adeg_f$PARAM)\n ) %>%\n count_abnormal(\"ANRIND\", abnormal = list(Low = \"LOW\", High = \"HIGH\"), exclude_base_abn = TRUE) %>%\n append_varlabels(adeg_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adeg_f, alt_counts_df = adsl)\nresult\n\nAssessment A: Drug X B: Placebo C: Combination\n Abnormality (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————\nHeart Rate \n Low 39/128 (30.5%) 42/124 (33.9%) 33/117 (28.2%)\n High 37/127 (29.1%) 43/129 (33.3%) 31/122 (25.4%)\nQT Duration \n Low 29/113 (25.7%) 42/126 (33.3%) 43/124 (34.7%)\n High 30/125 (24%) 40/130 (30.8%) 30/119 (25.2%)\nRR Duration \n Low 45/129 (34.9%) 26/123 (21.1%) 37/126 (29.4%)\n High 27/127 (21.3%) 43/122 (35.2%) 25/125 (20%) \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEG\", adeg, code = 'ADEG <- synthetic_cdisc_dataset(\"latest\", \"adeg\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality(\n label = \"Abnormality Table\",\n dataname = \"ADEG\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adeg, subset = c(\"EGCAT\", \"PARAM\", \"AVISIT\")),\n selected = c(\"PARAM\"),\n keep_order = TRUE\n ),\n grade = choices_selected(\n choices = variable_choices(adeg, subset = \"ANRIND\"),\n selected = \"ANRIND\",\n fixed = TRUE\n ),\n abnormal = list(Low = \"LOW\", High = \"HIGH\"),\n exclude_base_abn = FALSE\n )\n )\n)\n\n[INFO] 2023-09-08 19:37:07.6441 pid:4171 token:[] teal.modules.clinical Initializing tm_t_abnormality\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] scda_0.1.6.9012 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nECG Abnormalities Regardless of Abnormality at Baseline\nECG Abnormalities Among Subjects Without Abnormality at Baseline\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\n\n# Note: We keep only post-baseline for analysis.\nadeg_f <- adeg %>%\n filter(ONTRTFL == \"Y\") %>%\n filter(PARAM %in% c(\"Heart Rate\", \"QT Duration\", \"RR Duration\")) %>%\n filter(ANRIND != \"<Missing>\") %>%\n var_relabel(\n PARAM = \"Assessment\",\n ANRIND = \"Abnormality\"\n )\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adeg_f$PARAM)\n ) %>%\n count_abnormal(\"ANRIND\", abnormal = list(Low = \"LOW\", High = \"HIGH\"), exclude_base_abn = FALSE) %>%\n append_varlabels(adeg_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adeg_f, alt_counts_df = adsl)\nresult\n\nAssessment A: Drug X B: Placebo C: Combination\n Abnormality (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————\nHeart Rate \n Low 40/134 (29.9%) 43/134 (32.1%) 37/132 (28%) \n High 39/134 (29.1%) 45/134 (33.6%) 36/132 (27.3%)\nQT Duration \n Low 33/134 (24.6%) 44/134 (32.8%) 47/132 (35.6%)\n High 30/134 (22.4%) 42/134 (31.3%) 34/132 (25.8%)\nRR Duration \n Low 45/134 (33.6%) 26/134 (19.4%) 38/132 (28.8%)\n High 29/134 (21.6%) 49/134 (36.6%) 27/132 (20.5%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adeg_f$PARAM)\n ) %>%\n count_abnormal(\"ANRIND\", abnormal = list(Low = \"LOW\", High = \"HIGH\"), exclude_base_abn = TRUE) %>%\n append_varlabels(adeg_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adeg_f, alt_counts_df = adsl)\nresult\n\nAssessment A: Drug X B: Placebo C: Combination\n Abnormality (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————\nHeart Rate \n Low 39/128 (30.5%) 42/124 (33.9%) 33/117 (28.2%)\n High 37/127 (29.1%) 43/129 (33.3%) 31/122 (25.4%)\nQT Duration \n Low 29/113 (25.7%) 42/126 (33.3%) 43/124 (34.7%)\n High 30/125 (24%) 40/130 (30.8%) 30/119 (25.2%)\nRR Duration \n Low 45/129 (34.9%) 26/123 (21.1%) 37/126 (29.4%)\n High 27/127 (21.3%) 43/122 (35.2%) 25/125 (20%) \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEG\", adeg, code = 'ADEG <- synthetic_cdisc_dataset(\"latest\", \"adeg\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality(\n label = \"Abnormality Table\",\n dataname = \"ADEG\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adeg, subset = c(\"EGCAT\", \"PARAM\", \"AVISIT\")),\n selected = c(\"PARAM\"),\n keep_order = TRUE\n ),\n grade = choices_selected(\n choices = variable_choices(adeg, subset = \"ANRIND\"),\n selected = \"ANRIND\",\n fixed = TRUE\n ),\n abnormal = list(Low = \"LOW\", High = \"HIGH\"),\n exclude_base_abn = FALSE\n )\n )\n)\n\n[INFO] 2023-09-09 17:55:08.8358 pid:4176 token:[] teal.modules.clinical Initializing tm_t_abnormality\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] scda_0.1.6.9012 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/vst01.html",
"href": "tables/safety/vst01.html",
"title": "VST01",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadvs <- df_explicit_na(advs)\n\nadvs_label <- var_labels(advs)\n\nadvs <- advs %>%\n filter(\n PARAMCD == \"DIABP\",\n PARAM == \"Diastolic Blood Pressure\"\n ) %>%\n mutate(\n PARAMCD = droplevels(PARAMCD),\n PARAM = droplevels(PARAM)\n )\n\n# post-baseline\nadvs_pb <- advs %>%\n filter(ABLFL != \"Y\", ABLFL2 != \"Y\")\n\nadvs_pb_max <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVAL)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Maximum\")\n\nadvs_pb_min <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(AVAL) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Minimum\")\n\nadvs_pb_last <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVISITN)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Last\")\n\n# Please note that for real data, per ADaM Spec 1.1, the advs_f can be obtained by filtering on PARAMCD, then\n# ANL01FL == 'Y' or AVISIT in c('POST-BASELINE MAXIMUM', 'POST-BASELINE MINIMUM', 'POST-BASELINE LAST')\n\nadvs_f <- rbind(\n advs,\n advs_pb_last,\n advs_pb_min,\n advs_pb_max\n)\n\nadvs_f <- advs_f %>%\n mutate(AVISIT = droplevels(AVISIT))\n\nvar_labels(advs_f) <- advs_label\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nafun <- function(x, .var, .spl_context, ...) {\n n_fun <- sum(!is.na(x), na.rm = TRUE)\n if (n_fun == 0) {\n mean_sd_fun <- c(NA, NA)\n median_fun <- NA\n min_max_fun <- c(NA, NA)\n } else {\n mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))\n median_fun <- median(x, na.rm = TRUE)\n min_max_fun <- c(min(x), max(x))\n }\n is_chg <- .var == \"CHG\"\n is_baseline <- .spl_context$value[which(.spl_context$split == \"AVISIT\")] == \"BASELINE\"\n if (is_baseline && is_chg) n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL\n\n in_rows(\n \"n\" = n_fun,\n \"Mean (SD)\" = mean_sd_fun,\n \"Median\" = median_fun,\n \"Min - Max\" = min_max_fun,\n .formats = list(\"n\" = \"xx\", \"Mean (SD)\" = \"xx.xx (xx.xx)\", \"Median\" = \"xx.xx\", \"Min - Max\" = \"xx.xx - xx.xx\"),\n .format_na_strs = list(\"n\" = \"NE\", \"Mean (SD)\" = \"NE (NE)\", \"Median\" = \"NE\", \"Min - Max\" = \"NE - NE\")\n )\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = \"\\n\\nAnalysis Visit\") %>%\n split_cols_by_multivar(\n vars = c(\"AVAL\", \"CHG\"),\n varlabels = c(\"Value at Visit\", \"Change from\\nBaseline\")\n ) %>%\n analyze_colvars(afun = afun)\n\nresult <- build_table(lyt = lyt, df = advs_f, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination \n Change from Change from Change from \nAnalysis Visit Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline \n (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nSCREENING \n n 134 0 134 0 132 0 \n Mean (SD) 99.92 (17.99) NE (NE) 101.88 (21.07) NE (NE) 100.48 (19.07) NE (NE) \n Median 99.26 NE 100.22 NE 99.10 NE \n Min - Max 54.22 - 152.98 NE - NE 48.15 - 148.03 NE - NE 42.22 - 149.95 NE - NE \nBASELINE \n n 134 134 132 \n Mean (SD) 96.50 (19.90) 101.10 (19.87) 102.77 (19.48) \n Median 96.05 100.45 102.01 \n Min - Max 44.28 - 136.59 29.21 - 143.77 49.37 - 153.50 \nWEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 100.65 (18.79) 4.14 (26.93) 99.19 (19.36) -1.92 (27.37) 97.14 (19.72) -5.63 (25.95) \n Median 100.22 1.52 99.37 -2.79 94.19 -5.57 \n Min - Max 57.60 - 147.46 -50.92 - 74.84 59.28 - 141.21 -64.50 - 70.93 50.98 - 142.47 -55.15 - 56.11\nWEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 102.09 (19.62) 5.58 (29.38) 99.29 (21.11) -1.81 (31.11) 99.95 (20.85) -2.81 (29.10) \n Median 103.59 7.82 100.57 -1.77 102.52 -5.68 \n Min - Max 54.73 - 150.85 -59.71 - 98.08 51.60 - 145.28 -71.00 - 92.43 37.06 - 138.92 -73.10 - 76.80\nWEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 101.78 (19.54) 5.28 (27.16) 97.73 (19.85) -3.37 (27.76) 99.86 (19.15) -2.91 (27.25) \n Median 100.39 6.53 98.83 -5.79 100.06 -1.54 \n Min - Max 47.68 - 162.22 -64.46 - 76.64 36.25 - 142.78 -70.23 - 84.74 53.80 - 146.37 -74.30 - 67.46\nWEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 100.18 (20.18) 3.68 (27.21) 99.06 (17.75) -2.04 (26.59) 99.27 (20.12) -3.50 (27.62) \n Median 98.17 3.00 97.98 -1.89 99.61 -0.46 \n Min - Max 48.52 - 153.41 -77.30 - 61.90 56.78 - 142.45 -82.96 - 89.87 46.87 - 146.12 -88.68 - 70.90\nWEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 101.42 (18.83) 4.92 (28.02) 95.92 (19.90) -5.19 (29.34) 97.73 (18.92) -5.04 (26.64) \n Median 98.56 3.93 94.30 -7.18 98.09 -5.62 \n Min - Max 62.66 - 155.52 -63.05 - 78.66 51.06 - 151.52 -78.07 - 72.91 51.48 - 157.27 -76.13 - 86.42\nPost-Baseline Last \n n 134 134 134 134 132 132 \n Mean (SD) 101.42 (18.83) 4.92 (28.02) 95.92 (19.90) -5.19 (29.34) 97.73 (18.92) -5.04 (26.64) \n Median 98.56 3.93 94.30 -7.18 98.09 -5.62 \n Min - Max 62.66 - 155.52 -63.05 - 78.66 51.06 - 151.52 -78.07 - 72.91 51.48 - 157.27 -76.13 - 86.42\nPost-Baseline Minimum \n n 134 134 134 134 132 132 \n Mean (SD) 78.98 (11.94) -17.52 (23.92) 75.77 (13.25) -25.33 (25.39) 76.35 (13.13) -26.41 (22.78)\n Median 80.14 -13.96 75.71 -26.70 76.26 -27.17 \n Min - Max 47.68 - 110.54 -77.30 - 33.00 36.25 - 113.53 -82.96 - 69.23 37.06 - 112.35 -88.68 - 34.24\nPost-Baseline Maximum \n n 134 134 134 134 132 132 \n Mean (SD) 125.08 (12.28) 28.57 (23.20) 121.33 (12.01) 20.23 (23.64) 121.42 (12.09) 18.65 (22.74) \n Median 124.20 29.14 120.80 18.74 122.55 16.93 \n Min - Max 94.06 - 162.22 -21.49 - 98.08 94.43 - 151.52 -34.95 - 92.43 79.39 - 157.27 -43.32 - 86.42\n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\nadvs_label <- var_labels(advs)\n\n# post-baseline\nadvs_pb <- advs %>%\n filter(\n ABLFL != \"Y\",\n ABLFL2 != \"Y\"\n )\n\nadvs_pb_max <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVAL)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Maximum\")\n\nadvs_pb_min <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(AVAL) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Minimum\")\n\nadvs_pb_last <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVISITN)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Last\")\n\nadvs_f <- rbind(\n advs,\n advs_pb_last,\n advs_pb_min,\n advs_pb_max\n)\n\nadvs_f <- advs_f %>%\n mutate(AVISIT = droplevels(AVISIT))\n\nvar_labels(advs_f) <- advs_label\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'\n ),\n cdisc_dataset(\"ADVS\",\n advs_f,\n code = 'ADVS <- synthetic_cdisc_dataset(\"latest\", \"advs\")\n ADVS_label <- var_labels(ADVS)\n\n # post-baseline\n ADVS_pb <- ADVS %>%\n filter(\n ABLFL != \"Y\",\n ABLFL2 != \"Y\"\n )\n\n ADVS_pb_max <- ADVS_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVAL)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Maximum\")\n\n ADVS_pb_min <- ADVS_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(AVAL) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Minimum\")\n\n ADVS_pb_last <- ADVS_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVISITN)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Last\")\n\n ADVS_f <- rbind(\n ADVS,\n ADVS_pb_last,\n ADVS_pb_min,\n ADVS_pb_max\n )\n\n ADVS <- ADVS_f %>%\n mutate(AVISIT = droplevels(AVISIT))\n var_labels(ADVS) <- ADVS_label'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Vital Sign Results and Change from Baseline by Visit\",\n dataname = \"ADVS\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(advs, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\", \"PARAM\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(advs, c(\"AVAL\", \"CHG\")),\n selected = c(\"AVAL\", \"CHG\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(advs, \"PARAMCD\", \"PARAM\"),\n selected = \"DIABP\"\n ),\n parallel_vars = TRUE\n )\n ),\n filter = list(ADVS = list(AVAL = list()))\n)\n\n[INFO] 2023-09-08 19:35:46.6317 pid:3975 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] bslib_0.5.1 httpuv_1.6.11 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadvs <- df_explicit_na(advs)\n\nadvs_label <- var_labels(advs)\n\nadvs <- advs %>%\n filter(\n PARAMCD == \"DIABP\",\n PARAM == \"Diastolic Blood Pressure\"\n ) %>%\n mutate(\n PARAMCD = droplevels(PARAMCD),\n PARAM = droplevels(PARAM)\n )\n\n# post-baseline\nadvs_pb <- advs %>%\n filter(ABLFL != \"Y\", ABLFL2 != \"Y\")\n\nadvs_pb_max <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVAL)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Maximum\")\n\nadvs_pb_min <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(AVAL) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Minimum\")\n\nadvs_pb_last <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVISITN)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Last\")\n\n# Please note that for real data, per ADaM Spec 1.1, the advs_f can be obtained by filtering on PARAMCD, then\n# ANL01FL == 'Y' or AVISIT in c('POST-BASELINE MAXIMUM', 'POST-BASELINE MINIMUM', 'POST-BASELINE LAST')\n\nadvs_f <- rbind(\n advs,\n advs_pb_last,\n advs_pb_min,\n advs_pb_max\n)\n\nadvs_f <- advs_f %>%\n mutate(AVISIT = droplevels(AVISIT))\n\nvar_labels(advs_f) <- advs_label\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nafun <- function(x, .var, .spl_context, ...) {\n n_fun <- sum(!is.na(x), na.rm = TRUE)\n if (n_fun == 0) {\n mean_sd_fun <- c(NA, NA)\n median_fun <- NA\n min_max_fun <- c(NA, NA)\n } else {\n mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))\n median_fun <- median(x, na.rm = TRUE)\n min_max_fun <- c(min(x), max(x))\n }\n is_chg <- .var == \"CHG\"\n is_baseline <- .spl_context$value[which(.spl_context$split == \"AVISIT\")] == \"BASELINE\"\n if (is_baseline && is_chg) n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL\n\n in_rows(\n \"n\" = n_fun,\n \"Mean (SD)\" = mean_sd_fun,\n \"Median\" = median_fun,\n \"Min - Max\" = min_max_fun,\n .formats = list(\"n\" = \"xx\", \"Mean (SD)\" = \"xx.xx (xx.xx)\", \"Median\" = \"xx.xx\", \"Min - Max\" = \"xx.xx - xx.xx\"),\n .format_na_strs = list(\"n\" = \"NE\", \"Mean (SD)\" = \"NE (NE)\", \"Median\" = \"NE\", \"Min - Max\" = \"NE - NE\")\n )\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = \"\\n\\nAnalysis Visit\") %>%\n split_cols_by_multivar(\n vars = c(\"AVAL\", \"CHG\"),\n varlabels = c(\"Value at Visit\", \"Change from\\nBaseline\")\n ) %>%\n analyze_colvars(afun = afun)\n\nresult <- build_table(lyt = lyt, df = advs_f, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination \n Change from Change from Change from \nAnalysis Visit Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline \n (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nSCREENING \n n 134 0 134 0 132 0 \n Mean (SD) 99.92 (17.99) NE (NE) 101.88 (21.07) NE (NE) 100.48 (19.07) NE (NE) \n Median 99.26 NE 100.22 NE 99.10 NE \n Min - Max 54.22 - 152.98 NE - NE 48.15 - 148.03 NE - NE 42.22 - 149.95 NE - NE \nBASELINE \n n 134 134 132 \n Mean (SD) 96.50 (19.90) 101.10 (19.87) 102.77 (19.48) \n Median 96.05 100.45 102.01 \n Min - Max 44.28 - 136.59 29.21 - 143.77 49.37 - 153.50 \nWEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 100.65 (18.79) 4.14 (26.93) 99.19 (19.36) -1.92 (27.37) 97.14 (19.72) -5.63 (25.95) \n Median 100.22 1.52 99.37 -2.79 94.19 -5.57 \n Min - Max 57.60 - 147.46 -50.92 - 74.84 59.28 - 141.21 -64.50 - 70.93 50.98 - 142.47 -55.15 - 56.11\nWEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 102.09 (19.62) 5.58 (29.38) 99.29 (21.11) -1.81 (31.11) 99.95 (20.85) -2.81 (29.10) \n Median 103.59 7.82 100.57 -1.77 102.52 -5.68 \n Min - Max 54.73 - 150.85 -59.71 - 98.08 51.60 - 145.28 -71.00 - 92.43 37.06 - 138.92 -73.10 - 76.80\nWEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 101.78 (19.54) 5.28 (27.16) 97.73 (19.85) -3.37 (27.76) 99.86 (19.15) -2.91 (27.25) \n Median 100.39 6.53 98.83 -5.79 100.06 -1.54 \n Min - Max 47.68 - 162.22 -64.46 - 76.64 36.25 - 142.78 -70.23 - 84.74 53.80 - 146.37 -74.30 - 67.46\nWEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 100.18 (20.18) 3.68 (27.21) 99.06 (17.75) -2.04 (26.59) 99.27 (20.12) -3.50 (27.62) \n Median 98.17 3.00 97.98 -1.89 99.61 -0.46 \n Min - Max 48.52 - 153.41 -77.30 - 61.90 56.78 - 142.45 -82.96 - 89.87 46.87 - 146.12 -88.68 - 70.90\nWEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 101.42 (18.83) 4.92 (28.02) 95.92 (19.90) -5.19 (29.34) 97.73 (18.92) -5.04 (26.64) \n Median 98.56 3.93 94.30 -7.18 98.09 -5.62 \n Min - Max 62.66 - 155.52 -63.05 - 78.66 51.06 - 151.52 -78.07 - 72.91 51.48 - 157.27 -76.13 - 86.42\nPost-Baseline Last \n n 134 134 134 134 132 132 \n Mean (SD) 101.42 (18.83) 4.92 (28.02) 95.92 (19.90) -5.19 (29.34) 97.73 (18.92) -5.04 (26.64) \n Median 98.56 3.93 94.30 -7.18 98.09 -5.62 \n Min - Max 62.66 - 155.52 -63.05 - 78.66 51.06 - 151.52 -78.07 - 72.91 51.48 - 157.27 -76.13 - 86.42\nPost-Baseline Minimum \n n 134 134 134 134 132 132 \n Mean (SD) 78.98 (11.94) -17.52 (23.92) 75.77 (13.25) -25.33 (25.39) 76.35 (13.13) -26.41 (22.78)\n Median 80.14 -13.96 75.71 -26.70 76.26 -27.17 \n Min - Max 47.68 - 110.54 -77.30 - 33.00 36.25 - 113.53 -82.96 - 69.23 37.06 - 112.35 -88.68 - 34.24\nPost-Baseline Maximum \n n 134 134 134 134 132 132 \n Mean (SD) 125.08 (12.28) 28.57 (23.20) 121.33 (12.01) 20.23 (23.64) 121.42 (12.09) 18.65 (22.74) \n Median 124.20 29.14 120.80 18.74 122.55 16.93 \n Min - Max 94.06 - 162.22 -21.49 - 98.08 94.43 - 151.52 -34.95 - 92.43 79.39 - 157.27 -43.32 - 86.42\n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\nadvs_label <- var_labels(advs)\n\n# post-baseline\nadvs_pb <- advs %>%\n filter(\n ABLFL != \"Y\",\n ABLFL2 != \"Y\"\n )\n\nadvs_pb_max <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVAL)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Maximum\")\n\nadvs_pb_min <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(AVAL) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Minimum\")\n\nadvs_pb_last <- advs_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVISITN)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Last\")\n\nadvs_f <- rbind(\n advs,\n advs_pb_last,\n advs_pb_min,\n advs_pb_max\n)\n\nadvs_f <- advs_f %>%\n mutate(AVISIT = droplevels(AVISIT))\n\nvar_labels(advs_f) <- advs_label\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'\n ),\n cdisc_dataset(\"ADVS\",\n advs_f,\n code = 'ADVS <- synthetic_cdisc_dataset(\"latest\", \"advs\")\n ADVS_label <- var_labels(ADVS)\n\n # post-baseline\n ADVS_pb <- ADVS %>%\n filter(\n ABLFL != \"Y\",\n ABLFL2 != \"Y\"\n )\n\n ADVS_pb_max <- ADVS_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVAL)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Maximum\")\n\n ADVS_pb_min <- ADVS_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(AVAL) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Minimum\")\n\n ADVS_pb_last <- ADVS_pb %>%\n group_by(PARAM, USUBJID) %>%\n arrange(desc(AVISITN)) %>%\n slice(1) %>%\n ungroup() %>%\n mutate(AVISIT = \"Post-Baseline Last\")\n\n ADVS_f <- rbind(\n ADVS,\n ADVS_pb_last,\n ADVS_pb_min,\n ADVS_pb_max\n )\n\n ADVS <- ADVS_f %>%\n mutate(AVISIT = droplevels(AVISIT))\n var_labels(ADVS) <- ADVS_label'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Vital Sign Results and Change from Baseline by Visit\",\n dataname = \"ADVS\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(advs, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\", \"PARAM\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(advs, c(\"AVAL\", \"CHG\")),\n selected = c(\"AVAL\", \"CHG\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(advs, \"PARAMCD\", \"PARAM\"),\n selected = \"DIABP\"\n ),\n parallel_vars = TRUE\n )\n ),\n filter = list(ADVS = list(AVAL = list()))\n)\n\n[INFO] 2023-09-09 17:53:34.0121 pid:3980 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] bslib_0.5.1 httpuv_1.6.11 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/vst02.html",
"href": "tables/safety/vst02.html",
"title": "VST02",
"section": "",
- "text": "Data Setup\nVST02_1 – Table of Abnormalities Regardless of Abnormality at Baseline\nVST02_2 – Table of Abnormalities Among Subjects Without Abnormality at Baseline\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\n\n# Ensure character variables are converted to factors and empty strings\n# and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadvs <- df_explicit_na(advs)\n\n# Note: We keep only post-baseline for analysis.\nadvs_f <- advs %>%\n filter(ONTRTFL == \"Y\", ANRIND != \"<Missing>\") %>%\n var_relabel(\n PARAM = \"Assessment\",\n ANRIND = \"Abnormality\"\n )\n\n# If you want to control which parameters in the table have only `LOW` or only `HIGH` theoretical ranges defined,\n# see `tern::h_map_for_count_abnormal` with method \"range\" or refer to the `EGT02` example.\n# For `VST02` we want to keep both directions for all parameters so we will not use `trim_levels_to_map` as the split function.\nsplit_fun <- drop_split_levels\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(advs_f$PARAM)) %>%\n count_abnormal(\n \"ANRIND\",\n abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")),\n exclude_base_abn = FALSE\n ) %>%\n append_varlabels(advs_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = advs_f, alt_counts_df = adsl)\n\nresult\n\nAssessment A: Drug X B: Placebo C: Combination All Patients \n Abnormality (N=134) (N=134) (N=132) (N=400) \n————————————————————————————————————————————————————————————————————————————————————————————————\nDiastolic Blood Pressure \n Low 66/134 (49.3%) 86/134 (64.2%) 78/132 (59.1%) 230/400 (57.5%)\n High 88/134 (65.7%) 70/134 (52.2%) 76/132 (57.6%) 234/400 (58.5%)\nPulse Rate \n Low 58/134 (43.3%) 32/134 (23.9%) 48/132 (36.4%) 138/400 (34.5%)\n High 53/134 (39.6%) 49/134 (36.6%) 44/132 (33.3%) 146/400 (36.5%)\nRespiratory Rate \n Low 97/134 (72.4%) 84/134 (62.7%) 98/132 (74.2%) 279/400 (69.8%)\n High 96/134 (71.6%) 98/134 (73.1%) 98/132 (74.2%) 292/400 (73%) \nSystolic Blood Pressure \n Low 71/134 (53%) 77/134 (57.5%) 73/132 (55.3%) 221/400 (55.2%)\n High 78/134 (58.2%) 74/134 (55.2%) 73/132 (55.3%) 225/400 (56.2%)\nTemperature \n Low 108/134 (80.6%) 110/134 (82.1%) 108/132 (81.8%) 326/400 (81.5%)\n High 112/134 (83.6%) 106/134 (79.1%) 107/132 (81.1%) 325/400 (81.2%)\nWeight \n Low 43/134 (32.1%) 39/134 (29.1%) 39/132 (29.5%) 121/400 (30.2%)\n High 46/134 (34.3%) 43/134 (32.1%) 44/132 (33.3%) 133/400 (33.2%)\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(advs_f$PARAM)) %>%\n count_abnormal(\n \"ANRIND\",\n abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")),\n exclude_base_abn = TRUE\n ) %>%\n append_varlabels(advs_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = advs_f, alt_counts_df = adsl)\n\nresult\n\nAssessment A: Drug X B: Placebo C: Combination All Patients \n Abnormality (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————————————\nDiastolic Blood Pressure \n Low 54/108 (50%) 76/116 (65.5%) 68/114 (59.6%) 198/338 (58.6%)\n High 74/114 (64.9%) 56/109 (51.4%) 62/106 (58.5%) 192/329 (58.4%)\nPulse Rate \n Low 53/121 (43.8%) 30/125 (24%) 42/119 (35.3%) 125/365 (34.2%)\n High 48/123 (39%) 45/116 (38.8%) 39/120 (32.5%) 132/359 (36.8%)\nRespiratory Rate \n Low 72/100 (72%) 72/110 (65.5%) 79/102 (77.5%) 223/312 (71.5%)\n High 77/107 (72%) 78/108 (72.2%) 79/109 (72.5%) 234/324 (72.2%)\nSystolic Blood Pressure \n Low 62/117 (53%) 63/114 (55.3%) 57/103 (55.3%) 182/334 (54.5%)\n High 64/110 (58.2%) 67/120 (55.8%) 68/115 (59.1%) 199/345 (57.7%)\nTemperature \n Low 77/96 (80.2%) 78/94 (83%) 74/90 (82.2%) 229/280 (81.8%)\n High 78/93 (83.9%) 73/92 (79.3%) 81/100 (81%) 232/285 (81.4%)\nWeight \n Low 42/129 (32.6%) 37/125 (29.6%) 37/123 (30.1%) 116/377 (30.8%)\n High 41/126 (32.5%) 41/124 (33.1%) 42/121 (34.7%) 124/371 (33.4%)\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\") %>%\n mutate(ONTRTFL = ifelse(AVISIT %in% c(\"SCREENING\", \"BASELINE\"), \"\", \"Y\")) %>%\n var_relabel(ONTRTFL = \"On Treatment Record Flag\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADVS\", advs, code = 'ADVS <- synthetic_cdisc_dataset(\"latest\", \"advs\") %>%\n mutate(ONTRTFL = ifelse(AVISIT %in% c(\"SCREENING\", \"BASELINE\"), \"\", \"Y\")) %>%\n var_relabel(ONTRTFL = \"On Treatment Record Flag\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality(\n label = \"Abnormality Table\",\n dataname = \"ADVS\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(advs, subset = c(\"VSCAT\", \"PARAM\", \"AVISIT\")),\n selected = c(\"PARAM\"),\n keep_order = TRUE\n ),\n grade = choices_selected(\n choices = variable_choices(advs, subset = \"ANRIND\"),\n selected = \"ANRIND\",\n fixed = TRUE\n ),\n abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")),\n exclude_base_abn = FALSE\n )\n )\n)\n\n[INFO] 2023-09-08 19:35:13.4160 pid:3826 token:[] teal.modules.clinical Initializing tm_t_abnormality\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nVST02_1 – Table of Abnormalities Regardless of Abnormality at Baseline\nVST02_2 – Table of Abnormalities Among Subjects Without Abnormality at Baseline\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\n\n# Ensure character variables are converted to factors and empty strings\n# and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadvs <- df_explicit_na(advs)\n\n# Note: We keep only post-baseline for analysis.\nadvs_f <- advs %>%\n filter(ONTRTFL == \"Y\", ANRIND != \"<Missing>\") %>%\n var_relabel(\n PARAM = \"Assessment\",\n ANRIND = \"Abnormality\"\n )\n\n# If you want to control which parameters in the table have only `LOW` or only `HIGH` theoretical ranges defined,\n# see `tern::h_map_for_count_abnormal` with method \"range\" or refer to the `EGT02` example.\n# For `VST02` we want to keep both directions for all parameters so we will not use `trim_levels_to_map` as the split function.\nsplit_fun <- drop_split_levels\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(advs_f$PARAM)) %>%\n count_abnormal(\n \"ANRIND\",\n abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")),\n exclude_base_abn = FALSE\n ) %>%\n append_varlabels(advs_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = advs_f, alt_counts_df = adsl)\n\nresult\n\nAssessment A: Drug X B: Placebo C: Combination All Patients \n Abnormality (N=134) (N=134) (N=132) (N=400) \n————————————————————————————————————————————————————————————————————————————————————————————————\nDiastolic Blood Pressure \n Low 66/134 (49.3%) 86/134 (64.2%) 78/132 (59.1%) 230/400 (57.5%)\n High 88/134 (65.7%) 70/134 (52.2%) 76/132 (57.6%) 234/400 (58.5%)\nPulse Rate \n Low 58/134 (43.3%) 32/134 (23.9%) 48/132 (36.4%) 138/400 (34.5%)\n High 53/134 (39.6%) 49/134 (36.6%) 44/132 (33.3%) 146/400 (36.5%)\nRespiratory Rate \n Low 97/134 (72.4%) 84/134 (62.7%) 98/132 (74.2%) 279/400 (69.8%)\n High 96/134 (71.6%) 98/134 (73.1%) 98/132 (74.2%) 292/400 (73%) \nSystolic Blood Pressure \n Low 71/134 (53%) 77/134 (57.5%) 73/132 (55.3%) 221/400 (55.2%)\n High 78/134 (58.2%) 74/134 (55.2%) 73/132 (55.3%) 225/400 (56.2%)\nTemperature \n Low 108/134 (80.6%) 110/134 (82.1%) 108/132 (81.8%) 326/400 (81.5%)\n High 112/134 (83.6%) 106/134 (79.1%) 107/132 (81.1%) 325/400 (81.2%)\nWeight \n Low 43/134 (32.1%) 39/134 (29.1%) 39/132 (29.5%) 121/400 (30.2%)\n High 46/134 (34.3%) 43/134 (32.1%) 44/132 (33.3%) 133/400 (33.2%)\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(advs_f$PARAM)) %>%\n count_abnormal(\n \"ANRIND\",\n abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")),\n exclude_base_abn = TRUE\n ) %>%\n append_varlabels(advs_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = advs_f, alt_counts_df = adsl)\n\nresult\n\nAssessment A: Drug X B: Placebo C: Combination All Patients \n Abnormality (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————————————\nDiastolic Blood Pressure \n Low 54/108 (50%) 76/116 (65.5%) 68/114 (59.6%) 198/338 (58.6%)\n High 74/114 (64.9%) 56/109 (51.4%) 62/106 (58.5%) 192/329 (58.4%)\nPulse Rate \n Low 53/121 (43.8%) 30/125 (24%) 42/119 (35.3%) 125/365 (34.2%)\n High 48/123 (39%) 45/116 (38.8%) 39/120 (32.5%) 132/359 (36.8%)\nRespiratory Rate \n Low 72/100 (72%) 72/110 (65.5%) 79/102 (77.5%) 223/312 (71.5%)\n High 77/107 (72%) 78/108 (72.2%) 79/109 (72.5%) 234/324 (72.2%)\nSystolic Blood Pressure \n Low 62/117 (53%) 63/114 (55.3%) 57/103 (55.3%) 182/334 (54.5%)\n High 64/110 (58.2%) 67/120 (55.8%) 68/115 (59.1%) 199/345 (57.7%)\nTemperature \n Low 77/96 (80.2%) 78/94 (83%) 74/90 (82.2%) 229/280 (81.8%)\n High 78/93 (83.9%) 73/92 (79.3%) 81/100 (81%) 232/285 (81.4%)\nWeight \n Low 42/129 (32.6%) 37/125 (29.6%) 37/123 (30.1%) 116/377 (30.8%)\n High 41/126 (32.5%) 41/124 (33.1%) 42/121 (34.7%) 124/371 (33.4%)\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\") %>%\n mutate(ONTRTFL = ifelse(AVISIT %in% c(\"SCREENING\", \"BASELINE\"), \"\", \"Y\")) %>%\n var_relabel(ONTRTFL = \"On Treatment Record Flag\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADVS\", advs, code = 'ADVS <- synthetic_cdisc_dataset(\"latest\", \"advs\") %>%\n mutate(ONTRTFL = ifelse(AVISIT %in% c(\"SCREENING\", \"BASELINE\"), \"\", \"Y\")) %>%\n var_relabel(ONTRTFL = \"On Treatment Record Flag\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality(\n label = \"Abnormality Table\",\n dataname = \"ADVS\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(advs, subset = c(\"VSCAT\", \"PARAM\", \"AVISIT\")),\n selected = c(\"PARAM\"),\n keep_order = TRUE\n ),\n grade = choices_selected(\n choices = variable_choices(advs, subset = \"ANRIND\"),\n selected = \"ANRIND\",\n fixed = TRUE\n ),\n abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")),\n exclude_base_abn = FALSE\n )\n )\n)\n\n[INFO] 2023-09-09 17:52:47.9319 pid:3831 token:[] teal.modules.clinical Initializing tm_t_abnormality\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/dmt01.html",
"href": "tables/safety/dmt01.html",
"title": "DMT01",
"section": "",
- "text": "Data Setup\nTable with an Additional Study-Specific Continuous Variable\nTable with an Additional Study-Specific Categorical Variable\nTable with Subgrouping for Some Analyses\nTable with Additional Vital Signs Baseline Values\nTable with Additional Values from ADSUB\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\nlibrary(tidyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\nadsub <- synthetic_cdisc_dataset(\"latest\", \"adsub\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadvs <- df_explicit_na(advs)\nadsub <- df_explicit_na(adsub)\n\n# Change description in variable SEX.\nadsl <- adsl %>%\n mutate(\n SEX = factor(case_when(\n SEX == \"M\" ~ \"Male\",\n SEX == \"F\" ~ \"Female\",\n SEX == \"U\" ~ \"Unknown\",\n SEX == \"UNDIFFERENTIATED\" ~ \"Undifferentiated\"\n )),\n AGEGR1 = factor(\n case_when(\n between(AGE, 18, 40) ~ \"18-40\",\n between(AGE, 41, 64) ~ \"41-64\",\n AGE > 64 ~ \">=65\"\n ),\n levels = c(\"18-40\", \"41-64\", \">=65\")\n ),\n BMRKR1_CAT = factor(\n case_when(\n BMRKR1 < 3.5 ~ \"LOW\",\n BMRKR1 >= 3.5 & BMRKR1 < 10 ~ \"MEDIUM\",\n BMRKR1 >= 10 ~ \"HIGH\"\n ),\n levels = c(\"LOW\", \"MEDIUM\", \"HIGH\")\n )\n ) %>%\n var_relabel(\n BMRKR1_CAT = \"Biomarker 1 Categories\"\n )\n# The developer needs to do pre-processing to add necessary variables based on ADVS to analysis dataset.\n# Obtain SBP, DBP and weight.\nget_param_advs <- function(pname, plabel) {\n ds <- advs %>%\n filter(PARAM == plabel & AVISIT == \"BASELINE\") %>%\n select(USUBJID, AVAL)\n\n colnames(ds) <- c(\"USUBJID\", pname)\n\n ds\n}\n# The developer needs to do pre-processing to add necessary variables based on ADSUB to analysis dataset.\n# Obtain baseline BMI (BBMISI).\nget_param_adsub <- function(pname, plabel) {\n ds <- adsub %>%\n filter(PARAM == plabel) %>%\n select(USUBJID, AVAL)\n\n colnames(ds) <- c(\"USUBJID\", pname)\n\n ds\n}\nadsl <- adsl %>%\n left_join(get_param_advs(\"SBP\", \"Systolic Blood Pressure\"), by = \"USUBJID\") %>%\n left_join(get_param_advs(\"DBP\", \"Diastolic Blood Pressure\"), by = \"USUBJID\") %>%\n left_join(get_param_advs(\"WGT\", \"Weight\"), by = \"USUBJID\") %>%\n left_join(get_param_adsub(\"BBMISI\", \"Baseline BMI\"), by = \"USUBJID\")\n\n\n\n\n\nCodevars <- c(\"AGE\", \"AGEGR1\", \"SEX\", \"ETHNIC\", \"RACE\", \"BMRKR1\")\nvar_labels <- c(\n \"Age (yr)\",\n \"Age Group\",\n \"Sex\",\n \"Ethnicity\",\n \"Race\",\n \"Continous Level Biomarker 1\"\n)\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n analyze_vars(\n vars = vars,\n var_labels = var_labels\n ) %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————————————————\nAge (yr) \n n 134 134 132 400 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) 34.9 (7.4) \n Median 33.0 35.0 35.0 34.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 \nAge Group \n n 134 134 132 400 \n 18-40 113 (84.3%) 103 (76.9%) 106 (80.3%) 322 (80.5%) \n 41-64 21 (15.7%) 31 (23.1%) 25 (18.9%) 77 (19.2%) \n >=65 0 0 1 (0.8%) 1 (0.2%) \nSex \n n 134 134 132 400 \n Female 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) \n Male 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) \nEthnicity \n n 134 134 132 400 \n HISPANIC OR LATINO 15 (11.2%) 18 (13.4%) 15 (11.4%) 48 (12%) \n NOT HISPANIC OR LATINO 104 (77.6%) 103 (76.9%) 101 (76.5%) 308 (77%) \n NOT REPORTED 6 (4.5%) 10 (7.5%) 11 (8.3%) 27 (6.8%) \n UNKNOWN 9 (6.7%) 3 (2.2%) 5 (3.8%) 17 (4.2%) \nRace \n n 134 134 132 400 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) 208 (52%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) 91 (22.8%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) 74 (18.5%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) 25 (6.2%) \n MULTIPLE 0 1 (0.7%) 0 1 (0.2%) \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 1 (0.2%) \n OTHER 0 0 0 0 \n UNKNOWN 0 0 0 0 \nContinous Level Biomarker 1 \n n 134 134 132 400 \n Mean (SD) 6.0 (3.6) 5.7 (3.3) 5.6 (3.5) 5.8 (3.4) \n Median 5.4 4.8 4.6 4.8 \n Min - Max 0.4 - 17.7 0.6 - 14.2 0.2 - 21.4 0.2 - 21.4 \n\n\n\n\n\nCodevars <- c(\"AGE\", \"AGEGR1\", \"SEX\", \"ETHNIC\", \"RACE\", \"BMRKR1_CAT\")\nvar_labels <- c(\n \"Age (yr)\",\n \"Age Group\",\n \"Sex\",\n \"Ethnicity\",\n \"Race\",\n \"Biomarker 1 Categories\"\n)\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_vars(\n vars = vars,\n var_labels = var_labels\n ) %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————\nAge (yr) \n n 134 134 132 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) \n Median 33.0 35.0 35.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 \nAge Group \n n 134 134 132 \n 18-40 113 (84.3%) 103 (76.9%) 106 (80.3%) \n 41-64 21 (15.7%) 31 (23.1%) 25 (18.9%) \n >=65 0 0 1 (0.8%) \nSex \n n 134 134 132 \n Female 79 (59%) 82 (61.2%) 70 (53%) \n Male 55 (41%) 52 (38.8%) 62 (47%) \nEthnicity \n n 134 134 132 \n HISPANIC OR LATINO 15 (11.2%) 18 (13.4%) 15 (11.4%) \n NOT HISPANIC OR LATINO 104 (77.6%) 103 (76.9%) 101 (76.5%) \n NOT REPORTED 6 (4.5%) 10 (7.5%) 11 (8.3%) \n UNKNOWN 9 (6.7%) 3 (2.2%) 5 (3.8%) \nRace \n n 134 134 132 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) \n MULTIPLE 0 1 (0.7%) 0 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 \n OTHER 0 0 0 \n UNKNOWN 0 0 0 \nBiomarker 1 Categories \n n 134 134 132 \n LOW 33 (24.6%) 41 (30.6%) 38 (28.8%) \n MEDIUM 84 (62.7%) 76 (56.7%) 80 (60.6%) \n HIGH 17 (12.7%) 17 (12.7%) 14 (10.6%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_vars(\n vars = c(\"AGE\", \"SEX\", \"RACE\"),\n var_labels = c(\"Age\", \"Sex\", \"Race\")\n ) %>%\n split_rows_by(\"STRATA1\",\n split_fun = split_fun\n ) %>%\n analyze_vars(\"BMRKR1\") %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————\nAge \n n 134 134 132 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) \n Median 33.0 35.0 35.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 \nSex \n n 134 134 132 \n Female 79 (59%) 82 (61.2%) 70 (53%) \n Male 55 (41%) 52 (38.8%) 62 (47%) \nRace \n n 134 134 132 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) \n MULTIPLE 0 1 (0.7%) 0 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 \n OTHER 0 0 0 \n UNKNOWN 0 0 0 \nA \n n 38 44 40 \n Mean (SD) 5.8 (3.8) 5.4 (3.2) 5.1 (3.2) \n Median 5.1 4.5 3.8 \n Min - Max 0.4 - 17.7 1.4 - 14.2 1.5 - 14.0 \nB \n n 47 45 43 \n Mean (SD) 6.1 (3.6) 5.8 (3.6) 5.7 (3.4) \n Median 5.2 4.8 5.1 \n Min - Max 1.6 - 17.2 0.6 - 13.3 0.2 - 16.5 \nC \n n 49 45 49 \n Mean (SD) 6.0 (3.4) 5.9 (3.2) 6.0 (3.8) \n Median 5.8 5.6 4.5 \n Min - Max 0.5 - 15.1 1.5 - 13.9 1.2 - 21.4 \n\n\n\n\n\nCoderesult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_vars(\n vars = c(\"AGE\", \"SEX\", \"RACE\", \"DBP\", \"SBP\"),\n var_labels = c(\n \"Age (yr)\",\n \"Sex\",\n \"Race\",\n \"Diastolic Blood Pressure\",\n \"Systolic Blood Pressure\"\n )\n ) %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————\nAge (yr) \n n 134 134 132 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) \n Median 33.0 35.0 35.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 \nSex \n n 134 134 132 \n Female 79 (59%) 82 (61.2%) 70 (53%) \n Male 55 (41%) 52 (38.8%) 62 (47%) \nRace \n n 134 134 132 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) \n MULTIPLE 0 1 (0.7%) 0 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 \n OTHER 0 0 0 \n UNKNOWN 0 0 0 \nDiastolic Blood Pressure \n n 134 134 132 \n Mean (SD) 96.5 (19.9) 101.1 (19.9) 102.8 (19.5) \n Median 96.0 100.4 102.0 \n Min - Max 44.3 - 136.6 29.2 - 143.8 49.4 - 153.5 \nSystolic Blood Pressure \n n 134 134 132 \n Mean (SD) 151.7 (31.5) 149.5 (26.5) 144.7 (30.1) \n Median 150.1 153.0 146.5 \n Min - Max 69.1 - 231.2 87.2 - 220.9 71.8 - 220.2 \n\n\n\n\n\nCoderesult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_vars(\n vars = c(\"AGE\", \"SEX\", \"RACE\", \"BBMISI\"),\n var_labels = c(\n \"Age (yr)\",\n \"Sex\",\n \"Race\",\n \"Baseline BMI\"\n )\n ) %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————\nAge (yr) \n n 134 134 132 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) \n Median 33.0 35.0 35.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 \nSex \n n 134 134 132 \n Female 79 (59%) 82 (61.2%) 70 (53%) \n Male 55 (41%) 52 (38.8%) 62 (47%) \nRace \n n 134 134 132 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) \n MULTIPLE 0 1 (0.7%) 0 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 \n OTHER 0 0 0 \n UNKNOWN 0 0 0 \nBaseline BMI \n n 134 134 132 \n Mean (SD) 30.0 (18.3) 32.4 (23.2) 30.1 (18.4) \n Median 27.1 31.1 30.0 \n Min - Max -6.9 - 75.9 -26.6 - 117.9 -44.2 - 87.5 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n\n# Include `EOSDY` and `DCSREAS` variables below because they contain missing data.\nstopifnot(\n any(is.na(adsl$EOSDY)),\n any(is.na(adsl$DCSREAS))\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")',\n check = TRUE\n ),\n modules = modules(\n tm_t_summary(\n label = \"Demographic Table\",\n dataname = \"ADSL\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n summarize_vars = choices_selected(\n c(\"SEX\", \"RACE\", \"BMRKR2\", \"EOSDY\", \"DCSREAS\"),\n c(\"SEX\", \"RACE\")\n ),\n useNA = \"ifany\"\n )\n )\n)\n\n[INFO] 2023-09-08 19:33:59.5890 pid:3630 token:[] teal.modules.clinical Initializing tm_t_summary\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tidyr_1.3.0 dplyr_1.1.2 \n [9] scda_0.1.6.9012 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nTable with an Additional Study-Specific Continuous Variable\nTable with an Additional Study-Specific Categorical Variable\nTable with Subgrouping for Some Analyses\nTable with Additional Vital Signs Baseline Values\nTable with Additional Values from ADSUB\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\nlibrary(tidyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\nadsub <- synthetic_cdisc_dataset(\"latest\", \"adsub\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadvs <- df_explicit_na(advs)\nadsub <- df_explicit_na(adsub)\n\n# Change description in variable SEX.\nadsl <- adsl %>%\n mutate(\n SEX = factor(case_when(\n SEX == \"M\" ~ \"Male\",\n SEX == \"F\" ~ \"Female\",\n SEX == \"U\" ~ \"Unknown\",\n SEX == \"UNDIFFERENTIATED\" ~ \"Undifferentiated\"\n )),\n AGEGR1 = factor(\n case_when(\n between(AGE, 18, 40) ~ \"18-40\",\n between(AGE, 41, 64) ~ \"41-64\",\n AGE > 64 ~ \">=65\"\n ),\n levels = c(\"18-40\", \"41-64\", \">=65\")\n ),\n BMRKR1_CAT = factor(\n case_when(\n BMRKR1 < 3.5 ~ \"LOW\",\n BMRKR1 >= 3.5 & BMRKR1 < 10 ~ \"MEDIUM\",\n BMRKR1 >= 10 ~ \"HIGH\"\n ),\n levels = c(\"LOW\", \"MEDIUM\", \"HIGH\")\n )\n ) %>%\n var_relabel(\n BMRKR1_CAT = \"Biomarker 1 Categories\"\n )\n# The developer needs to do pre-processing to add necessary variables based on ADVS to analysis dataset.\n# Obtain SBP, DBP and weight.\nget_param_advs <- function(pname, plabel) {\n ds <- advs %>%\n filter(PARAM == plabel & AVISIT == \"BASELINE\") %>%\n select(USUBJID, AVAL)\n\n colnames(ds) <- c(\"USUBJID\", pname)\n\n ds\n}\n# The developer needs to do pre-processing to add necessary variables based on ADSUB to analysis dataset.\n# Obtain baseline BMI (BBMISI).\nget_param_adsub <- function(pname, plabel) {\n ds <- adsub %>%\n filter(PARAM == plabel) %>%\n select(USUBJID, AVAL)\n\n colnames(ds) <- c(\"USUBJID\", pname)\n\n ds\n}\nadsl <- adsl %>%\n left_join(get_param_advs(\"SBP\", \"Systolic Blood Pressure\"), by = \"USUBJID\") %>%\n left_join(get_param_advs(\"DBP\", \"Diastolic Blood Pressure\"), by = \"USUBJID\") %>%\n left_join(get_param_advs(\"WGT\", \"Weight\"), by = \"USUBJID\") %>%\n left_join(get_param_adsub(\"BBMISI\", \"Baseline BMI\"), by = \"USUBJID\")\n\n\n\n\n\nCodevars <- c(\"AGE\", \"AGEGR1\", \"SEX\", \"ETHNIC\", \"RACE\", \"BMRKR1\")\nvar_labels <- c(\n \"Age (yr)\",\n \"Age Group\",\n \"Sex\",\n \"Ethnicity\",\n \"Race\",\n \"Continous Level Biomarker 1\"\n)\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n analyze_vars(\n vars = vars,\n var_labels = var_labels\n ) %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————————————————\nAge (yr) \n n 134 134 132 400 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) 34.9 (7.4) \n Median 33.0 35.0 35.0 34.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 \nAge Group \n n 134 134 132 400 \n 18-40 113 (84.3%) 103 (76.9%) 106 (80.3%) 322 (80.5%) \n 41-64 21 (15.7%) 31 (23.1%) 25 (18.9%) 77 (19.2%) \n >=65 0 0 1 (0.8%) 1 (0.2%) \nSex \n n 134 134 132 400 \n Female 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) \n Male 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) \nEthnicity \n n 134 134 132 400 \n HISPANIC OR LATINO 15 (11.2%) 18 (13.4%) 15 (11.4%) 48 (12%) \n NOT HISPANIC OR LATINO 104 (77.6%) 103 (76.9%) 101 (76.5%) 308 (77%) \n NOT REPORTED 6 (4.5%) 10 (7.5%) 11 (8.3%) 27 (6.8%) \n UNKNOWN 9 (6.7%) 3 (2.2%) 5 (3.8%) 17 (4.2%) \nRace \n n 134 134 132 400 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) 208 (52%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) 91 (22.8%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) 74 (18.5%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) 25 (6.2%) \n MULTIPLE 0 1 (0.7%) 0 1 (0.2%) \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 1 (0.2%) \n OTHER 0 0 0 0 \n UNKNOWN 0 0 0 0 \nContinous Level Biomarker 1 \n n 134 134 132 400 \n Mean (SD) 6.0 (3.6) 5.7 (3.3) 5.6 (3.5) 5.8 (3.4) \n Median 5.4 4.8 4.6 4.8 \n Min - Max 0.4 - 17.7 0.6 - 14.2 0.2 - 21.4 0.2 - 21.4 \n\n\n\n\n\nCodevars <- c(\"AGE\", \"AGEGR1\", \"SEX\", \"ETHNIC\", \"RACE\", \"BMRKR1_CAT\")\nvar_labels <- c(\n \"Age (yr)\",\n \"Age Group\",\n \"Sex\",\n \"Ethnicity\",\n \"Race\",\n \"Biomarker 1 Categories\"\n)\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_vars(\n vars = vars,\n var_labels = var_labels\n ) %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————\nAge (yr) \n n 134 134 132 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) \n Median 33.0 35.0 35.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 \nAge Group \n n 134 134 132 \n 18-40 113 (84.3%) 103 (76.9%) 106 (80.3%) \n 41-64 21 (15.7%) 31 (23.1%) 25 (18.9%) \n >=65 0 0 1 (0.8%) \nSex \n n 134 134 132 \n Female 79 (59%) 82 (61.2%) 70 (53%) \n Male 55 (41%) 52 (38.8%) 62 (47%) \nEthnicity \n n 134 134 132 \n HISPANIC OR LATINO 15 (11.2%) 18 (13.4%) 15 (11.4%) \n NOT HISPANIC OR LATINO 104 (77.6%) 103 (76.9%) 101 (76.5%) \n NOT REPORTED 6 (4.5%) 10 (7.5%) 11 (8.3%) \n UNKNOWN 9 (6.7%) 3 (2.2%) 5 (3.8%) \nRace \n n 134 134 132 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) \n MULTIPLE 0 1 (0.7%) 0 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 \n OTHER 0 0 0 \n UNKNOWN 0 0 0 \nBiomarker 1 Categories \n n 134 134 132 \n LOW 33 (24.6%) 41 (30.6%) 38 (28.8%) \n MEDIUM 84 (62.7%) 76 (56.7%) 80 (60.6%) \n HIGH 17 (12.7%) 17 (12.7%) 14 (10.6%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_vars(\n vars = c(\"AGE\", \"SEX\", \"RACE\"),\n var_labels = c(\"Age\", \"Sex\", \"Race\")\n ) %>%\n split_rows_by(\"STRATA1\",\n split_fun = split_fun\n ) %>%\n analyze_vars(\"BMRKR1\") %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————\nAge \n n 134 134 132 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) \n Median 33.0 35.0 35.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 \nSex \n n 134 134 132 \n Female 79 (59%) 82 (61.2%) 70 (53%) \n Male 55 (41%) 52 (38.8%) 62 (47%) \nRace \n n 134 134 132 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) \n MULTIPLE 0 1 (0.7%) 0 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 \n OTHER 0 0 0 \n UNKNOWN 0 0 0 \nA \n n 38 44 40 \n Mean (SD) 5.8 (3.8) 5.4 (3.2) 5.1 (3.2) \n Median 5.1 4.5 3.8 \n Min - Max 0.4 - 17.7 1.4 - 14.2 1.5 - 14.0 \nB \n n 47 45 43 \n Mean (SD) 6.1 (3.6) 5.8 (3.6) 5.7 (3.4) \n Median 5.2 4.8 5.1 \n Min - Max 1.6 - 17.2 0.6 - 13.3 0.2 - 16.5 \nC \n n 49 45 49 \n Mean (SD) 6.0 (3.4) 5.9 (3.2) 6.0 (3.8) \n Median 5.8 5.6 4.5 \n Min - Max 0.5 - 15.1 1.5 - 13.9 1.2 - 21.4 \n\n\n\n\n\nCoderesult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_vars(\n vars = c(\"AGE\", \"SEX\", \"RACE\", \"DBP\", \"SBP\"),\n var_labels = c(\n \"Age (yr)\",\n \"Sex\",\n \"Race\",\n \"Diastolic Blood Pressure\",\n \"Systolic Blood Pressure\"\n )\n ) %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————\nAge (yr) \n n 134 134 132 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) \n Median 33.0 35.0 35.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 \nSex \n n 134 134 132 \n Female 79 (59%) 82 (61.2%) 70 (53%) \n Male 55 (41%) 52 (38.8%) 62 (47%) \nRace \n n 134 134 132 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) \n MULTIPLE 0 1 (0.7%) 0 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 \n OTHER 0 0 0 \n UNKNOWN 0 0 0 \nDiastolic Blood Pressure \n n 134 134 132 \n Mean (SD) 96.5 (19.9) 101.1 (19.9) 102.8 (19.5) \n Median 96.0 100.4 102.0 \n Min - Max 44.3 - 136.6 29.2 - 143.8 49.4 - 153.5 \nSystolic Blood Pressure \n n 134 134 132 \n Mean (SD) 151.7 (31.5) 149.5 (26.5) 144.7 (30.1) \n Median 150.1 153.0 146.5 \n Min - Max 69.1 - 231.2 87.2 - 220.9 71.8 - 220.2 \n\n\n\n\n\nCoderesult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_vars(\n vars = c(\"AGE\", \"SEX\", \"RACE\", \"BBMISI\"),\n var_labels = c(\n \"Age (yr)\",\n \"Sex\",\n \"Race\",\n \"Baseline BMI\"\n )\n ) %>%\n build_table(adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————\nAge (yr) \n n 134 134 132 \n Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) \n Median 33.0 35.0 35.0 \n Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 \nSex \n n 134 134 132 \n Female 79 (59%) 82 (61.2%) 70 (53%) \n Male 55 (41%) 52 (38.8%) 62 (47%) \nRace \n n 134 134 132 \n ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) \n BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) \n WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) \n AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) \n MULTIPLE 0 1 (0.7%) 0 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 \n OTHER 0 0 0 \n UNKNOWN 0 0 0 \nBaseline BMI \n n 134 134 132 \n Mean (SD) 30.0 (18.3) 32.4 (23.2) 30.1 (18.4) \n Median 27.1 31.1 30.0 \n Min - Max -6.9 - 75.9 -26.6 - 117.9 -44.2 - 87.5 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n\n# Include `EOSDY` and `DCSREAS` variables below because they contain missing data.\nstopifnot(\n any(is.na(adsl$EOSDY)),\n any(is.na(adsl$DCSREAS))\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")',\n check = TRUE\n ),\n modules = modules(\n tm_t_summary(\n label = \"Demographic Table\",\n dataname = \"ADSL\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n summarize_vars = choices_selected(\n c(\"SEX\", \"RACE\", \"BMRKR2\", \"EOSDY\", \"DCSREAS\"),\n c(\"SEX\", \"RACE\")\n ),\n useNA = \"ifany\"\n )\n )\n)\n\n[INFO] 2023-09-09 17:51:19.6447 pid:3634 token:[] teal.modules.clinical Initializing tm_t_summary\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tidyr_1.3.0 dplyr_1.1.2 \n [9] scda_0.1.6.9012 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/enrollment01.html",
"href": "tables/safety/enrollment01.html",
"title": "ENTXX",
"section": "",
- "text": "Data Setup\nENT01 – Enrollment by Region, Country, and Investigator Number\nENT01A – Enrollment by Country and Investigator Number\nENT02 – Enrollment by Region, Country, and Investigator Number/Name\nENT02A – Enrollment by Country and Investigator Number/Name\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(forcats)\nlibrary(scda)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\n\nadsl <- adsl %>%\n mutate(\n REGION1 = droplevels(REGION1),\n COUNTRY = droplevels(COUNTRY),\n INVID_INVNAM = paste(INVID, INVNAM, sep = \" / \")\n ) %>%\n mutate(\n INVID = factor(INVID),\n SITEID = factor(SITEID),\n INVNAM = factor(INVNAM),\n INVID_INVNAM = factor(INVID_INVNAM)\n ) %>%\n var_relabel(\n INVID_INVNAM = \"Investigator Number/Name\",\n REGION1 = \"Geographic Region 1\",\n COUNTRY = \"Country\",\n INVID = \"Investigator Identifier\"\n ) %>%\n arrange(REGION1, COUNTRY, INVID)\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n split_rows_by(\"REGION1\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$REGION1)) %>%\n summarize_row_groups() %>%\n split_rows_by(\"COUNTRY\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$COUNTRY)) %>%\n summarize_row_groups() %>%\n analyze(\"INVID\") %>%\n append_varlabels(adsl, \"INVID\", 2L)\n\nresult <- build_table(lyt, adsl) %>%\n prune_table()\n\nresult\n\nGeographic Region 1 \n Country A: Drug X B: Placebo C: Combination All Patients\n Investigator Identifier (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————\nAfrica 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n NGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n INV ID NGA-1 3 3 4 10 \n INV ID NGA-11 1 2 3 6 \n INV ID NGA-12 0 1 1 2 \n INV ID NGA-17 2 0 0 2 \n INV ID NGA-2 1 1 0 2 \n INV ID NGA-4 1 0 1 2 \n INV ID NGA-5 0 0 1 1 \n INV ID NGA-6 0 0 1 1 \nAsia 91 (67.9%) 94 (70.1%) 83 (62.9%) 268 (67.0%) \n CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) \n INV ID CHN-1 21 20 16 57 \n INV ID CHN-10 0 1 0 1 \n INV ID CHN-11 12 20 16 48 \n INV ID CHN-12 4 3 1 8 \n INV ID CHN-13 2 6 0 8 \n INV ID CHN-14 4 2 3 9 \n INV ID CHN-15 2 0 4 6 \n INV ID CHN-16 0 3 3 6 \n INV ID CHN-17 4 4 3 11 \n INV ID CHN-18 1 0 2 3 \n INV ID CHN-2 9 4 3 16 \n INV ID CHN-3 5 1 5 11 \n INV ID CHN-4 3 3 3 9 \n INV ID CHN-5 4 3 4 11 \n INV ID CHN-6 1 3 0 4 \n INV ID CHN-7 0 5 1 6 \n INV ID CHN-8 1 1 0 2 \n INV ID CHN-9 1 2 0 3 \n PAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) \n INV ID PAK-1 2 4 4 10 \n INV ID PAK-11 4 3 2 9 \n INV ID PAK-12 2 0 0 2 \n INV ID PAK-13 1 1 0 2 \n INV ID PAK-14 1 0 0 1 \n INV ID PAK-15 1 0 0 1 \n INV ID PAK-2 1 0 2 3 \n INV ID PAK-4 0 1 1 2 \n INV ID PAK-5 0 0 1 1 \n JPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) \n INV ID JPN-1 2 2 1 5 \n INV ID JPN-11 0 0 3 3 \n INV ID JPN-12 0 0 1 1 \n INV ID JPN-14 0 1 0 1 \n INV ID JPN-17 0 0 2 2 \n INV ID JPN-18 1 0 0 1 \n INV ID JPN-2 0 0 1 1 \n INV ID JPN-3 0 1 0 1 \n INV ID JPN-5 1 0 1 2 \n INV ID JPN-6 1 0 0 1 \nEurasia 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n RUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n INV ID RUS-1 1 0 0 1 \n INV ID RUS-11 0 2 2 4 \n INV ID RUS-12 0 1 0 1 \n INV ID RUS-13 1 0 0 1 \n INV ID RUS-14 0 0 1 1 \n INV ID RUS-16 1 1 0 2 \n INV ID RUS-18 1 0 0 1 \n INV ID RUS-2 0 1 0 1 \n INV ID RUS-3 0 0 1 1 \n INV ID RUS-4 0 2 1 3 \n INV ID RUS-5 0 1 0 1 \n INV ID RUS-6 1 0 0 1 \n INV ID RUS-7 0 0 1 1 \nEurope 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n GBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n INV ID GBR-1 2 0 1 3 \n INV ID GBR-11 0 1 1 2 \n INV ID GBR-13 1 0 0 1 \n INV ID GBR-15 1 0 0 1 \n INV ID GBR-17 0 1 0 1 \n INV ID GBR-6 0 1 0 1 \nNorth America 13 (9.7%) 15 (11.2%) 20 (15.2%) 48 (12.0%) \n USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) \n INV ID USA-1 1 4 5 10 \n INV ID USA-11 4 2 3 9 \n INV ID USA-12 1 2 3 6 \n INV ID USA-14 1 0 0 1 \n INV ID USA-15 0 1 1 2 \n INV ID USA-17 1 1 0 2 \n INV ID USA-19 0 0 1 1 \n INV ID USA-2 0 0 1 1 \n INV ID USA-3 1 0 1 2 \n INV ID USA-4 0 1 1 2 \n INV ID USA-5 0 1 0 1 \n INV ID USA-6 0 1 0 1 \n INV ID USA-8 0 0 1 1 \n INV ID USA-9 1 0 0 1 \n CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) \n INV ID CAN-1 1 1 0 2 \n INV ID CAN-11 1 0 1 2 \n INV ID CAN-14 1 0 0 1 \n INV ID CAN-4 0 1 1 2 \n INV ID CAN-5 0 0 1 1 \nSouth America 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n INV ID BRA-1 4 2 2 8 \n INV ID BRA-11 4 0 4 8 \n INV ID BRA-12 0 1 0 1 \n INV ID BRA-13 1 0 0 1 \n INV ID BRA-14 1 0 1 2 \n INV ID BRA-15 1 0 0 1 \n INV ID BRA-2 1 1 0 2 \n INV ID BRA-3 0 2 0 2 \n INV ID BRA-4 0 1 1 2 \n INV ID BRA-5 0 0 1 1 \n INV ID BRA-6 1 0 0 1 \n INV ID BRA-7 0 0 1 1 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n split_rows_by(\"COUNTRY\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$COUNTRY)) %>%\n summarize_row_groups() %>%\n analyze(\"INVID\") %>%\n append_varlabels(adsl, \"INVID\", 1L)\n\nresult <- build_table(lyt, adsl) %>%\n prune_table()\n\nresult\n\nCountry A: Drug X B: Placebo C: Combination All Patients\n Investigator Identifier (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————\nCHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) \n INV ID CHN-1 21 20 16 57 \n INV ID CHN-10 0 1 0 1 \n INV ID CHN-11 12 20 16 48 \n INV ID CHN-12 4 3 1 8 \n INV ID CHN-13 2 6 0 8 \n INV ID CHN-14 4 2 3 9 \n INV ID CHN-15 2 0 4 6 \n INV ID CHN-16 0 3 3 6 \n INV ID CHN-17 4 4 3 11 \n INV ID CHN-18 1 0 2 3 \n INV ID CHN-2 9 4 3 16 \n INV ID CHN-3 5 1 5 11 \n INV ID CHN-4 3 3 3 9 \n INV ID CHN-5 4 3 4 11 \n INV ID CHN-6 1 3 0 4 \n INV ID CHN-7 0 5 1 6 \n INV ID CHN-8 1 1 0 2 \n INV ID CHN-9 1 2 0 3 \nUSA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) \n INV ID USA-1 1 4 5 10 \n INV ID USA-11 4 2 3 9 \n INV ID USA-12 1 2 3 6 \n INV ID USA-14 1 0 0 1 \n INV ID USA-15 0 1 1 2 \n INV ID USA-17 1 1 0 2 \n INV ID USA-19 0 0 1 1 \n INV ID USA-2 0 0 1 1 \n INV ID USA-3 1 0 1 2 \n INV ID USA-4 0 1 1 2 \n INV ID USA-5 0 1 0 1 \n INV ID USA-6 0 1 0 1 \n INV ID USA-8 0 0 1 1 \n INV ID USA-9 1 0 0 1 \nBRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n INV ID BRA-1 4 2 2 8 \n INV ID BRA-11 4 0 4 8 \n INV ID BRA-12 0 1 0 1 \n INV ID BRA-13 1 0 0 1 \n INV ID BRA-14 1 0 1 2 \n INV ID BRA-15 1 0 0 1 \n INV ID BRA-2 1 1 0 2 \n INV ID BRA-3 0 2 0 2 \n INV ID BRA-4 0 1 1 2 \n INV ID BRA-5 0 0 1 1 \n INV ID BRA-6 1 0 0 1 \n INV ID BRA-7 0 0 1 1 \nPAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) \n INV ID PAK-1 2 4 4 10 \n INV ID PAK-11 4 3 2 9 \n INV ID PAK-12 2 0 0 2 \n INV ID PAK-13 1 1 0 2 \n INV ID PAK-14 1 0 0 1 \n INV ID PAK-15 1 0 0 1 \n INV ID PAK-2 1 0 2 3 \n INV ID PAK-4 0 1 1 2 \n INV ID PAK-5 0 0 1 1 \nNGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n INV ID NGA-1 3 3 4 10 \n INV ID NGA-11 1 2 3 6 \n INV ID NGA-12 0 1 1 2 \n INV ID NGA-17 2 0 0 2 \n INV ID NGA-2 1 1 0 2 \n INV ID NGA-4 1 0 1 2 \n INV ID NGA-5 0 0 1 1 \n INV ID NGA-6 0 0 1 1 \nRUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n INV ID RUS-1 1 0 0 1 \n INV ID RUS-11 0 2 2 4 \n INV ID RUS-12 0 1 0 1 \n INV ID RUS-13 1 0 0 1 \n INV ID RUS-14 0 0 1 1 \n INV ID RUS-16 1 1 0 2 \n INV ID RUS-18 1 0 0 1 \n INV ID RUS-2 0 1 0 1 \n INV ID RUS-3 0 0 1 1 \n INV ID RUS-4 0 2 1 3 \n INV ID RUS-5 0 1 0 1 \n INV ID RUS-6 1 0 0 1 \n INV ID RUS-7 0 0 1 1 \nJPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) \n INV ID JPN-1 2 2 1 5 \n INV ID JPN-11 0 0 3 3 \n INV ID JPN-12 0 0 1 1 \n INV ID JPN-14 0 1 0 1 \n INV ID JPN-17 0 0 2 2 \n INV ID JPN-18 1 0 0 1 \n INV ID JPN-2 0 0 1 1 \n INV ID JPN-3 0 1 0 1 \n INV ID JPN-5 1 0 1 2 \n INV ID JPN-6 1 0 0 1 \nGBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n INV ID GBR-1 2 0 1 3 \n INV ID GBR-11 0 1 1 2 \n INV ID GBR-13 1 0 0 1 \n INV ID GBR-15 1 0 0 1 \n INV ID GBR-17 0 1 0 1 \n INV ID GBR-6 0 1 0 1 \nCAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) \n INV ID CAN-1 1 1 0 2 \n INV ID CAN-11 1 0 1 2 \n INV ID CAN-14 1 0 0 1 \n INV ID CAN-4 0 1 1 2 \n INV ID CAN-5 0 0 1 1 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n split_rows_by(\"REGION1\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$REGION1)) %>%\n summarize_row_groups() %>%\n split_rows_by(\"COUNTRY\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$COUNTRY)) %>%\n summarize_row_groups() %>%\n analyze(\"INVID_INVNAM\") %>%\n append_varlabels(adsl, \"INVID_INVNAM\", 2L)\n\nresult <- build_table(lyt, adsl) %>%\n prune_table()\n\nresult\n\nGeographic Region 1 \n Country A: Drug X B: Placebo C: Combination All Patients\n Investigator Number/Name (N=134) (N=134) (N=132) (N=400) \n————————————————————————————————————————————————————————————————————————————————————————————\nAfrica 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n NGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n INV ID NGA-1 / Dr. NGA-1 Doe 3 3 4 10 \n INV ID NGA-11 / Dr. NGA-11 Doe 1 2 3 6 \n INV ID NGA-12 / Dr. NGA-12 Doe 0 1 1 2 \n INV ID NGA-17 / Dr. NGA-17 Doe 2 0 0 2 \n INV ID NGA-2 / Dr. NGA-2 Doe 1 1 0 2 \n INV ID NGA-4 / Dr. NGA-4 Doe 1 0 1 2 \n INV ID NGA-5 / Dr. NGA-5 Doe 0 0 1 1 \n INV ID NGA-6 / Dr. NGA-6 Doe 0 0 1 1 \nAsia 91 (67.9%) 94 (70.1%) 83 (62.9%) 268 (67.0%) \n CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) \n INV ID CHN-1 / Dr. CHN-1 Doe 21 20 16 57 \n INV ID CHN-10 / Dr. CHN-10 Doe 0 1 0 1 \n INV ID CHN-11 / Dr. CHN-11 Doe 12 20 16 48 \n INV ID CHN-12 / Dr. CHN-12 Doe 4 3 1 8 \n INV ID CHN-13 / Dr. CHN-13 Doe 2 6 0 8 \n INV ID CHN-14 / Dr. CHN-14 Doe 4 2 3 9 \n INV ID CHN-15 / Dr. CHN-15 Doe 2 0 4 6 \n INV ID CHN-16 / Dr. CHN-16 Doe 0 3 3 6 \n INV ID CHN-17 / Dr. CHN-17 Doe 4 4 3 11 \n INV ID CHN-18 / Dr. CHN-18 Doe 1 0 2 3 \n INV ID CHN-2 / Dr. CHN-2 Doe 9 4 3 16 \n INV ID CHN-3 / Dr. CHN-3 Doe 5 1 5 11 \n INV ID CHN-4 / Dr. CHN-4 Doe 3 3 3 9 \n INV ID CHN-5 / Dr. CHN-5 Doe 4 3 4 11 \n INV ID CHN-6 / Dr. CHN-6 Doe 1 3 0 4 \n INV ID CHN-7 / Dr. CHN-7 Doe 0 5 1 6 \n INV ID CHN-8 / Dr. CHN-8 Doe 1 1 0 2 \n INV ID CHN-9 / Dr. CHN-9 Doe 1 2 0 3 \n PAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) \n INV ID PAK-1 / Dr. PAK-1 Doe 2 4 4 10 \n INV ID PAK-11 / Dr. PAK-11 Doe 4 3 2 9 \n INV ID PAK-12 / Dr. PAK-12 Doe 2 0 0 2 \n INV ID PAK-13 / Dr. PAK-13 Doe 1 1 0 2 \n INV ID PAK-14 / Dr. PAK-14 Doe 1 0 0 1 \n INV ID PAK-15 / Dr. PAK-15 Doe 1 0 0 1 \n INV ID PAK-2 / Dr. PAK-2 Doe 1 0 2 3 \n INV ID PAK-4 / Dr. PAK-4 Doe 0 1 1 2 \n INV ID PAK-5 / Dr. PAK-5 Doe 0 0 1 1 \n JPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) \n INV ID JPN-1 / Dr. JPN-1 Doe 2 2 1 5 \n INV ID JPN-11 / Dr. JPN-11 Doe 0 0 3 3 \n INV ID JPN-12 / Dr. JPN-12 Doe 0 0 1 1 \n INV ID JPN-14 / Dr. JPN-14 Doe 0 1 0 1 \n INV ID JPN-17 / Dr. JPN-17 Doe 0 0 2 2 \n INV ID JPN-18 / Dr. JPN-18 Doe 1 0 0 1 \n INV ID JPN-2 / Dr. JPN-2 Doe 0 0 1 1 \n INV ID JPN-3 / Dr. JPN-3 Doe 0 1 0 1 \n INV ID JPN-5 / Dr. JPN-5 Doe 1 0 1 2 \n INV ID JPN-6 / Dr. JPN-6 Doe 1 0 0 1 \nEurasia 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n RUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n INV ID RUS-1 / Dr. RUS-1 Doe 1 0 0 1 \n INV ID RUS-11 / Dr. RUS-11 Doe 0 2 2 4 \n INV ID RUS-12 / Dr. RUS-12 Doe 0 1 0 1 \n INV ID RUS-13 / Dr. RUS-13 Doe 1 0 0 1 \n INV ID RUS-14 / Dr. RUS-14 Doe 0 0 1 1 \n INV ID RUS-16 / Dr. RUS-16 Doe 1 1 0 2 \n INV ID RUS-18 / Dr. RUS-18 Doe 1 0 0 1 \n INV ID RUS-2 / Dr. RUS-2 Doe 0 1 0 1 \n INV ID RUS-3 / Dr. RUS-3 Doe 0 0 1 1 \n INV ID RUS-4 / Dr. RUS-4 Doe 0 2 1 3 \n INV ID RUS-5 / Dr. RUS-5 Doe 0 1 0 1 \n INV ID RUS-6 / Dr. RUS-6 Doe 1 0 0 1 \n INV ID RUS-7 / Dr. RUS-7 Doe 0 0 1 1 \nEurope 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n GBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n INV ID GBR-1 / Dr. GBR-1 Doe 2 0 1 3 \n INV ID GBR-11 / Dr. GBR-11 Doe 0 1 1 2 \n INV ID GBR-13 / Dr. GBR-13 Doe 1 0 0 1 \n INV ID GBR-15 / Dr. GBR-15 Doe 1 0 0 1 \n INV ID GBR-17 / Dr. GBR-17 Doe 0 1 0 1 \n INV ID GBR-6 / Dr. GBR-6 Doe 0 1 0 1 \nNorth America 13 (9.7%) 15 (11.2%) 20 (15.2%) 48 (12.0%) \n USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) \n INV ID USA-1 / Dr. USA-1 Doe 1 4 5 10 \n INV ID USA-11 / Dr. USA-11 Doe 4 2 3 9 \n INV ID USA-12 / Dr. USA-12 Doe 1 2 3 6 \n INV ID USA-14 / Dr. USA-14 Doe 1 0 0 1 \n INV ID USA-15 / Dr. USA-15 Doe 0 1 1 2 \n INV ID USA-17 / Dr. USA-17 Doe 1 1 0 2 \n INV ID USA-19 / Dr. USA-19 Doe 0 0 1 1 \n INV ID USA-2 / Dr. USA-2 Doe 0 0 1 1 \n INV ID USA-3 / Dr. USA-3 Doe 1 0 1 2 \n INV ID USA-4 / Dr. USA-4 Doe 0 1 1 2 \n INV ID USA-5 / Dr. USA-5 Doe 0 1 0 1 \n INV ID USA-6 / Dr. USA-6 Doe 0 1 0 1 \n INV ID USA-8 / Dr. USA-8 Doe 0 0 1 1 \n INV ID USA-9 / Dr. USA-9 Doe 1 0 0 1 \n CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) \n INV ID CAN-1 / Dr. CAN-1 Doe 1 1 0 2 \n INV ID CAN-11 / Dr. CAN-11 Doe 1 0 1 2 \n INV ID CAN-14 / Dr. CAN-14 Doe 1 0 0 1 \n INV ID CAN-4 / Dr. CAN-4 Doe 0 1 1 2 \n INV ID CAN-5 / Dr. CAN-5 Doe 0 0 1 1 \nSouth America 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n INV ID BRA-1 / Dr. BRA-1 Doe 4 2 2 8 \n INV ID BRA-11 / Dr. BRA-11 Doe 4 0 4 8 \n INV ID BRA-12 / Dr. BRA-12 Doe 0 1 0 1 \n INV ID BRA-13 / Dr. BRA-13 Doe 1 0 0 1 \n INV ID BRA-14 / Dr. BRA-14 Doe 1 0 1 2 \n INV ID BRA-15 / Dr. BRA-15 Doe 1 0 0 1 \n INV ID BRA-2 / Dr. BRA-2 Doe 1 1 0 2 \n INV ID BRA-3 / Dr. BRA-3 Doe 0 2 0 2 \n INV ID BRA-4 / Dr. BRA-4 Doe 0 1 1 2 \n INV ID BRA-5 / Dr. BRA-5 Doe 0 0 1 1 \n INV ID BRA-6 / Dr. BRA-6 Doe 1 0 0 1 \n INV ID BRA-7 / Dr. BRA-7 Doe 0 0 1 1 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n split_rows_by(\"COUNTRY\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$COUNTRY)) %>%\n summarize_row_groups() %>%\n analyze(\"INVID_INVNAM\") %>%\n append_varlabels(adsl, \"INVID_INVNAM\", 1L)\n\nresult <- build_table(lyt, adsl) %>%\n prune_table()\n\nresult\n\nCountry A: Drug X B: Placebo C: Combination All Patients\n Investigator Number/Name (N=134) (N=134) (N=132) (N=400) \n——————————————————————————————————————————————————————————————————————————————————————————\nCHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) \n INV ID CHN-1 / Dr. CHN-1 Doe 21 20 16 57 \n INV ID CHN-10 / Dr. CHN-10 Doe 0 1 0 1 \n INV ID CHN-11 / Dr. CHN-11 Doe 12 20 16 48 \n INV ID CHN-12 / Dr. CHN-12 Doe 4 3 1 8 \n INV ID CHN-13 / Dr. CHN-13 Doe 2 6 0 8 \n INV ID CHN-14 / Dr. CHN-14 Doe 4 2 3 9 \n INV ID CHN-15 / Dr. CHN-15 Doe 2 0 4 6 \n INV ID CHN-16 / Dr. CHN-16 Doe 0 3 3 6 \n INV ID CHN-17 / Dr. CHN-17 Doe 4 4 3 11 \n INV ID CHN-18 / Dr. CHN-18 Doe 1 0 2 3 \n INV ID CHN-2 / Dr. CHN-2 Doe 9 4 3 16 \n INV ID CHN-3 / Dr. CHN-3 Doe 5 1 5 11 \n INV ID CHN-4 / Dr. CHN-4 Doe 3 3 3 9 \n INV ID CHN-5 / Dr. CHN-5 Doe 4 3 4 11 \n INV ID CHN-6 / Dr. CHN-6 Doe 1 3 0 4 \n INV ID CHN-7 / Dr. CHN-7 Doe 0 5 1 6 \n INV ID CHN-8 / Dr. CHN-8 Doe 1 1 0 2 \n INV ID CHN-9 / Dr. CHN-9 Doe 1 2 0 3 \nUSA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) \n INV ID USA-1 / Dr. USA-1 Doe 1 4 5 10 \n INV ID USA-11 / Dr. USA-11 Doe 4 2 3 9 \n INV ID USA-12 / Dr. USA-12 Doe 1 2 3 6 \n INV ID USA-14 / Dr. USA-14 Doe 1 0 0 1 \n INV ID USA-15 / Dr. USA-15 Doe 0 1 1 2 \n INV ID USA-17 / Dr. USA-17 Doe 1 1 0 2 \n INV ID USA-19 / Dr. USA-19 Doe 0 0 1 1 \n INV ID USA-2 / Dr. USA-2 Doe 0 0 1 1 \n INV ID USA-3 / Dr. USA-3 Doe 1 0 1 2 \n INV ID USA-4 / Dr. USA-4 Doe 0 1 1 2 \n INV ID USA-5 / Dr. USA-5 Doe 0 1 0 1 \n INV ID USA-6 / Dr. USA-6 Doe 0 1 0 1 \n INV ID USA-8 / Dr. USA-8 Doe 0 0 1 1 \n INV ID USA-9 / Dr. USA-9 Doe 1 0 0 1 \nBRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n INV ID BRA-1 / Dr. BRA-1 Doe 4 2 2 8 \n INV ID BRA-11 / Dr. BRA-11 Doe 4 0 4 8 \n INV ID BRA-12 / Dr. BRA-12 Doe 0 1 0 1 \n INV ID BRA-13 / Dr. BRA-13 Doe 1 0 0 1 \n INV ID BRA-14 / Dr. BRA-14 Doe 1 0 1 2 \n INV ID BRA-15 / Dr. BRA-15 Doe 1 0 0 1 \n INV ID BRA-2 / Dr. BRA-2 Doe 1 1 0 2 \n INV ID BRA-3 / Dr. BRA-3 Doe 0 2 0 2 \n INV ID BRA-4 / Dr. BRA-4 Doe 0 1 1 2 \n INV ID BRA-5 / Dr. BRA-5 Doe 0 0 1 1 \n INV ID BRA-6 / Dr. BRA-6 Doe 1 0 0 1 \n INV ID BRA-7 / Dr. BRA-7 Doe 0 0 1 1 \nPAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) \n INV ID PAK-1 / Dr. PAK-1 Doe 2 4 4 10 \n INV ID PAK-11 / Dr. PAK-11 Doe 4 3 2 9 \n INV ID PAK-12 / Dr. PAK-12 Doe 2 0 0 2 \n INV ID PAK-13 / Dr. PAK-13 Doe 1 1 0 2 \n INV ID PAK-14 / Dr. PAK-14 Doe 1 0 0 1 \n INV ID PAK-15 / Dr. PAK-15 Doe 1 0 0 1 \n INV ID PAK-2 / Dr. PAK-2 Doe 1 0 2 3 \n INV ID PAK-4 / Dr. PAK-4 Doe 0 1 1 2 \n INV ID PAK-5 / Dr. PAK-5 Doe 0 0 1 1 \nNGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n INV ID NGA-1 / Dr. NGA-1 Doe 3 3 4 10 \n INV ID NGA-11 / Dr. NGA-11 Doe 1 2 3 6 \n INV ID NGA-12 / Dr. NGA-12 Doe 0 1 1 2 \n INV ID NGA-17 / Dr. NGA-17 Doe 2 0 0 2 \n INV ID NGA-2 / Dr. NGA-2 Doe 1 1 0 2 \n INV ID NGA-4 / Dr. NGA-4 Doe 1 0 1 2 \n INV ID NGA-5 / Dr. NGA-5 Doe 0 0 1 1 \n INV ID NGA-6 / Dr. NGA-6 Doe 0 0 1 1 \nRUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n INV ID RUS-1 / Dr. RUS-1 Doe 1 0 0 1 \n INV ID RUS-11 / Dr. RUS-11 Doe 0 2 2 4 \n INV ID RUS-12 / Dr. RUS-12 Doe 0 1 0 1 \n INV ID RUS-13 / Dr. RUS-13 Doe 1 0 0 1 \n INV ID RUS-14 / Dr. RUS-14 Doe 0 0 1 1 \n INV ID RUS-16 / Dr. RUS-16 Doe 1 1 0 2 \n INV ID RUS-18 / Dr. RUS-18 Doe 1 0 0 1 \n INV ID RUS-2 / Dr. RUS-2 Doe 0 1 0 1 \n INV ID RUS-3 / Dr. RUS-3 Doe 0 0 1 1 \n INV ID RUS-4 / Dr. RUS-4 Doe 0 2 1 3 \n INV ID RUS-5 / Dr. RUS-5 Doe 0 1 0 1 \n INV ID RUS-6 / Dr. RUS-6 Doe 1 0 0 1 \n INV ID RUS-7 / Dr. RUS-7 Doe 0 0 1 1 \nJPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) \n INV ID JPN-1 / Dr. JPN-1 Doe 2 2 1 5 \n INV ID JPN-11 / Dr. JPN-11 Doe 0 0 3 3 \n INV ID JPN-12 / Dr. JPN-12 Doe 0 0 1 1 \n INV ID JPN-14 / Dr. JPN-14 Doe 0 1 0 1 \n INV ID JPN-17 / Dr. JPN-17 Doe 0 0 2 2 \n INV ID JPN-18 / Dr. JPN-18 Doe 1 0 0 1 \n INV ID JPN-2 / Dr. JPN-2 Doe 0 0 1 1 \n INV ID JPN-3 / Dr. JPN-3 Doe 0 1 0 1 \n INV ID JPN-5 / Dr. JPN-5 Doe 1 0 1 2 \n INV ID JPN-6 / Dr. JPN-6 Doe 1 0 0 1 \nGBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n INV ID GBR-1 / Dr. GBR-1 Doe 2 0 1 3 \n INV ID GBR-11 / Dr. GBR-11 Doe 0 1 1 2 \n INV ID GBR-13 / Dr. GBR-13 Doe 1 0 0 1 \n INV ID GBR-15 / Dr. GBR-15 Doe 1 0 0 1 \n INV ID GBR-17 / Dr. GBR-17 Doe 0 1 0 1 \n INV ID GBR-6 / Dr. GBR-6 Doe 0 1 0 1 \nCAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) \n INV ID CAN-1 / Dr. CAN-1 Doe 1 1 0 2 \n INV ID CAN-11 / Dr. CAN-11 Doe 1 0 1 2 \n INV ID CAN-14 / Dr. CAN-14 Doe 1 0 0 1 \n INV ID CAN-4 / Dr. CAN-4 Doe 0 1 1 2 \n INV ID CAN-5 / Dr. CAN-5 Doe 0 0 1 1 \n\n\n\n\nNote that for this module application, only the variables passed into by_vars are used when row_groups is selected. Variables passed into analyze_vars are additionally used when row_groups is deselected.\n\nCodelibrary(dplyr)\nlibrary(forcats)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\n\nadsl_labels <- var_labels(adsl)\n\nadsl <- adsl %>%\n mutate(\n REGION1 = droplevels(REGION1),\n COUNTRY = droplevels(COUNTRY),\n INVID_INVNAM = paste(INVID, INVNAM, sep = \" / \")\n ) %>%\n arrange(REGION1, COUNTRY, INVID) %>%\n mutate(\n INVID = factor(INVID),\n SITEID = factor(SITEID),\n INVNAM = factor(INVNAM),\n INVID_INVNAM = factor(INVID_INVNAM)\n )\n\nvar_labels(adsl) <- c(adsl_labels, \"Investigator Number/Name\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\n ADSL_labels <- var_labels(ADSL)\n ADSL <- ADSL %>% mutate(\n REGION1 = droplevels(REGION1),\n COUNTRY = droplevels(COUNTRY),\n INVID_INVNAM = paste(INVID, INVNAM, sep = \" / \")\n ) %>%\n arrange(REGION1, COUNTRY, INVID) %>%\n mutate(\n INVID = factor(INVID),\n SITEID = factor(SITEID),\n INVNAM = factor(INVNAM),\n INVID_INVNAM = factor(INVID_INVNAM)\n )\n\n var_labels(ADSL) <- c(ADSL_labels, \"Investigator Number/Name\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Enrollment Table\",\n dataname = \"ADSL\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adsl, c(\"REGION1\", \"COUNTRY\", \"SITEID\", \"INVID\", \"INVNAM\", \"INVID_INVNAM\")),\n selected = c(\"REGION1\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adsl, c(\"REGION1\", \"COUNTRY\", \"SITEID\", \"INVID\", \"INVNAM\", \"INVID_INVNAM\")),\n selected = c(\"SITEID\")\n ),\n denominator = choices_selected(\n choices = c(\"n\", \"N\", \"omit\"),\n selected = \"N\",\n fixed = TRUE\n ),\n useNA = \"ifany\",\n row_groups = TRUE\n )\n )\n)\n\n[INFO] 2023-09-08 19:33:29.5898 pid:3480 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] scda_0.1.6.9012 forcats_1.0.0 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nENT01 – Enrollment by Region, Country, and Investigator Number\nENT01A – Enrollment by Country and Investigator Number\nENT02 – Enrollment by Region, Country, and Investigator Number/Name\nENT02A – Enrollment by Country and Investigator Number/Name\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(forcats)\nlibrary(scda)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\n\nadsl <- adsl %>%\n mutate(\n REGION1 = droplevels(REGION1),\n COUNTRY = droplevels(COUNTRY),\n INVID_INVNAM = paste(INVID, INVNAM, sep = \" / \")\n ) %>%\n mutate(\n INVID = factor(INVID),\n SITEID = factor(SITEID),\n INVNAM = factor(INVNAM),\n INVID_INVNAM = factor(INVID_INVNAM)\n ) %>%\n var_relabel(\n INVID_INVNAM = \"Investigator Number/Name\",\n REGION1 = \"Geographic Region 1\",\n COUNTRY = \"Country\",\n INVID = \"Investigator Identifier\"\n ) %>%\n arrange(REGION1, COUNTRY, INVID)\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n split_rows_by(\"REGION1\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$REGION1)) %>%\n summarize_row_groups() %>%\n split_rows_by(\"COUNTRY\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$COUNTRY)) %>%\n summarize_row_groups() %>%\n analyze(\"INVID\") %>%\n append_varlabels(adsl, \"INVID\", 2L)\n\nresult <- build_table(lyt, adsl) %>%\n prune_table()\n\nresult\n\nGeographic Region 1 \n Country A: Drug X B: Placebo C: Combination All Patients\n Investigator Identifier (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————\nAfrica 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n NGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n INV ID NGA-1 3 3 4 10 \n INV ID NGA-11 1 2 3 6 \n INV ID NGA-12 0 1 1 2 \n INV ID NGA-17 2 0 0 2 \n INV ID NGA-2 1 1 0 2 \n INV ID NGA-4 1 0 1 2 \n INV ID NGA-5 0 0 1 1 \n INV ID NGA-6 0 0 1 1 \nAsia 91 (67.9%) 94 (70.1%) 83 (62.9%) 268 (67.0%) \n CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) \n INV ID CHN-1 21 20 16 57 \n INV ID CHN-10 0 1 0 1 \n INV ID CHN-11 12 20 16 48 \n INV ID CHN-12 4 3 1 8 \n INV ID CHN-13 2 6 0 8 \n INV ID CHN-14 4 2 3 9 \n INV ID CHN-15 2 0 4 6 \n INV ID CHN-16 0 3 3 6 \n INV ID CHN-17 4 4 3 11 \n INV ID CHN-18 1 0 2 3 \n INV ID CHN-2 9 4 3 16 \n INV ID CHN-3 5 1 5 11 \n INV ID CHN-4 3 3 3 9 \n INV ID CHN-5 4 3 4 11 \n INV ID CHN-6 1 3 0 4 \n INV ID CHN-7 0 5 1 6 \n INV ID CHN-8 1 1 0 2 \n INV ID CHN-9 1 2 0 3 \n PAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) \n INV ID PAK-1 2 4 4 10 \n INV ID PAK-11 4 3 2 9 \n INV ID PAK-12 2 0 0 2 \n INV ID PAK-13 1 1 0 2 \n INV ID PAK-14 1 0 0 1 \n INV ID PAK-15 1 0 0 1 \n INV ID PAK-2 1 0 2 3 \n INV ID PAK-4 0 1 1 2 \n INV ID PAK-5 0 0 1 1 \n JPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) \n INV ID JPN-1 2 2 1 5 \n INV ID JPN-11 0 0 3 3 \n INV ID JPN-12 0 0 1 1 \n INV ID JPN-14 0 1 0 1 \n INV ID JPN-17 0 0 2 2 \n INV ID JPN-18 1 0 0 1 \n INV ID JPN-2 0 0 1 1 \n INV ID JPN-3 0 1 0 1 \n INV ID JPN-5 1 0 1 2 \n INV ID JPN-6 1 0 0 1 \nEurasia 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n RUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n INV ID RUS-1 1 0 0 1 \n INV ID RUS-11 0 2 2 4 \n INV ID RUS-12 0 1 0 1 \n INV ID RUS-13 1 0 0 1 \n INV ID RUS-14 0 0 1 1 \n INV ID RUS-16 1 1 0 2 \n INV ID RUS-18 1 0 0 1 \n INV ID RUS-2 0 1 0 1 \n INV ID RUS-3 0 0 1 1 \n INV ID RUS-4 0 2 1 3 \n INV ID RUS-5 0 1 0 1 \n INV ID RUS-6 1 0 0 1 \n INV ID RUS-7 0 0 1 1 \nEurope 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n GBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n INV ID GBR-1 2 0 1 3 \n INV ID GBR-11 0 1 1 2 \n INV ID GBR-13 1 0 0 1 \n INV ID GBR-15 1 0 0 1 \n INV ID GBR-17 0 1 0 1 \n INV ID GBR-6 0 1 0 1 \nNorth America 13 (9.7%) 15 (11.2%) 20 (15.2%) 48 (12.0%) \n USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) \n INV ID USA-1 1 4 5 10 \n INV ID USA-11 4 2 3 9 \n INV ID USA-12 1 2 3 6 \n INV ID USA-14 1 0 0 1 \n INV ID USA-15 0 1 1 2 \n INV ID USA-17 1 1 0 2 \n INV ID USA-19 0 0 1 1 \n INV ID USA-2 0 0 1 1 \n INV ID USA-3 1 0 1 2 \n INV ID USA-4 0 1 1 2 \n INV ID USA-5 0 1 0 1 \n INV ID USA-6 0 1 0 1 \n INV ID USA-8 0 0 1 1 \n INV ID USA-9 1 0 0 1 \n CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) \n INV ID CAN-1 1 1 0 2 \n INV ID CAN-11 1 0 1 2 \n INV ID CAN-14 1 0 0 1 \n INV ID CAN-4 0 1 1 2 \n INV ID CAN-5 0 0 1 1 \nSouth America 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n INV ID BRA-1 4 2 2 8 \n INV ID BRA-11 4 0 4 8 \n INV ID BRA-12 0 1 0 1 \n INV ID BRA-13 1 0 0 1 \n INV ID BRA-14 1 0 1 2 \n INV ID BRA-15 1 0 0 1 \n INV ID BRA-2 1 1 0 2 \n INV ID BRA-3 0 2 0 2 \n INV ID BRA-4 0 1 1 2 \n INV ID BRA-5 0 0 1 1 \n INV ID BRA-6 1 0 0 1 \n INV ID BRA-7 0 0 1 1 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n split_rows_by(\"COUNTRY\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$COUNTRY)) %>%\n summarize_row_groups() %>%\n analyze(\"INVID\") %>%\n append_varlabels(adsl, \"INVID\", 1L)\n\nresult <- build_table(lyt, adsl) %>%\n prune_table()\n\nresult\n\nCountry A: Drug X B: Placebo C: Combination All Patients\n Investigator Identifier (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————\nCHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) \n INV ID CHN-1 21 20 16 57 \n INV ID CHN-10 0 1 0 1 \n INV ID CHN-11 12 20 16 48 \n INV ID CHN-12 4 3 1 8 \n INV ID CHN-13 2 6 0 8 \n INV ID CHN-14 4 2 3 9 \n INV ID CHN-15 2 0 4 6 \n INV ID CHN-16 0 3 3 6 \n INV ID CHN-17 4 4 3 11 \n INV ID CHN-18 1 0 2 3 \n INV ID CHN-2 9 4 3 16 \n INV ID CHN-3 5 1 5 11 \n INV ID CHN-4 3 3 3 9 \n INV ID CHN-5 4 3 4 11 \n INV ID CHN-6 1 3 0 4 \n INV ID CHN-7 0 5 1 6 \n INV ID CHN-8 1 1 0 2 \n INV ID CHN-9 1 2 0 3 \nUSA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) \n INV ID USA-1 1 4 5 10 \n INV ID USA-11 4 2 3 9 \n INV ID USA-12 1 2 3 6 \n INV ID USA-14 1 0 0 1 \n INV ID USA-15 0 1 1 2 \n INV ID USA-17 1 1 0 2 \n INV ID USA-19 0 0 1 1 \n INV ID USA-2 0 0 1 1 \n INV ID USA-3 1 0 1 2 \n INV ID USA-4 0 1 1 2 \n INV ID USA-5 0 1 0 1 \n INV ID USA-6 0 1 0 1 \n INV ID USA-8 0 0 1 1 \n INV ID USA-9 1 0 0 1 \nBRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n INV ID BRA-1 4 2 2 8 \n INV ID BRA-11 4 0 4 8 \n INV ID BRA-12 0 1 0 1 \n INV ID BRA-13 1 0 0 1 \n INV ID BRA-14 1 0 1 2 \n INV ID BRA-15 1 0 0 1 \n INV ID BRA-2 1 1 0 2 \n INV ID BRA-3 0 2 0 2 \n INV ID BRA-4 0 1 1 2 \n INV ID BRA-5 0 0 1 1 \n INV ID BRA-6 1 0 0 1 \n INV ID BRA-7 0 0 1 1 \nPAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) \n INV ID PAK-1 2 4 4 10 \n INV ID PAK-11 4 3 2 9 \n INV ID PAK-12 2 0 0 2 \n INV ID PAK-13 1 1 0 2 \n INV ID PAK-14 1 0 0 1 \n INV ID PAK-15 1 0 0 1 \n INV ID PAK-2 1 0 2 3 \n INV ID PAK-4 0 1 1 2 \n INV ID PAK-5 0 0 1 1 \nNGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n INV ID NGA-1 3 3 4 10 \n INV ID NGA-11 1 2 3 6 \n INV ID NGA-12 0 1 1 2 \n INV ID NGA-17 2 0 0 2 \n INV ID NGA-2 1 1 0 2 \n INV ID NGA-4 1 0 1 2 \n INV ID NGA-5 0 0 1 1 \n INV ID NGA-6 0 0 1 1 \nRUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n INV ID RUS-1 1 0 0 1 \n INV ID RUS-11 0 2 2 4 \n INV ID RUS-12 0 1 0 1 \n INV ID RUS-13 1 0 0 1 \n INV ID RUS-14 0 0 1 1 \n INV ID RUS-16 1 1 0 2 \n INV ID RUS-18 1 0 0 1 \n INV ID RUS-2 0 1 0 1 \n INV ID RUS-3 0 0 1 1 \n INV ID RUS-4 0 2 1 3 \n INV ID RUS-5 0 1 0 1 \n INV ID RUS-6 1 0 0 1 \n INV ID RUS-7 0 0 1 1 \nJPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) \n INV ID JPN-1 2 2 1 5 \n INV ID JPN-11 0 0 3 3 \n INV ID JPN-12 0 0 1 1 \n INV ID JPN-14 0 1 0 1 \n INV ID JPN-17 0 0 2 2 \n INV ID JPN-18 1 0 0 1 \n INV ID JPN-2 0 0 1 1 \n INV ID JPN-3 0 1 0 1 \n INV ID JPN-5 1 0 1 2 \n INV ID JPN-6 1 0 0 1 \nGBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n INV ID GBR-1 2 0 1 3 \n INV ID GBR-11 0 1 1 2 \n INV ID GBR-13 1 0 0 1 \n INV ID GBR-15 1 0 0 1 \n INV ID GBR-17 0 1 0 1 \n INV ID GBR-6 0 1 0 1 \nCAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) \n INV ID CAN-1 1 1 0 2 \n INV ID CAN-11 1 0 1 2 \n INV ID CAN-14 1 0 0 1 \n INV ID CAN-4 0 1 1 2 \n INV ID CAN-5 0 0 1 1 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n split_rows_by(\"REGION1\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$REGION1)) %>%\n summarize_row_groups() %>%\n split_rows_by(\"COUNTRY\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$COUNTRY)) %>%\n summarize_row_groups() %>%\n analyze(\"INVID_INVNAM\") %>%\n append_varlabels(adsl, \"INVID_INVNAM\", 2L)\n\nresult <- build_table(lyt, adsl) %>%\n prune_table()\n\nresult\n\nGeographic Region 1 \n Country A: Drug X B: Placebo C: Combination All Patients\n Investigator Number/Name (N=134) (N=134) (N=132) (N=400) \n————————————————————————————————————————————————————————————————————————————————————————————\nAfrica 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n NGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n INV ID NGA-1 / Dr. NGA-1 Doe 3 3 4 10 \n INV ID NGA-11 / Dr. NGA-11 Doe 1 2 3 6 \n INV ID NGA-12 / Dr. NGA-12 Doe 0 1 1 2 \n INV ID NGA-17 / Dr. NGA-17 Doe 2 0 0 2 \n INV ID NGA-2 / Dr. NGA-2 Doe 1 1 0 2 \n INV ID NGA-4 / Dr. NGA-4 Doe 1 0 1 2 \n INV ID NGA-5 / Dr. NGA-5 Doe 0 0 1 1 \n INV ID NGA-6 / Dr. NGA-6 Doe 0 0 1 1 \nAsia 91 (67.9%) 94 (70.1%) 83 (62.9%) 268 (67.0%) \n CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) \n INV ID CHN-1 / Dr. CHN-1 Doe 21 20 16 57 \n INV ID CHN-10 / Dr. CHN-10 Doe 0 1 0 1 \n INV ID CHN-11 / Dr. CHN-11 Doe 12 20 16 48 \n INV ID CHN-12 / Dr. CHN-12 Doe 4 3 1 8 \n INV ID CHN-13 / Dr. CHN-13 Doe 2 6 0 8 \n INV ID CHN-14 / Dr. CHN-14 Doe 4 2 3 9 \n INV ID CHN-15 / Dr. CHN-15 Doe 2 0 4 6 \n INV ID CHN-16 / Dr. CHN-16 Doe 0 3 3 6 \n INV ID CHN-17 / Dr. CHN-17 Doe 4 4 3 11 \n INV ID CHN-18 / Dr. CHN-18 Doe 1 0 2 3 \n INV ID CHN-2 / Dr. CHN-2 Doe 9 4 3 16 \n INV ID CHN-3 / Dr. CHN-3 Doe 5 1 5 11 \n INV ID CHN-4 / Dr. CHN-4 Doe 3 3 3 9 \n INV ID CHN-5 / Dr. CHN-5 Doe 4 3 4 11 \n INV ID CHN-6 / Dr. CHN-6 Doe 1 3 0 4 \n INV ID CHN-7 / Dr. CHN-7 Doe 0 5 1 6 \n INV ID CHN-8 / Dr. CHN-8 Doe 1 1 0 2 \n INV ID CHN-9 / Dr. CHN-9 Doe 1 2 0 3 \n PAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) \n INV ID PAK-1 / Dr. PAK-1 Doe 2 4 4 10 \n INV ID PAK-11 / Dr. PAK-11 Doe 4 3 2 9 \n INV ID PAK-12 / Dr. PAK-12 Doe 2 0 0 2 \n INV ID PAK-13 / Dr. PAK-13 Doe 1 1 0 2 \n INV ID PAK-14 / Dr. PAK-14 Doe 1 0 0 1 \n INV ID PAK-15 / Dr. PAK-15 Doe 1 0 0 1 \n INV ID PAK-2 / Dr. PAK-2 Doe 1 0 2 3 \n INV ID PAK-4 / Dr. PAK-4 Doe 0 1 1 2 \n INV ID PAK-5 / Dr. PAK-5 Doe 0 0 1 1 \n JPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) \n INV ID JPN-1 / Dr. JPN-1 Doe 2 2 1 5 \n INV ID JPN-11 / Dr. JPN-11 Doe 0 0 3 3 \n INV ID JPN-12 / Dr. JPN-12 Doe 0 0 1 1 \n INV ID JPN-14 / Dr. JPN-14 Doe 0 1 0 1 \n INV ID JPN-17 / Dr. JPN-17 Doe 0 0 2 2 \n INV ID JPN-18 / Dr. JPN-18 Doe 1 0 0 1 \n INV ID JPN-2 / Dr. JPN-2 Doe 0 0 1 1 \n INV ID JPN-3 / Dr. JPN-3 Doe 0 1 0 1 \n INV ID JPN-5 / Dr. JPN-5 Doe 1 0 1 2 \n INV ID JPN-6 / Dr. JPN-6 Doe 1 0 0 1 \nEurasia 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n RUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n INV ID RUS-1 / Dr. RUS-1 Doe 1 0 0 1 \n INV ID RUS-11 / Dr. RUS-11 Doe 0 2 2 4 \n INV ID RUS-12 / Dr. RUS-12 Doe 0 1 0 1 \n INV ID RUS-13 / Dr. RUS-13 Doe 1 0 0 1 \n INV ID RUS-14 / Dr. RUS-14 Doe 0 0 1 1 \n INV ID RUS-16 / Dr. RUS-16 Doe 1 1 0 2 \n INV ID RUS-18 / Dr. RUS-18 Doe 1 0 0 1 \n INV ID RUS-2 / Dr. RUS-2 Doe 0 1 0 1 \n INV ID RUS-3 / Dr. RUS-3 Doe 0 0 1 1 \n INV ID RUS-4 / Dr. RUS-4 Doe 0 2 1 3 \n INV ID RUS-5 / Dr. RUS-5 Doe 0 1 0 1 \n INV ID RUS-6 / Dr. RUS-6 Doe 1 0 0 1 \n INV ID RUS-7 / Dr. RUS-7 Doe 0 0 1 1 \nEurope 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n GBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n INV ID GBR-1 / Dr. GBR-1 Doe 2 0 1 3 \n INV ID GBR-11 / Dr. GBR-11 Doe 0 1 1 2 \n INV ID GBR-13 / Dr. GBR-13 Doe 1 0 0 1 \n INV ID GBR-15 / Dr. GBR-15 Doe 1 0 0 1 \n INV ID GBR-17 / Dr. GBR-17 Doe 0 1 0 1 \n INV ID GBR-6 / Dr. GBR-6 Doe 0 1 0 1 \nNorth America 13 (9.7%) 15 (11.2%) 20 (15.2%) 48 (12.0%) \n USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) \n INV ID USA-1 / Dr. USA-1 Doe 1 4 5 10 \n INV ID USA-11 / Dr. USA-11 Doe 4 2 3 9 \n INV ID USA-12 / Dr. USA-12 Doe 1 2 3 6 \n INV ID USA-14 / Dr. USA-14 Doe 1 0 0 1 \n INV ID USA-15 / Dr. USA-15 Doe 0 1 1 2 \n INV ID USA-17 / Dr. USA-17 Doe 1 1 0 2 \n INV ID USA-19 / Dr. USA-19 Doe 0 0 1 1 \n INV ID USA-2 / Dr. USA-2 Doe 0 0 1 1 \n INV ID USA-3 / Dr. USA-3 Doe 1 0 1 2 \n INV ID USA-4 / Dr. USA-4 Doe 0 1 1 2 \n INV ID USA-5 / Dr. USA-5 Doe 0 1 0 1 \n INV ID USA-6 / Dr. USA-6 Doe 0 1 0 1 \n INV ID USA-8 / Dr. USA-8 Doe 0 0 1 1 \n INV ID USA-9 / Dr. USA-9 Doe 1 0 0 1 \n CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) \n INV ID CAN-1 / Dr. CAN-1 Doe 1 1 0 2 \n INV ID CAN-11 / Dr. CAN-11 Doe 1 0 1 2 \n INV ID CAN-14 / Dr. CAN-14 Doe 1 0 0 1 \n INV ID CAN-4 / Dr. CAN-4 Doe 0 1 1 2 \n INV ID CAN-5 / Dr. CAN-5 Doe 0 0 1 1 \nSouth America 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n INV ID BRA-1 / Dr. BRA-1 Doe 4 2 2 8 \n INV ID BRA-11 / Dr. BRA-11 Doe 4 0 4 8 \n INV ID BRA-12 / Dr. BRA-12 Doe 0 1 0 1 \n INV ID BRA-13 / Dr. BRA-13 Doe 1 0 0 1 \n INV ID BRA-14 / Dr. BRA-14 Doe 1 0 1 2 \n INV ID BRA-15 / Dr. BRA-15 Doe 1 0 0 1 \n INV ID BRA-2 / Dr. BRA-2 Doe 1 1 0 2 \n INV ID BRA-3 / Dr. BRA-3 Doe 0 2 0 2 \n INV ID BRA-4 / Dr. BRA-4 Doe 0 1 1 2 \n INV ID BRA-5 / Dr. BRA-5 Doe 0 0 1 1 \n INV ID BRA-6 / Dr. BRA-6 Doe 1 0 0 1 \n INV ID BRA-7 / Dr. BRA-7 Doe 0 0 1 1 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n split_rows_by(\"COUNTRY\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adsl$COUNTRY)) %>%\n summarize_row_groups() %>%\n analyze(\"INVID_INVNAM\") %>%\n append_varlabels(adsl, \"INVID_INVNAM\", 1L)\n\nresult <- build_table(lyt, adsl) %>%\n prune_table()\n\nresult\n\nCountry A: Drug X B: Placebo C: Combination All Patients\n Investigator Number/Name (N=134) (N=134) (N=132) (N=400) \n——————————————————————————————————————————————————————————————————————————————————————————\nCHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) \n INV ID CHN-1 / Dr. CHN-1 Doe 21 20 16 57 \n INV ID CHN-10 / Dr. CHN-10 Doe 0 1 0 1 \n INV ID CHN-11 / Dr. CHN-11 Doe 12 20 16 48 \n INV ID CHN-12 / Dr. CHN-12 Doe 4 3 1 8 \n INV ID CHN-13 / Dr. CHN-13 Doe 2 6 0 8 \n INV ID CHN-14 / Dr. CHN-14 Doe 4 2 3 9 \n INV ID CHN-15 / Dr. CHN-15 Doe 2 0 4 6 \n INV ID CHN-16 / Dr. CHN-16 Doe 0 3 3 6 \n INV ID CHN-17 / Dr. CHN-17 Doe 4 4 3 11 \n INV ID CHN-18 / Dr. CHN-18 Doe 1 0 2 3 \n INV ID CHN-2 / Dr. CHN-2 Doe 9 4 3 16 \n INV ID CHN-3 / Dr. CHN-3 Doe 5 1 5 11 \n INV ID CHN-4 / Dr. CHN-4 Doe 3 3 3 9 \n INV ID CHN-5 / Dr. CHN-5 Doe 4 3 4 11 \n INV ID CHN-6 / Dr. CHN-6 Doe 1 3 0 4 \n INV ID CHN-7 / Dr. CHN-7 Doe 0 5 1 6 \n INV ID CHN-8 / Dr. CHN-8 Doe 1 1 0 2 \n INV ID CHN-9 / Dr. CHN-9 Doe 1 2 0 3 \nUSA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) \n INV ID USA-1 / Dr. USA-1 Doe 1 4 5 10 \n INV ID USA-11 / Dr. USA-11 Doe 4 2 3 9 \n INV ID USA-12 / Dr. USA-12 Doe 1 2 3 6 \n INV ID USA-14 / Dr. USA-14 Doe 1 0 0 1 \n INV ID USA-15 / Dr. USA-15 Doe 0 1 1 2 \n INV ID USA-17 / Dr. USA-17 Doe 1 1 0 2 \n INV ID USA-19 / Dr. USA-19 Doe 0 0 1 1 \n INV ID USA-2 / Dr. USA-2 Doe 0 0 1 1 \n INV ID USA-3 / Dr. USA-3 Doe 1 0 1 2 \n INV ID USA-4 / Dr. USA-4 Doe 0 1 1 2 \n INV ID USA-5 / Dr. USA-5 Doe 0 1 0 1 \n INV ID USA-6 / Dr. USA-6 Doe 0 1 0 1 \n INV ID USA-8 / Dr. USA-8 Doe 0 0 1 1 \n INV ID USA-9 / Dr. USA-9 Doe 1 0 0 1 \nBRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) \n INV ID BRA-1 / Dr. BRA-1 Doe 4 2 2 8 \n INV ID BRA-11 / Dr. BRA-11 Doe 4 0 4 8 \n INV ID BRA-12 / Dr. BRA-12 Doe 0 1 0 1 \n INV ID BRA-13 / Dr. BRA-13 Doe 1 0 0 1 \n INV ID BRA-14 / Dr. BRA-14 Doe 1 0 1 2 \n INV ID BRA-15 / Dr. BRA-15 Doe 1 0 0 1 \n INV ID BRA-2 / Dr. BRA-2 Doe 1 1 0 2 \n INV ID BRA-3 / Dr. BRA-3 Doe 0 2 0 2 \n INV ID BRA-4 / Dr. BRA-4 Doe 0 1 1 2 \n INV ID BRA-5 / Dr. BRA-5 Doe 0 0 1 1 \n INV ID BRA-6 / Dr. BRA-6 Doe 1 0 0 1 \n INV ID BRA-7 / Dr. BRA-7 Doe 0 0 1 1 \nPAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) \n INV ID PAK-1 / Dr. PAK-1 Doe 2 4 4 10 \n INV ID PAK-11 / Dr. PAK-11 Doe 4 3 2 9 \n INV ID PAK-12 / Dr. PAK-12 Doe 2 0 0 2 \n INV ID PAK-13 / Dr. PAK-13 Doe 1 1 0 2 \n INV ID PAK-14 / Dr. PAK-14 Doe 1 0 0 1 \n INV ID PAK-15 / Dr. PAK-15 Doe 1 0 0 1 \n INV ID PAK-2 / Dr. PAK-2 Doe 1 0 2 3 \n INV ID PAK-4 / Dr. PAK-4 Doe 0 1 1 2 \n INV ID PAK-5 / Dr. PAK-5 Doe 0 0 1 1 \nNGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) \n INV ID NGA-1 / Dr. NGA-1 Doe 3 3 4 10 \n INV ID NGA-11 / Dr. NGA-11 Doe 1 2 3 6 \n INV ID NGA-12 / Dr. NGA-12 Doe 0 1 1 2 \n INV ID NGA-17 / Dr. NGA-17 Doe 2 0 0 2 \n INV ID NGA-2 / Dr. NGA-2 Doe 1 1 0 2 \n INV ID NGA-4 / Dr. NGA-4 Doe 1 0 1 2 \n INV ID NGA-5 / Dr. NGA-5 Doe 0 0 1 1 \n INV ID NGA-6 / Dr. NGA-6 Doe 0 0 1 1 \nRUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) \n INV ID RUS-1 / Dr. RUS-1 Doe 1 0 0 1 \n INV ID RUS-11 / Dr. RUS-11 Doe 0 2 2 4 \n INV ID RUS-12 / Dr. RUS-12 Doe 0 1 0 1 \n INV ID RUS-13 / Dr. RUS-13 Doe 1 0 0 1 \n INV ID RUS-14 / Dr. RUS-14 Doe 0 0 1 1 \n INV ID RUS-16 / Dr. RUS-16 Doe 1 1 0 2 \n INV ID RUS-18 / Dr. RUS-18 Doe 1 0 0 1 \n INV ID RUS-2 / Dr. RUS-2 Doe 0 1 0 1 \n INV ID RUS-3 / Dr. RUS-3 Doe 0 0 1 1 \n INV ID RUS-4 / Dr. RUS-4 Doe 0 2 1 3 \n INV ID RUS-5 / Dr. RUS-5 Doe 0 1 0 1 \n INV ID RUS-6 / Dr. RUS-6 Doe 1 0 0 1 \n INV ID RUS-7 / Dr. RUS-7 Doe 0 0 1 1 \nJPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) \n INV ID JPN-1 / Dr. JPN-1 Doe 2 2 1 5 \n INV ID JPN-11 / Dr. JPN-11 Doe 0 0 3 3 \n INV ID JPN-12 / Dr. JPN-12 Doe 0 0 1 1 \n INV ID JPN-14 / Dr. JPN-14 Doe 0 1 0 1 \n INV ID JPN-17 / Dr. JPN-17 Doe 0 0 2 2 \n INV ID JPN-18 / Dr. JPN-18 Doe 1 0 0 1 \n INV ID JPN-2 / Dr. JPN-2 Doe 0 0 1 1 \n INV ID JPN-3 / Dr. JPN-3 Doe 0 1 0 1 \n INV ID JPN-5 / Dr. JPN-5 Doe 1 0 1 2 \n INV ID JPN-6 / Dr. JPN-6 Doe 1 0 0 1 \nGBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) \n INV ID GBR-1 / Dr. GBR-1 Doe 2 0 1 3 \n INV ID GBR-11 / Dr. GBR-11 Doe 0 1 1 2 \n INV ID GBR-13 / Dr. GBR-13 Doe 1 0 0 1 \n INV ID GBR-15 / Dr. GBR-15 Doe 1 0 0 1 \n INV ID GBR-17 / Dr. GBR-17 Doe 0 1 0 1 \n INV ID GBR-6 / Dr. GBR-6 Doe 0 1 0 1 \nCAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) \n INV ID CAN-1 / Dr. CAN-1 Doe 1 1 0 2 \n INV ID CAN-11 / Dr. CAN-11 Doe 1 0 1 2 \n INV ID CAN-14 / Dr. CAN-14 Doe 1 0 0 1 \n INV ID CAN-4 / Dr. CAN-4 Doe 0 1 1 2 \n INV ID CAN-5 / Dr. CAN-5 Doe 0 0 1 1 \n\n\n\n\nNote that for this module application, only the variables passed into by_vars are used when row_groups is selected. Variables passed into analyze_vars are additionally used when row_groups is deselected.\n\nCodelibrary(dplyr)\nlibrary(forcats)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\n\nadsl_labels <- var_labels(adsl)\n\nadsl <- adsl %>%\n mutate(\n REGION1 = droplevels(REGION1),\n COUNTRY = droplevels(COUNTRY),\n INVID_INVNAM = paste(INVID, INVNAM, sep = \" / \")\n ) %>%\n arrange(REGION1, COUNTRY, INVID) %>%\n mutate(\n INVID = factor(INVID),\n SITEID = factor(SITEID),\n INVNAM = factor(INVNAM),\n INVID_INVNAM = factor(INVID_INVNAM)\n )\n\nvar_labels(adsl) <- c(adsl_labels, \"Investigator Number/Name\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\n ADSL_labels <- var_labels(ADSL)\n ADSL <- ADSL %>% mutate(\n REGION1 = droplevels(REGION1),\n COUNTRY = droplevels(COUNTRY),\n INVID_INVNAM = paste(INVID, INVNAM, sep = \" / \")\n ) %>%\n arrange(REGION1, COUNTRY, INVID) %>%\n mutate(\n INVID = factor(INVID),\n SITEID = factor(SITEID),\n INVNAM = factor(INVNAM),\n INVID_INVNAM = factor(INVID_INVNAM)\n )\n\n var_labels(ADSL) <- c(ADSL_labels, \"Investigator Number/Name\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Enrollment Table\",\n dataname = \"ADSL\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adsl, c(\"REGION1\", \"COUNTRY\", \"SITEID\", \"INVID\", \"INVNAM\", \"INVID_INVNAM\")),\n selected = c(\"REGION1\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adsl, c(\"REGION1\", \"COUNTRY\", \"SITEID\", \"INVID\", \"INVNAM\", \"INVID_INVNAM\")),\n selected = c(\"SITEID\")\n ),\n denominator = choices_selected(\n choices = c(\"n\", \"N\", \"omit\"),\n selected = \"N\",\n fixed = TRUE\n ),\n useNA = \"ifany\",\n row_groups = TRUE\n )\n )\n)\n\n[INFO] 2023-09-09 17:50:37.6125 pid:3485 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] scda_0.1.6.9012 forcats_1.0.0 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/pdt02.html",
@@ -417,28 +417,28 @@
"href": "tables/safety/cmt01b.html",
"title": "CMT01B",
"section": "",
- "text": "Data Setup\nStandard Table with > 1 ATC Class Level\nTable Changing Class Levels\nTable with Classes Sorted by Frequency\nTable with Total Number of Treatments per Medication Class Suppressed\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.factor(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\n# Keep only safety-evaluable patients and concomitant medications\nadsl <- adsl %>%\n filter(SAFFL == \"Y\")\n\nadcm <- adcm %>%\n filter(SAFFL == \"Y\" & ATIREL == \"CONCOMITANT\")\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC1\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC1)\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n split_rows_by(\n \"ATC3\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC3)\n ) %>%\n split_rows_by(\n \"ATC4\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC4)\n ) %>%\n append_topleft(\" Other Treatment\") %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC1\", \"*\", \"ATC2\", \"*\", \"ATC3\", \"*\", \"ATC4\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 1 Text \n ATC Level 2 Text \n ATC Level 3 Text \n ATC Level 4 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS1 A \n ATCCLAS2 A \n ATCCLAS3 A \n ATCCLAS4 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 A p2 \n ATCCLAS2 A p2 \n ATCCLAS3 A p2 \n ATCCLAS4 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 B \n ATCCLAS2 B \n ATCCLAS3 B \n ATCCLAS4 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS1 B p2 \n ATCCLAS2 B p2 \n ATCCLAS3 B p2 \n ATCCLAS4 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 B p3 \n ATCCLAS2 B p3 \n ATCCLAS3 B p3 \n ATCCLAS4 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 C \n ATCCLAS2 C \n ATCCLAS3 C \n ATCCLAS4 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p2 \n ATCCLAS2 C p2 \n ATCCLAS3 C p2 \n ATCCLAS4 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p3 \n ATCCLAS2 C p3 \n ATCCLAS3 C p3 \n ATCCLAS4 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n analyze_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC3\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC3)\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_topleft(\" Other Treatment\")\n\nresult <- build_table(\n lyt = lyt,\n df = adcm,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC3\", \"*\", \"ATC2\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 3 Text \n ATC Level 2 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS3 A \n ATCCLAS2 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS3 A p2 \n ATCCLAS2 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS3 B \n ATCCLAS2 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS3 B p2 \n ATCCLAS2 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS3 B p3 \n ATCCLAS2 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS3 C \n ATCCLAS2 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS3 C p2 \n ATCCLAS2 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS3 C p3 \n ATCCLAS2 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCode# In progress\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\n \"ATC1\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC1)\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n split_rows_by(\n \"ATC3\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC3)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC4\",\n child_labels = \"visible\",\n nested = TRUE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC4)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_topleft(\" Other Treatment\")\n\nresult <- build_table(\n lyt = lyt,\n df = adcm,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC1\", \"*\", \"ATC2\", \"*\", \"ATC3\", \"*\", \"ATC4\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 1 Text \n ATC Level 2 Text \n ATC Level 3 Text \n ATC Level 4 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————\nATCCLAS1 A \n ATCCLAS2 A \n ATCCLAS3 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n ATCCLAS4 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 A p2 \n ATCCLAS2 A p2 \n ATCCLAS3 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n ATCCLAS4 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 B \n ATCCLAS2 B \n ATCCLAS3 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n ATCCLAS4 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS1 B p2 \n ATCCLAS2 B p2 \n ATCCLAS3 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n ATCCLAS4 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 B p3 \n ATCCLAS2 B p3 \n ATCCLAS3 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n ATCCLAS4 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 C \n ATCCLAS2 C \n ATCCLAS3 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n ATCCLAS4 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p2 \n ATCCLAS2 C p2 \n ATCCLAS3 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n ATCCLAS4 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p3 \n ATCCLAS2 C p3 \n ATCCLAS3 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n ATCCLAS4 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.integer(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm_keys <- c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"CMSEQ\", \"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)\n '),\n cdisc_dataset(\"ADCM\", adcm,\n code = '\n ADCM <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n ADCM$CMSEQ <- as.factor(ADCM$CMSEQ)\n ADCM <- df_explicit_na(ADCM)\n ',\n keys = adcm_keys\n )\n ),\n modules = modules(\n tm_t_mult_events(\n label = \"Concomitant Medications by Medication Class and Preferred Name\",\n dataname = \"ADCM\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n seq_var = choices_selected(\"CMSEQ\", selected = \"CMSEQ\", fixed = TRUE),\n hlt = choices_selected(\n choices = variable_choices(adcm, c(\"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")),\n selected = c(\"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")\n ),\n llt = choices_selected(\n choices = variable_choices(adcm, c(\"CMDECOD\")),\n selected = c(\"CMDECOD\")\n ),\n add_total = FALSE,\n event_type = \"treatment\"\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\"),\n ADCM = list(ATIREL = \"CONCOMITANT\")\n )\n)\n\n[INFO] 2023-09-08 19:31:58.2753 pid:3135 token:[] teal.modules.clinical Initializing tm_t_mult_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table with > 1 ATC Class Level\nTable Changing Class Levels\nTable with Classes Sorted by Frequency\nTable with Total Number of Treatments per Medication Class Suppressed\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.factor(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\n# Keep only safety-evaluable patients and concomitant medications\nadsl <- adsl %>%\n filter(SAFFL == \"Y\")\n\nadcm <- adcm %>%\n filter(SAFFL == \"Y\" & ATIREL == \"CONCOMITANT\")\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC1\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC1)\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n split_rows_by(\n \"ATC3\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC3)\n ) %>%\n split_rows_by(\n \"ATC4\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC4)\n ) %>%\n append_topleft(\" Other Treatment\") %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC1\", \"*\", \"ATC2\", \"*\", \"ATC3\", \"*\", \"ATC4\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 1 Text \n ATC Level 2 Text \n ATC Level 3 Text \n ATC Level 4 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS1 A \n ATCCLAS2 A \n ATCCLAS3 A \n ATCCLAS4 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 A p2 \n ATCCLAS2 A p2 \n ATCCLAS3 A p2 \n ATCCLAS4 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 B \n ATCCLAS2 B \n ATCCLAS3 B \n ATCCLAS4 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS1 B p2 \n ATCCLAS2 B p2 \n ATCCLAS3 B p2 \n ATCCLAS4 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 B p3 \n ATCCLAS2 B p3 \n ATCCLAS3 B p3 \n ATCCLAS4 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 C \n ATCCLAS2 C \n ATCCLAS3 C \n ATCCLAS4 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p2 \n ATCCLAS2 C p2 \n ATCCLAS3 C p2 \n ATCCLAS4 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p3 \n ATCCLAS2 C p3 \n ATCCLAS3 C p3 \n ATCCLAS4 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n analyze_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC3\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC3)\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_topleft(\" Other Treatment\")\n\nresult <- build_table(\n lyt = lyt,\n df = adcm,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC3\", \"*\", \"ATC2\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 3 Text \n ATC Level 2 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nATCCLAS3 A \n ATCCLAS2 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS3 A p2 \n ATCCLAS2 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS3 B \n ATCCLAS2 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS3 B p2 \n ATCCLAS2 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS3 B p3 \n ATCCLAS2 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS3 C \n ATCCLAS2 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS3 C p2 \n ATCCLAS2 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS3 C p3 \n ATCCLAS2 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCode# In progress\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\n \"ATC1\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC1)\n ) %>%\n split_rows_by(\n \"ATC2\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC2)\n ) %>%\n split_rows_by(\n \"ATC3\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC3)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"ATC4\",\n child_labels = \"visible\",\n nested = TRUE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adcm$ATC4)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_topleft(\" Other Treatment\")\n\nresult <- build_table(\n lyt = lyt,\n df = adcm,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sort lowest level terms by descending frequency.\n sort_at_path(\n path = c(\"ATC1\", \"*\", \"ATC2\", \"*\", \"ATC3\", \"*\", \"ATC4\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nATC Level 1 Text \n ATC Level 2 Text \n ATC Level 3 Text \n ATC Level 4 Text A: Drug X B: Placebo C: Combination\n Other Treatment (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————————\nATCCLAS1 A \n ATCCLAS2 A \n ATCCLAS3 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n ATCCLAS4 A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 A p2 \n ATCCLAS2 A p2 \n ATCCLAS3 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n Total number of treatments 58 66 64 \n ATCCLAS4 A p2 \n Total number of patients with at least one treatment 45 (33.6%) 54 (40.3%) 48 (36.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nATCCLAS1 B \n ATCCLAS2 B \n ATCCLAS3 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n ATCCLAS4 B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nATCCLAS1 B p2 \n ATCCLAS2 B p2 \n ATCCLAS3 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n ATCCLAS4 B p2 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 B p3 \n ATCCLAS2 B p3 \n ATCCLAS3 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n Total number of treatments 75 82 83 \n ATCCLAS4 B p3 \n Total number of patients with at least one treatment 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \nATCCLAS1 C \n ATCCLAS2 C \n ATCCLAS3 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n ATCCLAS4 C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p2 \n ATCCLAS2 C p2 \n ATCCLAS3 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n ATCCLAS4 C p2 \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \nATCCLAS1 C p3 \n ATCCLAS2 C p3 \n ATCCLAS3 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n Total number of treatments 69 73 80 \n ATCCLAS4 C p3 \n Total number of patients with at least one treatment 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.integer(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm_keys <- c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"CMSEQ\", \"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)\n '),\n cdisc_dataset(\"ADCM\", adcm,\n code = '\n ADCM <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n ADCM$CMSEQ <- as.factor(ADCM$CMSEQ)\n ADCM <- df_explicit_na(ADCM)\n ',\n keys = adcm_keys\n )\n ),\n modules = modules(\n tm_t_mult_events(\n label = \"Concomitant Medications by Medication Class and Preferred Name\",\n dataname = \"ADCM\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n seq_var = choices_selected(\"CMSEQ\", selected = \"CMSEQ\", fixed = TRUE),\n hlt = choices_selected(\n choices = variable_choices(adcm, c(\"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")),\n selected = c(\"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")\n ),\n llt = choices_selected(\n choices = variable_choices(adcm, c(\"CMDECOD\")),\n selected = c(\"CMDECOD\")\n ),\n add_total = FALSE,\n event_type = \"treatment\"\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\"),\n ADCM = list(ATIREL = \"CONCOMITANT\")\n )\n)\n\n[INFO] 2023-09-09 17:48:33.1891 pid:3140 token:[] teal.modules.clinical Initializing tm_t_mult_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt03.html",
"href": "tables/lab-results/lbt03.html",
"title": "LBT03",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\nFor illustration purposes, this example focuses on “C-Reactive Protein Measurement” starting from baseline, while excluding visit at week 1 for subjects who were randomized to the placebo group.\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\nsaved_labels <- var_labels(adlb)\n\nadlb_f <- adlb %>%\n filter(\n PARAM == \"C-Reactive Protein Measurement\",\n !(ARM == \"B: Placebo\" &\n AVISIT == \"WEEK 1 DAY 8\"),\n AVISIT != \"SCREENING\"\n ) %>%\n dplyr::mutate(\n AVISIT = droplevels(AVISIT),\n ABLFLL = ABLFL == \"Y\"\n )\n\nvar_labels(adlb_f) <- c(saved_labels, \"\")\n\n\n\n\nThe LBT03 template is the result of a junction between the analysis of AVAL at baseline and CHG at visit time. AVAL is summarized for baseline visits and and CHG is summarized for post-baseline visits.\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adlb_f$AVISIT)) %>%\n summarize_change(\n \"CHG\",\n variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"),\n na.rm = TRUE\n )\n\nresult <- build_table(\n lyt = lyt,\n df = adlb_f,\n alt_counts_df = adsl\n)\n\nresult\n\nAnalysis Visit A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————\nBASELINE \n n 134 134 132 \n Mean (SD) 9.06 (0.93) 8.99 (0.98) 8.98 (0.89) \n Median 9.07 8.92 8.96 \n Min - Max 6.21 - 11.87 6.23 - 11.63 6.24 - 11.18 \nWEEK 1 DAY 8 \n n 134 0 132 \n Mean (SD) -0.05 (1.38) NA -0.02 (1.30) \n Median -0.17 NA 0.02 \n Min - Max -3.56 - 3.48 NA -3.28 - 3.33 \nWEEK 2 DAY 15 \n n 134 134 132 \n Mean (SD) -0.19 (1.47) 0.01 (1.45) 0.15 (1.25) \n Median -0.27 -0.00 0.15 \n Min - Max -4.53 - 4.45 -3.79 - 3.43 -2.92 - 3.28 \nWEEK 3 DAY 22 \n n 134 134 132 \n Mean (SD) 0.03 (1.38) -0.02 (1.49) 0.02 (1.34) \n Median 0.15 -0.04 0.20 \n Min - Max -3.95 - 2.99 -4.28 - 4.24 -2.76 - 3.26 \nWEEK 4 DAY 29 \n n 134 134 132 \n Mean (SD) -0.26 (1.45) 0.05 (1.24) -0.01 (1.17) \n Median -0.37 0.10 -0.06 \n Min - Max -3.74 - 4.15 -3.34 - 3.71 -3.06 - 3.22 \nWEEK 5 DAY 36 \n n 134 134 132 \n Mean (SD) -0.02 (1.50) 0.07 (1.34) 0.03 (1.27) \n Median 0.01 0.15 0.05 \n Min - Max -4.15 - 3.96 -3.50 - 3.53 -3.63 - 4.78 \n\n\nIn the final step, a new variable is derived from AVISIT that can specify the method of estimation of the evaluated change.\n\nCodeadlb_f <- adlb_f %>% mutate(AVISIT_header = recode(AVISIT,\n \"BASELINE\" = \"BASELINE\",\n \"WEEK 1 DAY 8\" = \"WEEK 1 DAY 8 value minus baseline\",\n \"WEEK 2 DAY 15\" = \"WEEK 2 DAY 15 value minus baseline\",\n \"WEEK 3 DAY 22\" = \"WEEK 3 DAY 22 value minus baseline\",\n \"WEEK 4 DAY 29\" = \"WEEK 4 DAY 29 value minus baseline\",\n \"WEEK 5 DAY 36\" = \"WEEK 5 DAY 36 value minus baseline\"\n))\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\"AVISIT_header\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adlb_f$AVISIT)\n ) %>%\n summarize_change(\n \"CHG\",\n variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"),\n na.rm = TRUE\n )\n\nresult <- build_table(\n lyt = lyt,\n df = adlb_f,\n alt_counts_df = adsl\n)\n\nresult\n\nAnalysis Visit A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————\nBASELINE \n n 134 134 132 \n Mean (SD) 9.06 (0.93) 8.99 (0.98) 8.98 (0.89) \n Median 9.07 8.92 8.96 \n Min - Max 6.21 - 11.87 6.23 - 11.63 6.24 - 11.18 \nWEEK 1 DAY 8 value minus baseline \n n 134 0 132 \n Mean (SD) -0.05 (1.38) NA -0.02 (1.30) \n Median -0.17 NA 0.02 \n Min - Max -3.56 - 3.48 NA -3.28 - 3.33 \nWEEK 2 DAY 15 value minus baseline \n n 134 134 132 \n Mean (SD) -0.19 (1.47) 0.01 (1.45) 0.15 (1.25) \n Median -0.27 -0.00 0.15 \n Min - Max -4.53 - 4.45 -3.79 - 3.43 -2.92 - 3.28 \nWEEK 3 DAY 22 value minus baseline \n n 134 134 132 \n Mean (SD) 0.03 (1.38) -0.02 (1.49) 0.02 (1.34) \n Median 0.15 -0.04 0.20 \n Min - Max -3.95 - 2.99 -4.28 - 4.24 -2.76 - 3.26 \nWEEK 4 DAY 29 value minus baseline \n n 134 134 132 \n Mean (SD) -0.26 (1.45) 0.05 (1.24) -0.01 (1.17) \n Median -0.37 0.10 -0.06 \n Min - Max -3.74 - 4.15 -3.34 - 3.71 -3.06 - 3.22 \nWEEK 5 DAY 36 value minus baseline \n n 134 134 132 \n Mean (SD) -0.02 (1.50) 0.07 (1.34) 0.03 (1.27) \n Median 0.01 0.15 0.05 \n Min - Max -4.15 - 3.96 -3.50 - 3.53 -3.63 - 4.78 \n\n\n\n\nHere, we pre-process and manually define the variable “Baseline or Absolute Change from Baseline”.\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\nadlb <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adlb\")) %>%\n filter(\n !(ARM == \"B: Placebo\" & AVISIT == \"WEEK 1 DAY 8\"),\n AVISIT != \"SCREENING\"\n ) %>%\n dplyr::mutate(\n AVISIT = droplevels(AVISIT),\n ABLFLL = ABLFL == \"Y\",\n AVISIT_header = recode(AVISIT,\n \"BASELINE\" = \"BASELINE\",\n \"WEEK 1 DAY 8\" = \"WEEK 1 DAY 8 value minus baseline\",\n \"WEEK 2 DAY 15\" = \"WEEK 2 DAY 15 value minus baseline\",\n \"WEEK 3 DAY 22\" = \"WEEK 3 DAY 22 value minus baseline\",\n \"WEEK 4 DAY 29\" = \"WEEK 4 DAY 29 value minus baseline\",\n \"WEEK 5 DAY 36\" = \"WEEK 5 DAY 36 value minus baseline\"\n )\n ) %>%\n dplyr::group_by(USUBJID, PARAM) %>%\n dplyr::mutate(\n AVAL_CHG = AVAL - (!ABLFLL) * sum(AVAL * ABLFLL)\n ) %>%\n dplyr::ungroup() %>%\n var_relabel(\n AVAL_CHG = \"Baseline or Absolute Change from Baseline\",\n ABLFLL = \"Baseline Flag (TRUE/FALSE)\",\n AVISIT_header = \"Analysis Visit\"\n )\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADLB\", adlb, code = '\n ADLB <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adlb\")) %>%\n filter(\n !(ARM == \"B: Placebo\" & AVISIT == \"WEEK 1 DAY 8\"),\n AVISIT != \"SCREENING\"\n ) %>%\n dplyr::mutate(\n AVISIT = droplevels(AVISIT),\n ABLFLL = ABLFL == \"Y\",\n AVISIT_header = recode(AVISIT,\n \"BASELINE\" = \"BASELINE\",\n \"WEEK 1 DAY 8\" = \"WEEK 1 DAY 8 value minus baseline\",\n \"WEEK 2 DAY 15\" = \"WEEK 2 DAY 15 value minus baseline\",\n \"WEEK 3 DAY 22\" = \"WEEK 3 DAY 22 value minus baseline\",\n \"WEEK 4 DAY 29\" = \"WEEK 4 DAY 29 value minus baseline\",\n \"WEEK 5 DAY 36\" = \"WEEK 5 DAY 36 value minus baseline\"\n )\n ) %>%\n dplyr::group_by(USUBJID, PARAM) %>%\n dplyr::mutate(\n AVAL_CHG = AVAL - (!ABLFLL) * sum(AVAL * ABLFLL)\n ) %>%\n dplyr::ungroup() %>%\n var_relabel(\n AVAL_CHG = \"Baseline or Absolute Change from Baseline\",\n ABLFLL = \"Baseline Flag (TRUE/FALSE)\",\n AVISIT_header = \"Analysis Visit\"\n )'),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Laboratory Test Results Change from Baseline by Visit\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, c(\"PARAM\", \"AVISIT_header\")), # note: order matters here. If `PARAM` is first, the split will be first by `PARAM`and then by `AVISIT`\n selected = c(\"PARAM\", \"AVISIT_header\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adlb, c(\"AVAL\", \"CHG\", \"AVAL_CHG\")),\n selected = c(\"AVAL_CHG\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"CRP\"\n )\n )\n ),\n filter = list(ADLB = list(AVAL = list()))\n)\n\n[INFO] 2023-09-08 19:31:27.2824 pid:2986 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\nFor illustration purposes, this example focuses on “C-Reactive Protein Measurement” starting from baseline, while excluding visit at week 1 for subjects who were randomized to the placebo group.\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\nsaved_labels <- var_labels(adlb)\n\nadlb_f <- adlb %>%\n filter(\n PARAM == \"C-Reactive Protein Measurement\",\n !(ARM == \"B: Placebo\" &\n AVISIT == \"WEEK 1 DAY 8\"),\n AVISIT != \"SCREENING\"\n ) %>%\n dplyr::mutate(\n AVISIT = droplevels(AVISIT),\n ABLFLL = ABLFL == \"Y\"\n )\n\nvar_labels(adlb_f) <- c(saved_labels, \"\")\n\n\n\n\nThe LBT03 template is the result of a junction between the analysis of AVAL at baseline and CHG at visit time. AVAL is summarized for baseline visits and and CHG is summarized for post-baseline visits.\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adlb_f$AVISIT)) %>%\n summarize_change(\n \"CHG\",\n variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"),\n na.rm = TRUE\n )\n\nresult <- build_table(\n lyt = lyt,\n df = adlb_f,\n alt_counts_df = adsl\n)\n\nresult\n\nAnalysis Visit A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————\nBASELINE \n n 134 134 132 \n Mean (SD) 9.06 (0.93) 8.99 (0.98) 8.98 (0.89) \n Median 9.07 8.92 8.96 \n Min - Max 6.21 - 11.87 6.23 - 11.63 6.24 - 11.18 \nWEEK 1 DAY 8 \n n 134 0 132 \n Mean (SD) -0.05 (1.38) NA -0.02 (1.30) \n Median -0.17 NA 0.02 \n Min - Max -3.56 - 3.48 NA -3.28 - 3.33 \nWEEK 2 DAY 15 \n n 134 134 132 \n Mean (SD) -0.19 (1.47) 0.01 (1.45) 0.15 (1.25) \n Median -0.27 -0.00 0.15 \n Min - Max -4.53 - 4.45 -3.79 - 3.43 -2.92 - 3.28 \nWEEK 3 DAY 22 \n n 134 134 132 \n Mean (SD) 0.03 (1.38) -0.02 (1.49) 0.02 (1.34) \n Median 0.15 -0.04 0.20 \n Min - Max -3.95 - 2.99 -4.28 - 4.24 -2.76 - 3.26 \nWEEK 4 DAY 29 \n n 134 134 132 \n Mean (SD) -0.26 (1.45) 0.05 (1.24) -0.01 (1.17) \n Median -0.37 0.10 -0.06 \n Min - Max -3.74 - 4.15 -3.34 - 3.71 -3.06 - 3.22 \nWEEK 5 DAY 36 \n n 134 134 132 \n Mean (SD) -0.02 (1.50) 0.07 (1.34) 0.03 (1.27) \n Median 0.01 0.15 0.05 \n Min - Max -4.15 - 3.96 -3.50 - 3.53 -3.63 - 4.78 \n\n\nIn the final step, a new variable is derived from AVISIT that can specify the method of estimation of the evaluated change.\n\nCodeadlb_f <- adlb_f %>% mutate(AVISIT_header = recode(AVISIT,\n \"BASELINE\" = \"BASELINE\",\n \"WEEK 1 DAY 8\" = \"WEEK 1 DAY 8 value minus baseline\",\n \"WEEK 2 DAY 15\" = \"WEEK 2 DAY 15 value minus baseline\",\n \"WEEK 3 DAY 22\" = \"WEEK 3 DAY 22 value minus baseline\",\n \"WEEK 4 DAY 29\" = \"WEEK 4 DAY 29 value minus baseline\",\n \"WEEK 5 DAY 36\" = \"WEEK 5 DAY 36 value minus baseline\"\n))\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\"AVISIT_header\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adlb_f$AVISIT)\n ) %>%\n summarize_change(\n \"CHG\",\n variables = list(value = \"AVAL\", baseline_flag = \"ABLFLL\"),\n na.rm = TRUE\n )\n\nresult <- build_table(\n lyt = lyt,\n df = adlb_f,\n alt_counts_df = adsl\n)\n\nresult\n\nAnalysis Visit A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————\nBASELINE \n n 134 134 132 \n Mean (SD) 9.06 (0.93) 8.99 (0.98) 8.98 (0.89) \n Median 9.07 8.92 8.96 \n Min - Max 6.21 - 11.87 6.23 - 11.63 6.24 - 11.18 \nWEEK 1 DAY 8 value minus baseline \n n 134 0 132 \n Mean (SD) -0.05 (1.38) NA -0.02 (1.30) \n Median -0.17 NA 0.02 \n Min - Max -3.56 - 3.48 NA -3.28 - 3.33 \nWEEK 2 DAY 15 value minus baseline \n n 134 134 132 \n Mean (SD) -0.19 (1.47) 0.01 (1.45) 0.15 (1.25) \n Median -0.27 -0.00 0.15 \n Min - Max -4.53 - 4.45 -3.79 - 3.43 -2.92 - 3.28 \nWEEK 3 DAY 22 value minus baseline \n n 134 134 132 \n Mean (SD) 0.03 (1.38) -0.02 (1.49) 0.02 (1.34) \n Median 0.15 -0.04 0.20 \n Min - Max -3.95 - 2.99 -4.28 - 4.24 -2.76 - 3.26 \nWEEK 4 DAY 29 value minus baseline \n n 134 134 132 \n Mean (SD) -0.26 (1.45) 0.05 (1.24) -0.01 (1.17) \n Median -0.37 0.10 -0.06 \n Min - Max -3.74 - 4.15 -3.34 - 3.71 -3.06 - 3.22 \nWEEK 5 DAY 36 value minus baseline \n n 134 134 132 \n Mean (SD) -0.02 (1.50) 0.07 (1.34) 0.03 (1.27) \n Median 0.01 0.15 0.05 \n Min - Max -4.15 - 3.96 -3.50 - 3.53 -3.63 - 4.78 \n\n\n\n\nHere, we pre-process and manually define the variable “Baseline or Absolute Change from Baseline”.\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\nadlb <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adlb\")) %>%\n filter(\n !(ARM == \"B: Placebo\" & AVISIT == \"WEEK 1 DAY 8\"),\n AVISIT != \"SCREENING\"\n ) %>%\n dplyr::mutate(\n AVISIT = droplevels(AVISIT),\n ABLFLL = ABLFL == \"Y\",\n AVISIT_header = recode(AVISIT,\n \"BASELINE\" = \"BASELINE\",\n \"WEEK 1 DAY 8\" = \"WEEK 1 DAY 8 value minus baseline\",\n \"WEEK 2 DAY 15\" = \"WEEK 2 DAY 15 value minus baseline\",\n \"WEEK 3 DAY 22\" = \"WEEK 3 DAY 22 value minus baseline\",\n \"WEEK 4 DAY 29\" = \"WEEK 4 DAY 29 value minus baseline\",\n \"WEEK 5 DAY 36\" = \"WEEK 5 DAY 36 value minus baseline\"\n )\n ) %>%\n dplyr::group_by(USUBJID, PARAM) %>%\n dplyr::mutate(\n AVAL_CHG = AVAL - (!ABLFLL) * sum(AVAL * ABLFLL)\n ) %>%\n dplyr::ungroup() %>%\n var_relabel(\n AVAL_CHG = \"Baseline or Absolute Change from Baseline\",\n ABLFLL = \"Baseline Flag (TRUE/FALSE)\",\n AVISIT_header = \"Analysis Visit\"\n )\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADLB\", adlb, code = '\n ADLB <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adlb\")) %>%\n filter(\n !(ARM == \"B: Placebo\" & AVISIT == \"WEEK 1 DAY 8\"),\n AVISIT != \"SCREENING\"\n ) %>%\n dplyr::mutate(\n AVISIT = droplevels(AVISIT),\n ABLFLL = ABLFL == \"Y\",\n AVISIT_header = recode(AVISIT,\n \"BASELINE\" = \"BASELINE\",\n \"WEEK 1 DAY 8\" = \"WEEK 1 DAY 8 value minus baseline\",\n \"WEEK 2 DAY 15\" = \"WEEK 2 DAY 15 value minus baseline\",\n \"WEEK 3 DAY 22\" = \"WEEK 3 DAY 22 value minus baseline\",\n \"WEEK 4 DAY 29\" = \"WEEK 4 DAY 29 value minus baseline\",\n \"WEEK 5 DAY 36\" = \"WEEK 5 DAY 36 value minus baseline\"\n )\n ) %>%\n dplyr::group_by(USUBJID, PARAM) %>%\n dplyr::mutate(\n AVAL_CHG = AVAL - (!ABLFLL) * sum(AVAL * ABLFLL)\n ) %>%\n dplyr::ungroup() %>%\n var_relabel(\n AVAL_CHG = \"Baseline or Absolute Change from Baseline\",\n ABLFLL = \"Baseline Flag (TRUE/FALSE)\",\n AVISIT_header = \"Analysis Visit\"\n )'),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Laboratory Test Results Change from Baseline by Visit\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, c(\"PARAM\", \"AVISIT_header\")), # note: order matters here. If `PARAM` is first, the split will be first by `PARAM`and then by `AVISIT`\n selected = c(\"PARAM\", \"AVISIT_header\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adlb, c(\"AVAL\", \"CHG\", \"AVAL_CHG\")),\n selected = c(\"AVAL_CHG\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"CRP\"\n )\n )\n ),\n filter = list(ADLB = list(AVAL = list()))\n)\n\n[INFO] 2023-09-09 17:47:51.3762 pid:2991 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt14.html",
"href": "tables/lab-results/lbt14.html",
"title": "LBT14",
"section": "",
- "text": "Data Setup\nStandard Table (High)\nStandard Table (Low)\nTable Without Patients with Missing Baseline (High)\nTable with Missing Baseline Considered as Grade 0 (Low)\nTable with Fill-In of Grades\nteal App\nReproducibility\n\n\n\nPlease note that for each variant, the adlb dataset needs to be filtered on correct flags like WGRLOFL, WGRHIFL, et al., otherwise the layout function will not return the correct counts. There is an option to create a record for a lab test where no record is found at that visit. If you specified add_derived_type = \"PHANTOM\" & dtype_phantom_cond, you don’t have to use the h_adsl_adlb_merge_using_worst_flag function to preprocess your adlb dataset. Otherwise please follow the pre-processing steps below before applying the layout functions.\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\n# Please note that in real clinical data, population flag like SAFFL, and parameter category like PARCAT2 needs to be\n# selected properly.\nadsl_f <- adsl %>% filter(SAFFL == \"Y\")\nadlb <- adlb %>% filter(SAFFL == \"Y\")\n\n\n\n\nNote that the worst laboratory flag (below WGRHIFL) must be selected appropriately in the pre-processing step. New grouping variables ATOXGR_GP (post-baseline) and BTOXGR_GP (baseline) are created to display the correct output.\n\nCodeadlb_f <- adlb %>% filter(WGRHIFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRHIFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not High 134 134 132 \n Not High 134 (100%) 134 (100%) 132 (100%) \nC-Reactive Protein Measurement \n Not High 114 112 115 \n Not High 45 (33.6%) 55 (41.0%) 57 (43.2%) \n 1 18 (13.4%) 18 (13.4%) 19 (14.4%) \n 2 19 (14.2%) 10 (7.5%) 11 (8.3%) \n 3 22 (16.4%) 13 (9.7%) 20 (15.2%) \n 4 10 (7.5%) 16 (11.9%) 8 (6.1%) \n 1 8 10 7 \n Not High 5 (3.7%) 2 (1.5%) 2 (1.5%) \n 1 0 1 (0.7%) 0 \n 2 1 (0.7%) 3 (2.2%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 3 (2.2%) 2 (1.5%) \n 2 2 6 7 \n Not High 1 (0.7%) 4 (3.0%) 4 (3.0%) \n 1 0 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 4 0 0 1 (0.8%) \n 3 7 4 3 \n Not High 3 (2.2%) 0 2 (1.5%) \n 1 2 (1.5%) 1 (0.7%) 1 (0.8%) \n 2 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n 4 3 2 0 \n Not High 1 (0.7%) 0 0 \n 1 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 0 0 \nImmunoglobulin A Measurement \n Not High 119 116 113 \n Not High 55 (41.0%) 54 (40.3%) 51 (38.6%) \n 1 18 (13.4%) 11 (8.2%) 15 (11.4%) \n 2 14 (10.4%) 22 (16.4%) 19 (14.4%) \n 3 20 (14.9%) 19 (14.2%) 20 (15.2%) \n 4 12 (9.0%) 10 (7.5%) 8 (6.1%) \n 1 5 4 2 \n Not High 4 (3.0%) 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 2 (1.5%) 0 \n 2 4 4 5 \n Not High 2 (1.5%) 3 (2.2%) 3 (2.3%) \n 1 1 (0.7%) 0 2 (1.5%) \n 3 1 (0.7%) 0 0 \n 4 0 1 (0.7%) 0 \n 3 4 5 11 \n Not High 3 (2.2%) 1 (0.7%) 6 (4.5%) \n 1 0 1 (0.7%) 1 (0.8%) \n 2 1 (0.7%) 0 0 \n 3 0 2 (1.5%) 3 (2.3%) \n 4 0 1 (0.7%) 1 (0.8%) \n 4 2 5 1 \n Not High 0 3 (2.2%) 1 (0.8%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n\n\n\n\nNote that the worst laboratory flag (below WGRLOFL) must be selected appropriately in the pre-processing step. New grouping variables ATOXGR_GP (post-baseline) and BTOXGR_GP (baseline) are created to display the correct output.\n\nCodeadlb_f <- adlb %>% filter(WGRLOFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRLOFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n ATOXGR == -1 ~ \"1\",\n ATOXGR == -2 ~ \"2\",\n ATOXGR == -3 ~ \"3\",\n ATOXGR == -4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n BTOXGR == -1 ~ \"1\",\n BTOXGR == -2 ~ \"2\",\n BTOXGR == -3 ~ \"3\",\n BTOXGR == -4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not Low 113 117 123 \n Not Low 56 (41.8%) 55 (41.0%) 62 (47.0%) \n 1 11 (8.2%) 9 (6.7%) 15 (11.4%) \n 2 15 (11.2%) 23 (17.2%) 16 (12.1%) \n 3 15 (11.2%) 21 (15.7%) 13 (9.8%) \n 4 16 (11.9%) 9 (6.7%) 17 (12.9%) \n 1 6 6 4 \n Not Low 3 (2.2%) 5 (3.7%) 3 (2.3%) \n 1 3 (2.2%) 0 0 \n 4 0 1 (0.7%) 1 (0.8%) \n 2 8 5 1 \n Not Low 5 (3.7%) 3 (2.2%) 0 \n 1 0 1 (0.7%) 0 \n 2 2 (1.5%) 0 0 \n 3 0 1 (0.7%) 1 (0.8%) \n 4 1 (0.7%) 0 0 \n 3 3 3 2 \n Not Low 0 1 (0.7%) 0 \n 1 1 (0.7%) 0 0 \n 2 1 (0.7%) 0 1 (0.8%) \n 3 1 (0.7%) 2 (1.5%) 1 (0.8%) \n 4 4 3 2 \n Not Low 4 (3.0%) 1 (0.7%) 1 (0.8%) \n 1 0 1 (0.7%) 0 \n 2 0 1 (0.7%) 0 \n 3 0 0 1 (0.8%) \nC-Reactive Protein Measurement \n Not Low 119 113 112 \n Not Low 41 (30.6%) 42 (31.3%) 50 (37.9%) \n 1 20 (14.9%) 18 (13.4%) 11 (8.3%) \n 2 24 (17.9%) 20 (14.9%) 14 (10.6%) \n 3 25 (18.7%) 18 (13.4%) 21 (15.9%) \n 4 9 (6.7%) 15 (11.2%) 16 (12.1%) \n 1 3 5 9 \n Not Low 2 (1.5%) 2 (1.5%) 2 (1.5%) \n 2 0 1 (0.7%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 0 1 (0.7%) 4 (3.0%) \n 2 5 9 2 \n Not Low 3 (2.2%) 4 (3.0%) 1 (0.8%) \n 1 1 (0.7%) 4 (3.0%) 0 \n 3 0 1 (0.7%) 1 (0.8%) \n 4 1 (0.7%) 0 0 \n 3 4 5 7 \n Not Low 1 (0.7%) 4 (3.0%) 2 (1.5%) \n 1 0 0 1 (0.8%) \n 2 0 0 1 (0.8%) \n 3 3 (2.2%) 1 (0.7%) 2 (1.5%) \n 4 0 0 1 (0.8%) \n 4 3 2 2 \n Not Low 3 (2.2%) 1 (0.7%) 0 \n 2 0 1 (0.7%) 0 \n 3 0 0 1 (0.8%) \n 4 0 0 1 (0.8%) \nImmunoglobulin A Measurement \n Not Low 134 134 132 \n Not Low 134 (100%) 134 (100%) 132 (100%) \n\n\n\n\nNote that missing baseline values are filtered out in the pre-processing step.\n\nCodeadlb_f <- adlb %>% filter(WGRHIFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRHIFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n filter(BTOXGR != \"<Missing>\") %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not High 134 134 132 \n Not High 134 (100%) 134 (100%) 132 (100%) \nC-Reactive Protein Measurement \n Not High 114 112 115 \n Not High 45 (33.6%) 55 (41.0%) 57 (43.2%) \n 1 18 (13.4%) 18 (13.4%) 19 (14.4%) \n 2 19 (14.2%) 10 (7.5%) 11 (8.3%) \n 3 22 (16.4%) 13 (9.7%) 20 (15.2%) \n 4 10 (7.5%) 16 (11.9%) 8 (6.1%) \n 1 8 10 7 \n Not High 5 (3.7%) 2 (1.5%) 2 (1.5%) \n 1 0 1 (0.7%) 0 \n 2 1 (0.7%) 3 (2.2%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 3 (2.2%) 2 (1.5%) \n 2 2 6 7 \n Not High 1 (0.7%) 4 (3.0%) 4 (3.0%) \n 1 0 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 4 0 0 1 (0.8%) \n 3 7 4 3 \n Not High 3 (2.2%) 0 2 (1.5%) \n 1 2 (1.5%) 1 (0.7%) 1 (0.8%) \n 2 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n 4 3 2 0 \n Not High 1 (0.7%) 0 0 \n 1 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 0 0 \nImmunoglobulin A Measurement \n Not High 119 116 113 \n Not High 55 (41.0%) 54 (40.3%) 51 (38.6%) \n 1 18 (13.4%) 11 (8.2%) 15 (11.4%) \n 2 14 (10.4%) 22 (16.4%) 19 (14.4%) \n 3 20 (14.9%) 19 (14.2%) 20 (15.2%) \n 4 12 (9.0%) 10 (7.5%) 8 (6.1%) \n 1 5 4 2 \n Not High 4 (3.0%) 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 2 (1.5%) 0 \n 2 4 4 5 \n Not High 2 (1.5%) 3 (2.2%) 3 (2.3%) \n 1 1 (0.7%) 0 2 (1.5%) \n 3 1 (0.7%) 0 0 \n 4 0 1 (0.7%) 0 \n 3 4 5 11 \n Not High 3 (2.2%) 1 (0.7%) 6 (4.5%) \n 1 0 1 (0.7%) 1 (0.8%) \n 2 1 (0.7%) 0 0 \n 3 0 2 (1.5%) 3 (2.3%) \n 4 0 1 (0.7%) 1 (0.8%) \n 4 2 5 1 \n Not High 0 3 (2.2%) 1 (0.8%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n\n\n\n\nNote that when BTOXGR is missing, the grouping variable BTOXGR_GP now is \"Not Low\" instead of \"Missing\" compared to Standard Table (Low).\n\nCodeadlb_f <- adlb %>% filter(WGRLOFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRLOFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n ATOXGR == -1 ~ \"1\",\n ATOXGR == -2 ~ \"2\",\n ATOXGR == -3 ~ \"3\",\n ATOXGR == -4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, 1, 2, 3, 4, \"<Missing>\") ~ \"Not Low\",\n BTOXGR == -1 ~ \"1\",\n BTOXGR == -2 ~ \"2\",\n BTOXGR == -3 ~ \"3\",\n BTOXGR == -4 ~ \"4\"\n ), levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not Low 113 117 123 \n Not Low 56 (41.8%) 55 (41.0%) 62 (47.0%) \n 1 11 (8.2%) 9 (6.7%) 15 (11.4%) \n 2 15 (11.2%) 23 (17.2%) 16 (12.1%) \n 3 15 (11.2%) 21 (15.7%) 13 (9.8%) \n 4 16 (11.9%) 9 (6.7%) 17 (12.9%) \n 1 6 6 4 \n Not Low 3 (2.2%) 5 (3.7%) 3 (2.3%) \n 1 3 (2.2%) 0 0 \n 4 0 1 (0.7%) 1 (0.8%) \n 2 8 5 1 \n Not Low 5 (3.7%) 3 (2.2%) 0 \n 1 0 1 (0.7%) 0 \n 2 2 (1.5%) 0 0 \n 3 0 1 (0.7%) 1 (0.8%) \n 4 1 (0.7%) 0 0 \n 3 3 3 2 \n Not Low 0 1 (0.7%) 0 \n 1 1 (0.7%) 0 0 \n 2 1 (0.7%) 0 1 (0.8%) \n 3 1 (0.7%) 2 (1.5%) 1 (0.8%) \n 4 4 3 2 \n Not Low 4 (3.0%) 1 (0.7%) 1 (0.8%) \n 1 0 1 (0.7%) 0 \n 2 0 1 (0.7%) 0 \n 3 0 0 1 (0.8%) \nC-Reactive Protein Measurement \n Not Low 119 113 112 \n Not Low 41 (30.6%) 42 (31.3%) 50 (37.9%) \n 1 20 (14.9%) 18 (13.4%) 11 (8.3%) \n 2 24 (17.9%) 20 (14.9%) 14 (10.6%) \n 3 25 (18.7%) 18 (13.4%) 21 (15.9%) \n 4 9 (6.7%) 15 (11.2%) 16 (12.1%) \n 1 3 5 9 \n Not Low 2 (1.5%) 2 (1.5%) 2 (1.5%) \n 2 0 1 (0.7%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 0 1 (0.7%) 4 (3.0%) \n 2 5 9 2 \n Not Low 3 (2.2%) 4 (3.0%) 1 (0.8%) \n 1 1 (0.7%) 4 (3.0%) 0 \n 3 0 1 (0.7%) 1 (0.8%) \n 4 1 (0.7%) 0 0 \n 3 4 5 7 \n Not Low 1 (0.7%) 4 (3.0%) 2 (1.5%) \n 1 0 0 1 (0.8%) \n 2 0 0 1 (0.8%) \n 3 3 (2.2%) 1 (0.7%) 2 (1.5%) \n 4 0 0 1 (0.8%) \n 4 3 2 2 \n Not Low 3 (2.2%) 1 (0.7%) 0 \n 2 0 1 (0.7%) 0 \n 3 0 0 1 (0.8%) \n 4 0 0 1 (0.8%) \nImmunoglobulin A Measurement \n Not Low 134 134 132 \n Not Low 134 (100%) 134 (100%) 132 (100%) \n\n\n\n\nPre-processing is the same as Standard Table (High), but in order to keep all levels, prune_table() is not applied.\n\nCodeadlb_f <- adlb %>% filter(WGRHIFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRHIFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not High 134 134 132 \n Not High 134 (100%) 134 (100%) 132 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 1 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 4 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \nC-Reactive Protein Measurement \n Not High 114 112 115 \n Not High 45 (33.6%) 55 (41.0%) 57 (43.2%) \n 1 18 (13.4%) 18 (13.4%) 19 (14.4%) \n 2 19 (14.2%) 10 (7.5%) 11 (8.3%) \n 3 22 (16.4%) 13 (9.7%) 20 (15.2%) \n 4 10 (7.5%) 16 (11.9%) 8 (6.1%) \n Missing 0 0 0 \n 1 8 10 7 \n Not High 5 (3.7%) 2 (1.5%) 2 (1.5%) \n 1 0 1 (0.7%) 0 \n 2 1 (0.7%) 3 (2.2%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 3 (2.2%) 2 (1.5%) \n Missing 0 0 0 \n 2 2 6 7 \n Not High 1 (0.7%) 4 (3.0%) 4 (3.0%) \n 1 0 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 0 0 \n 4 0 0 1 (0.8%) \n Missing 0 0 0 \n 3 7 4 3 \n Not High 3 (2.2%) 0 2 (1.5%) \n 1 2 (1.5%) 1 (0.7%) 1 (0.8%) \n 2 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n Missing 0 0 0 \n 4 3 2 0 \n Not High 1 (0.7%) 0 0 \n 1 0 1 (0.7%) 0 \n 2 0 0 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 0 0 \n Missing 0 0 0 \n Missing 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \nImmunoglobulin A Measurement \n Not High 119 116 113 \n Not High 55 (41.0%) 54 (40.3%) 51 (38.6%) \n 1 18 (13.4%) 11 (8.2%) 15 (11.4%) \n 2 14 (10.4%) 22 (16.4%) 19 (14.4%) \n 3 20 (14.9%) 19 (14.2%) 20 (15.2%) \n 4 12 (9.0%) 10 (7.5%) 8 (6.1%) \n Missing 0 0 0 \n 1 5 4 2 \n Not High 4 (3.0%) 1 (0.7%) 2 (1.5%) \n 1 0 0 0 \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 2 (1.5%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 4 4 5 \n Not High 2 (1.5%) 3 (2.2%) 3 (2.3%) \n 1 1 (0.7%) 0 2 (1.5%) \n 2 0 0 0 \n 3 1 (0.7%) 0 0 \n 4 0 1 (0.7%) 0 \n Missing 0 0 0 \n 3 4 5 11 \n Not High 3 (2.2%) 1 (0.7%) 6 (4.5%) \n 1 0 1 (0.7%) 1 (0.8%) \n 2 1 (0.7%) 0 0 \n 3 0 2 (1.5%) 3 (2.3%) \n 4 0 1 (0.7%) 1 (0.8%) \n Missing 0 0 0 \n 4 2 5 1 \n Not High 0 3 (2.2%) 1 (0.8%) \n 1 0 0 0 \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 0 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n Missing 0 0 0 \n Missing 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb,\n code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_shift_by_grade(\n label = \"Grade Laboratory Abnormality Table\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"ALT\"\n ),\n worst_flag_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"WGRLOVFL\", \"WGRLOFL\", \"WGRHIVFL\", \"WGRHIFL\")),\n selected = c(\"WGRHIFL\")\n ),\n worst_flag_indicator = choices_selected(\n value_choices(adlb, \"WGRLOVFL\"),\n selected = \"Y\", fixed = TRUE\n ),\n anl_toxgrade_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"ATOXGR\")),\n selected = c(\"ATOXGR\"),\n fixed = TRUE\n ),\n base_toxgrade_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"BTOXGR\")),\n selected = c(\"BTOXGR\"),\n fixed = TRUE\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-08 19:29:59.0957 pid:2790 token:[] teal.modules.clinical Initializing tm_t_shift_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table (High)\nStandard Table (Low)\nTable Without Patients with Missing Baseline (High)\nTable with Missing Baseline Considered as Grade 0 (Low)\nTable with Fill-In of Grades\nteal App\nReproducibility\n\n\n\nPlease note that for each variant, the adlb dataset needs to be filtered on correct flags like WGRLOFL, WGRHIFL, et al., otherwise the layout function will not return the correct counts. There is an option to create a record for a lab test where no record is found at that visit. If you specified add_derived_type = \"PHANTOM\" & dtype_phantom_cond, you don’t have to use the h_adsl_adlb_merge_using_worst_flag function to preprocess your adlb dataset. Otherwise please follow the pre-processing steps below before applying the layout functions.\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\n# Please note that in real clinical data, population flag like SAFFL, and parameter category like PARCAT2 needs to be\n# selected properly.\nadsl_f <- adsl %>% filter(SAFFL == \"Y\")\nadlb <- adlb %>% filter(SAFFL == \"Y\")\n\n\n\n\nNote that the worst laboratory flag (below WGRHIFL) must be selected appropriately in the pre-processing step. New grouping variables ATOXGR_GP (post-baseline) and BTOXGR_GP (baseline) are created to display the correct output.\n\nCodeadlb_f <- adlb %>% filter(WGRHIFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRHIFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not High 134 134 132 \n Not High 134 (100%) 134 (100%) 132 (100%) \nC-Reactive Protein Measurement \n Not High 114 112 115 \n Not High 45 (33.6%) 55 (41.0%) 57 (43.2%) \n 1 18 (13.4%) 18 (13.4%) 19 (14.4%) \n 2 19 (14.2%) 10 (7.5%) 11 (8.3%) \n 3 22 (16.4%) 13 (9.7%) 20 (15.2%) \n 4 10 (7.5%) 16 (11.9%) 8 (6.1%) \n 1 8 10 7 \n Not High 5 (3.7%) 2 (1.5%) 2 (1.5%) \n 1 0 1 (0.7%) 0 \n 2 1 (0.7%) 3 (2.2%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 3 (2.2%) 2 (1.5%) \n 2 2 6 7 \n Not High 1 (0.7%) 4 (3.0%) 4 (3.0%) \n 1 0 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 4 0 0 1 (0.8%) \n 3 7 4 3 \n Not High 3 (2.2%) 0 2 (1.5%) \n 1 2 (1.5%) 1 (0.7%) 1 (0.8%) \n 2 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n 4 3 2 0 \n Not High 1 (0.7%) 0 0 \n 1 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 0 0 \nImmunoglobulin A Measurement \n Not High 119 116 113 \n Not High 55 (41.0%) 54 (40.3%) 51 (38.6%) \n 1 18 (13.4%) 11 (8.2%) 15 (11.4%) \n 2 14 (10.4%) 22 (16.4%) 19 (14.4%) \n 3 20 (14.9%) 19 (14.2%) 20 (15.2%) \n 4 12 (9.0%) 10 (7.5%) 8 (6.1%) \n 1 5 4 2 \n Not High 4 (3.0%) 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 2 (1.5%) 0 \n 2 4 4 5 \n Not High 2 (1.5%) 3 (2.2%) 3 (2.3%) \n 1 1 (0.7%) 0 2 (1.5%) \n 3 1 (0.7%) 0 0 \n 4 0 1 (0.7%) 0 \n 3 4 5 11 \n Not High 3 (2.2%) 1 (0.7%) 6 (4.5%) \n 1 0 1 (0.7%) 1 (0.8%) \n 2 1 (0.7%) 0 0 \n 3 0 2 (1.5%) 3 (2.3%) \n 4 0 1 (0.7%) 1 (0.8%) \n 4 2 5 1 \n Not High 0 3 (2.2%) 1 (0.8%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n\n\n\n\nNote that the worst laboratory flag (below WGRLOFL) must be selected appropriately in the pre-processing step. New grouping variables ATOXGR_GP (post-baseline) and BTOXGR_GP (baseline) are created to display the correct output.\n\nCodeadlb_f <- adlb %>% filter(WGRLOFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRLOFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n ATOXGR == -1 ~ \"1\",\n ATOXGR == -2 ~ \"2\",\n ATOXGR == -3 ~ \"3\",\n ATOXGR == -4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n BTOXGR == -1 ~ \"1\",\n BTOXGR == -2 ~ \"2\",\n BTOXGR == -3 ~ \"3\",\n BTOXGR == -4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not Low 113 117 123 \n Not Low 56 (41.8%) 55 (41.0%) 62 (47.0%) \n 1 11 (8.2%) 9 (6.7%) 15 (11.4%) \n 2 15 (11.2%) 23 (17.2%) 16 (12.1%) \n 3 15 (11.2%) 21 (15.7%) 13 (9.8%) \n 4 16 (11.9%) 9 (6.7%) 17 (12.9%) \n 1 6 6 4 \n Not Low 3 (2.2%) 5 (3.7%) 3 (2.3%) \n 1 3 (2.2%) 0 0 \n 4 0 1 (0.7%) 1 (0.8%) \n 2 8 5 1 \n Not Low 5 (3.7%) 3 (2.2%) 0 \n 1 0 1 (0.7%) 0 \n 2 2 (1.5%) 0 0 \n 3 0 1 (0.7%) 1 (0.8%) \n 4 1 (0.7%) 0 0 \n 3 3 3 2 \n Not Low 0 1 (0.7%) 0 \n 1 1 (0.7%) 0 0 \n 2 1 (0.7%) 0 1 (0.8%) \n 3 1 (0.7%) 2 (1.5%) 1 (0.8%) \n 4 4 3 2 \n Not Low 4 (3.0%) 1 (0.7%) 1 (0.8%) \n 1 0 1 (0.7%) 0 \n 2 0 1 (0.7%) 0 \n 3 0 0 1 (0.8%) \nC-Reactive Protein Measurement \n Not Low 119 113 112 \n Not Low 41 (30.6%) 42 (31.3%) 50 (37.9%) \n 1 20 (14.9%) 18 (13.4%) 11 (8.3%) \n 2 24 (17.9%) 20 (14.9%) 14 (10.6%) \n 3 25 (18.7%) 18 (13.4%) 21 (15.9%) \n 4 9 (6.7%) 15 (11.2%) 16 (12.1%) \n 1 3 5 9 \n Not Low 2 (1.5%) 2 (1.5%) 2 (1.5%) \n 2 0 1 (0.7%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 0 1 (0.7%) 4 (3.0%) \n 2 5 9 2 \n Not Low 3 (2.2%) 4 (3.0%) 1 (0.8%) \n 1 1 (0.7%) 4 (3.0%) 0 \n 3 0 1 (0.7%) 1 (0.8%) \n 4 1 (0.7%) 0 0 \n 3 4 5 7 \n Not Low 1 (0.7%) 4 (3.0%) 2 (1.5%) \n 1 0 0 1 (0.8%) \n 2 0 0 1 (0.8%) \n 3 3 (2.2%) 1 (0.7%) 2 (1.5%) \n 4 0 0 1 (0.8%) \n 4 3 2 2 \n Not Low 3 (2.2%) 1 (0.7%) 0 \n 2 0 1 (0.7%) 0 \n 3 0 0 1 (0.8%) \n 4 0 0 1 (0.8%) \nImmunoglobulin A Measurement \n Not Low 134 134 132 \n Not Low 134 (100%) 134 (100%) 132 (100%) \n\n\n\n\nNote that missing baseline values are filtered out in the pre-processing step.\n\nCodeadlb_f <- adlb %>% filter(WGRHIFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRHIFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n filter(BTOXGR != \"<Missing>\") %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not High 134 134 132 \n Not High 134 (100%) 134 (100%) 132 (100%) \nC-Reactive Protein Measurement \n Not High 114 112 115 \n Not High 45 (33.6%) 55 (41.0%) 57 (43.2%) \n 1 18 (13.4%) 18 (13.4%) 19 (14.4%) \n 2 19 (14.2%) 10 (7.5%) 11 (8.3%) \n 3 22 (16.4%) 13 (9.7%) 20 (15.2%) \n 4 10 (7.5%) 16 (11.9%) 8 (6.1%) \n 1 8 10 7 \n Not High 5 (3.7%) 2 (1.5%) 2 (1.5%) \n 1 0 1 (0.7%) 0 \n 2 1 (0.7%) 3 (2.2%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 3 (2.2%) 2 (1.5%) \n 2 2 6 7 \n Not High 1 (0.7%) 4 (3.0%) 4 (3.0%) \n 1 0 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 4 0 0 1 (0.8%) \n 3 7 4 3 \n Not High 3 (2.2%) 0 2 (1.5%) \n 1 2 (1.5%) 1 (0.7%) 1 (0.8%) \n 2 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n 4 3 2 0 \n Not High 1 (0.7%) 0 0 \n 1 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 0 0 \nImmunoglobulin A Measurement \n Not High 119 116 113 \n Not High 55 (41.0%) 54 (40.3%) 51 (38.6%) \n 1 18 (13.4%) 11 (8.2%) 15 (11.4%) \n 2 14 (10.4%) 22 (16.4%) 19 (14.4%) \n 3 20 (14.9%) 19 (14.2%) 20 (15.2%) \n 4 12 (9.0%) 10 (7.5%) 8 (6.1%) \n 1 5 4 2 \n Not High 4 (3.0%) 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 2 (1.5%) 0 \n 2 4 4 5 \n Not High 2 (1.5%) 3 (2.2%) 3 (2.3%) \n 1 1 (0.7%) 0 2 (1.5%) \n 3 1 (0.7%) 0 0 \n 4 0 1 (0.7%) 0 \n 3 4 5 11 \n Not High 3 (2.2%) 1 (0.7%) 6 (4.5%) \n 1 0 1 (0.7%) 1 (0.8%) \n 2 1 (0.7%) 0 0 \n 3 0 2 (1.5%) 3 (2.3%) \n 4 0 1 (0.7%) 1 (0.8%) \n 4 2 5 1 \n Not High 0 3 (2.2%) 1 (0.8%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n\n\n\n\nNote that when BTOXGR is missing, the grouping variable BTOXGR_GP now is \"Not Low\" instead of \"Missing\" compared to Standard Table (Low).\n\nCodeadlb_f <- adlb %>% filter(WGRLOFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRLOFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n ATOXGR == -1 ~ \"1\",\n ATOXGR == -2 ~ \"2\",\n ATOXGR == -3 ~ \"3\",\n ATOXGR == -4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, 1, 2, 3, 4, \"<Missing>\") ~ \"Not Low\",\n BTOXGR == -1 ~ \"1\",\n BTOXGR == -2 ~ \"2\",\n BTOXGR == -3 ~ \"3\",\n BTOXGR == -4 ~ \"4\"\n ), levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not Low 113 117 123 \n Not Low 56 (41.8%) 55 (41.0%) 62 (47.0%) \n 1 11 (8.2%) 9 (6.7%) 15 (11.4%) \n 2 15 (11.2%) 23 (17.2%) 16 (12.1%) \n 3 15 (11.2%) 21 (15.7%) 13 (9.8%) \n 4 16 (11.9%) 9 (6.7%) 17 (12.9%) \n 1 6 6 4 \n Not Low 3 (2.2%) 5 (3.7%) 3 (2.3%) \n 1 3 (2.2%) 0 0 \n 4 0 1 (0.7%) 1 (0.8%) \n 2 8 5 1 \n Not Low 5 (3.7%) 3 (2.2%) 0 \n 1 0 1 (0.7%) 0 \n 2 2 (1.5%) 0 0 \n 3 0 1 (0.7%) 1 (0.8%) \n 4 1 (0.7%) 0 0 \n 3 3 3 2 \n Not Low 0 1 (0.7%) 0 \n 1 1 (0.7%) 0 0 \n 2 1 (0.7%) 0 1 (0.8%) \n 3 1 (0.7%) 2 (1.5%) 1 (0.8%) \n 4 4 3 2 \n Not Low 4 (3.0%) 1 (0.7%) 1 (0.8%) \n 1 0 1 (0.7%) 0 \n 2 0 1 (0.7%) 0 \n 3 0 0 1 (0.8%) \nC-Reactive Protein Measurement \n Not Low 119 113 112 \n Not Low 41 (30.6%) 42 (31.3%) 50 (37.9%) \n 1 20 (14.9%) 18 (13.4%) 11 (8.3%) \n 2 24 (17.9%) 20 (14.9%) 14 (10.6%) \n 3 25 (18.7%) 18 (13.4%) 21 (15.9%) \n 4 9 (6.7%) 15 (11.2%) 16 (12.1%) \n 1 3 5 9 \n Not Low 2 (1.5%) 2 (1.5%) 2 (1.5%) \n 2 0 1 (0.7%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 0 1 (0.7%) 4 (3.0%) \n 2 5 9 2 \n Not Low 3 (2.2%) 4 (3.0%) 1 (0.8%) \n 1 1 (0.7%) 4 (3.0%) 0 \n 3 0 1 (0.7%) 1 (0.8%) \n 4 1 (0.7%) 0 0 \n 3 4 5 7 \n Not Low 1 (0.7%) 4 (3.0%) 2 (1.5%) \n 1 0 0 1 (0.8%) \n 2 0 0 1 (0.8%) \n 3 3 (2.2%) 1 (0.7%) 2 (1.5%) \n 4 0 0 1 (0.8%) \n 4 3 2 2 \n Not Low 3 (2.2%) 1 (0.7%) 0 \n 2 0 1 (0.7%) 0 \n 3 0 0 1 (0.8%) \n 4 0 0 1 (0.8%) \nImmunoglobulin A Measurement \n Not Low 134 134 132 \n Not Low 134 (100%) 134 (100%) 132 (100%) \n\n\n\n\nPre-processing is the same as Standard Table (High), but in order to keep all levels, prune_table() is not applied.\n\nCodeadlb_f <- adlb %>% filter(WGRHIFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- h_adsl_adlb_merge_using_worst_flag(adsl_f, adlb_f, worst_flag = c(\"WGRHIFL\" = \"Y\"))\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = factor(case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n ) %>%\n mutate(\n BTOXGR_GP = factor(case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n ), levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = \"Parameter\"\n ) %>%\n split_rows_by(\n \"BTOXGR_GP\",\n label_pos = \"topleft\",\n split_label = \" Baseline NCI-CTCAE Grade\",\n indent_mod = 2L\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\"), unique_count_suffix = FALSE) %>%\n count_occurrences_by_grade(\"ATOXGR_GP\", denom = \"n\", drop = FALSE, .indent_mods = 3L) %>%\n append_topleft(\" Post-baseline NCI-CTCAE Grade\") %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter \n Baseline NCI-CTCAE Grade A: Drug X B: Placebo C: Combination\n Post-baseline NCI-CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Not High 134 134 132 \n Not High 134 (100%) 134 (100%) 132 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 1 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 4 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \nC-Reactive Protein Measurement \n Not High 114 112 115 \n Not High 45 (33.6%) 55 (41.0%) 57 (43.2%) \n 1 18 (13.4%) 18 (13.4%) 19 (14.4%) \n 2 19 (14.2%) 10 (7.5%) 11 (8.3%) \n 3 22 (16.4%) 13 (9.7%) 20 (15.2%) \n 4 10 (7.5%) 16 (11.9%) 8 (6.1%) \n Missing 0 0 0 \n 1 8 10 7 \n Not High 5 (3.7%) 2 (1.5%) 2 (1.5%) \n 1 0 1 (0.7%) 0 \n 2 1 (0.7%) 3 (2.2%) 3 (2.3%) \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 3 (2.2%) 2 (1.5%) \n Missing 0 0 0 \n 2 2 6 7 \n Not High 1 (0.7%) 4 (3.0%) 4 (3.0%) \n 1 0 1 (0.7%) 2 (1.5%) \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 0 0 \n 4 0 0 1 (0.8%) \n Missing 0 0 0 \n 3 7 4 3 \n Not High 3 (2.2%) 0 2 (1.5%) \n 1 2 (1.5%) 1 (0.7%) 1 (0.8%) \n 2 0 1 (0.7%) 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n Missing 0 0 0 \n 4 3 2 0 \n Not High 1 (0.7%) 0 0 \n 1 0 1 (0.7%) 0 \n 2 0 0 0 \n 3 1 (0.7%) 1 (0.7%) 0 \n 4 1 (0.7%) 0 0 \n Missing 0 0 0 \n Missing 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \nImmunoglobulin A Measurement \n Not High 119 116 113 \n Not High 55 (41.0%) 54 (40.3%) 51 (38.6%) \n 1 18 (13.4%) 11 (8.2%) 15 (11.4%) \n 2 14 (10.4%) 22 (16.4%) 19 (14.4%) \n 3 20 (14.9%) 19 (14.2%) 20 (15.2%) \n 4 12 (9.0%) 10 (7.5%) 8 (6.1%) \n Missing 0 0 0 \n 1 5 4 2 \n Not High 4 (3.0%) 1 (0.7%) 2 (1.5%) \n 1 0 0 0 \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 2 (1.5%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 4 4 5 \n Not High 2 (1.5%) 3 (2.2%) 3 (2.3%) \n 1 1 (0.7%) 0 2 (1.5%) \n 2 0 0 0 \n 3 1 (0.7%) 0 0 \n 4 0 1 (0.7%) 0 \n Missing 0 0 0 \n 3 4 5 11 \n Not High 3 (2.2%) 1 (0.7%) 6 (4.5%) \n 1 0 1 (0.7%) 1 (0.8%) \n 2 1 (0.7%) 0 0 \n 3 0 2 (1.5%) 3 (2.3%) \n 4 0 1 (0.7%) 1 (0.8%) \n Missing 0 0 0 \n 4 2 5 1 \n Not High 0 3 (2.2%) 1 (0.8%) \n 1 0 0 0 \n 2 1 (0.7%) 1 (0.7%) 0 \n 3 0 0 0 \n 4 1 (0.7%) 1 (0.7%) 0 \n Missing 0 0 0 \n Missing 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb,\n code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_shift_by_grade(\n label = \"Grade Laboratory Abnormality Table\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"ALT\"\n ),\n worst_flag_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"WGRLOVFL\", \"WGRLOFL\", \"WGRHIVFL\", \"WGRHIFL\")),\n selected = c(\"WGRHIFL\")\n ),\n worst_flag_indicator = choices_selected(\n value_choices(adlb, \"WGRLOVFL\"),\n selected = \"Y\", fixed = TRUE\n ),\n anl_toxgrade_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"ATOXGR\")),\n selected = c(\"ATOXGR\"),\n fixed = TRUE\n ),\n base_toxgrade_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"BTOXGR\")),\n selected = c(\"BTOXGR\"),\n fixed = TRUE\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-09 17:46:02.5976 pid:2795 token:[] teal.modules.clinical Initializing tm_t_shift_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt11.html",
"href": "tables/lab-results/lbt11.html",
"title": "LBT11",
"section": "",
- "text": "Data Setup\nTime-To-Event Summary\nTime-To-Event Summary Selecting Sections to Display\nTime-To-Event Summary with Stratified Analysis\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsaftte <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadsaftte <- df_explicit_na(adsaftte)\n\nadsl_safl <- dplyr::filter(adsl, .data$SAFFL == \"Y\")\n\nanl <- adsaftte %>%\n dplyr::filter(\n SAFFL == \"Y\",\n PARAMCD == \"HYSTTEUL\"\n ) %>%\n dplyr::mutate(\n AVAL = .data$AVAL * dplyr::case_when( # convert to days, if possible\n .data$AVALU == \"WEEKS\" ~ 7,\n .data$AVALU == \"MONTHS\" ~ 30.4375,\n .data$AVALU == \"YEARS\" ~ 365,\n TRUE ~ 1\n ),\n AVALU = factor(dplyr::case_when(\n .data$AVALU %in% c(\"WEEKS\", \"MONTHS\", \"YEARS\") ~ factor(\"DAYS\"),\n TRUE ~ .data$AVALU\n ), levels = \"DAYS\"),\n is_event = CNSR == 0, # this will be a LLT event\n event_grp = factor(\n dplyr::case_when(\n CNSR == 0 ~ \"Patients with LLT event (%)\",\n CNSR == 1 ~ \"Patients without LLT event (%)\"\n ),\n levels = c(\n \"Patients with LLT event (%)\",\n \"Patients without LLT event (%)\"\n )\n )\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 20 (14.9%) 9 (6.7%) 9 (6.8%) \nPatients without LLT event (%) 114 (85.1%) 125 (93.3%) 123 (93.2%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 728.0 \n 95% CI NA (724.0, NA) NA \n 25% and 75%-ile 618.0, NA 724.0, NA 728.0, 728.0 \n Range (censored) 1.0 to 731.0 1.0 to 728.0 1.0 to 722.0 \n Range (event) 34.0 to 666.0 139.0 to 724.0 10.0 to 728.0\nUnstratified Analysis \n p-value (log-rank) 0.0295 0.1687 \n Hazard Ratio 0.43 0.58 \n 95% CI (0.19, 0.94) (0.26, 1.27) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 20 (14.9%) 9 (6.7%) 9 (6.8%) \nPatients without LLT event (%) 114 (85.1%) 125 (93.3%) 123 (93.2%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 728.0 \n 95% CI NA (724.0, NA) NA \n 25% and 75%-ile 618.0, NA 724.0, NA 728.0, 728.0 \n Range (censored) 1.0 to 731.0 1.0 to 728.0 1.0 to 722.0 \n Range (event) 34.0 to 666.0 139.0 to 724.0 10.0 to 728.0\n\n\n\n\n\nCodestrata <- c(\"RACE\", \"SEX\")\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = paste0(\"Stratified By: \", paste(strata, collapse = \", \")),\n strat = strata,\n table_names = \"coxph_stratified\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 20 (14.9%) 9 (6.7%) 9 (6.8%) \nPatients without LLT event (%) 114 (85.1%) 125 (93.3%) 123 (93.2%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 728.0 \n 95% CI NA (724.0, NA) NA \n 25% and 75%-ile 618.0, NA 724.0, NA 728.0, 728.0 \n Range (censored) 1.0 to 731.0 1.0 to 728.0 1.0 to 722.0 \n Range (event) 34.0 to 666.0 139.0 to 724.0 10.0 to 728.0\nUnstratified Analysis \n p-value (log-rank) 0.0295 0.1687 \n Hazard Ratio 0.43 0.58 \n 95% CI (0.19, 0.94) (0.26, 1.27) \nStratified By: RACE, SEX \n p-value (log-rank) 0.0858 0.1605 \n Hazard Ratio 0.51 0.57 \n 95% CI (0.23, 1.12) (0.26, 1.26) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsaftte <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadsaftte <- df_explicit_na(adsaftte)\n\nadsl <- dplyr::filter(adsl, .data$SAFFL == \"Y\")\nadsaftte <- dplyr::filter(adsaftte, .data$SAFFL == \"Y\")\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% df_explicit_na() %>% dplyr::filter(.data$SAFFL == \"Y\")'\n ),\n cdisc_dataset(\n \"ADSAFTTE\",\n adsaftte,\n keys = c(\"STUDYID\", \"USUBJID\", \"PARAMCD\"),\n code = 'ADSAFTTE <- synthetic_cdisc_dataset(\"latest\", \"adaette\") %>% df_explicit_na() %>% dplyr::filter(.data$SAFFL == \"Y\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_tte(\n label = \"Time To LLT Event Table\",\n dataname = \"ADSAFTTE\",\n arm_var = choices_selected(\n variable_choices(adsl, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adsaftte, \"PARAMCD\", \"PARAM\"),\n \"HYSTTEUL\"\n ),\n strata_var = choices_selected(\n variable_choices(adsl, c(\"RACE\", \"SEX\")),\n c(\"RACE\", \"SEX\")\n ),\n time_points = choices_selected(0, NULL),\n event_desc_var = choices_selected(\"EVNTDESC\", \"EVNTDESC\", fixed = TRUE)\n )\n )\n)\n\n[INFO] 2023-09-08 19:28:42.1556 pid:2594 token:[] teal.modules.clinical Initializing tm_t_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nTime-To-Event Summary\nTime-To-Event Summary Selecting Sections to Display\nTime-To-Event Summary with Stratified Analysis\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsaftte <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadsaftte <- df_explicit_na(adsaftte)\n\nadsl_safl <- dplyr::filter(adsl, .data$SAFFL == \"Y\")\n\nanl <- adsaftte %>%\n dplyr::filter(\n SAFFL == \"Y\",\n PARAMCD == \"HYSTTEUL\"\n ) %>%\n dplyr::mutate(\n AVAL = .data$AVAL * dplyr::case_when( # convert to days, if possible\n .data$AVALU == \"WEEKS\" ~ 7,\n .data$AVALU == \"MONTHS\" ~ 30.4375,\n .data$AVALU == \"YEARS\" ~ 365,\n TRUE ~ 1\n ),\n AVALU = factor(dplyr::case_when(\n .data$AVALU %in% c(\"WEEKS\", \"MONTHS\", \"YEARS\") ~ factor(\"DAYS\"),\n TRUE ~ .data$AVALU\n ), levels = \"DAYS\"),\n is_event = CNSR == 0, # this will be a LLT event\n event_grp = factor(\n dplyr::case_when(\n CNSR == 0 ~ \"Patients with LLT event (%)\",\n CNSR == 1 ~ \"Patients without LLT event (%)\"\n ),\n levels = c(\n \"Patients with LLT event (%)\",\n \"Patients without LLT event (%)\"\n )\n )\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 20 (14.9%) 9 (6.7%) 9 (6.8%) \nPatients without LLT event (%) 114 (85.1%) 125 (93.3%) 123 (93.2%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 728.0 \n 95% CI NA (724.0, NA) NA \n 25% and 75%-ile 618.0, NA 724.0, NA 728.0, 728.0 \n Range (censored) 1.0 to 731.0 1.0 to 728.0 1.0 to 722.0 \n Range (event) 34.0 to 666.0 139.0 to 724.0 10.0 to 728.0\nUnstratified Analysis \n p-value (log-rank) 0.0295 0.1687 \n Hazard Ratio 0.43 0.58 \n 95% CI (0.19, 0.94) (0.26, 1.27) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 20 (14.9%) 9 (6.7%) 9 (6.8%) \nPatients without LLT event (%) 114 (85.1%) 125 (93.3%) 123 (93.2%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 728.0 \n 95% CI NA (724.0, NA) NA \n 25% and 75%-ile 618.0, NA 724.0, NA 728.0, 728.0 \n Range (censored) 1.0 to 731.0 1.0 to 728.0 1.0 to 722.0 \n Range (event) 34.0 to 666.0 139.0 to 724.0 10.0 to 728.0\n\n\n\n\n\nCodestrata <- c(\"RACE\", \"SEX\")\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = paste0(\"Stratified By: \", paste(strata, collapse = \", \")),\n strat = strata,\n table_names = \"coxph_stratified\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 20 (14.9%) 9 (6.7%) 9 (6.8%) \nPatients without LLT event (%) 114 (85.1%) 125 (93.3%) 123 (93.2%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 728.0 \n 95% CI NA (724.0, NA) NA \n 25% and 75%-ile 618.0, NA 724.0, NA 728.0, 728.0 \n Range (censored) 1.0 to 731.0 1.0 to 728.0 1.0 to 722.0 \n Range (event) 34.0 to 666.0 139.0 to 724.0 10.0 to 728.0\nUnstratified Analysis \n p-value (log-rank) 0.0295 0.1687 \n Hazard Ratio 0.43 0.58 \n 95% CI (0.19, 0.94) (0.26, 1.27) \nStratified By: RACE, SEX \n p-value (log-rank) 0.0858 0.1605 \n Hazard Ratio 0.51 0.57 \n 95% CI (0.23, 1.12) (0.26, 1.26) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsaftte <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadsaftte <- df_explicit_na(adsaftte)\n\nadsl <- dplyr::filter(adsl, .data$SAFFL == \"Y\")\nadsaftte <- dplyr::filter(adsaftte, .data$SAFFL == \"Y\")\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% df_explicit_na() %>% dplyr::filter(.data$SAFFL == \"Y\")'\n ),\n cdisc_dataset(\n \"ADSAFTTE\",\n adsaftte,\n keys = c(\"STUDYID\", \"USUBJID\", \"PARAMCD\"),\n code = 'ADSAFTTE <- synthetic_cdisc_dataset(\"latest\", \"adaette\") %>% df_explicit_na() %>% dplyr::filter(.data$SAFFL == \"Y\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_tte(\n label = \"Time To LLT Event Table\",\n dataname = \"ADSAFTTE\",\n arm_var = choices_selected(\n variable_choices(adsl, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adsaftte, \"PARAMCD\", \"PARAM\"),\n \"HYSTTEUL\"\n ),\n strata_var = choices_selected(\n variable_choices(adsl, c(\"RACE\", \"SEX\")),\n c(\"RACE\", \"SEX\")\n ),\n time_points = choices_selected(0, NULL),\n event_desc_var = choices_selected(\"EVNTDESC\", \"EVNTDESC\", fixed = TRUE)\n )\n )\n)\n\n[INFO] 2023-09-09 17:44:29.6924 pid:2599 token:[] teal.modules.clinical Initializing tm_t_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt08.html",
@@ -452,7 +452,7 @@
"href": "tables/lab-results/lbt15.html",
"title": "LBT15",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Modifying Cut Point\nteal App\nReproducibility\n\n\n\nBecause the scda dataset adlb doesn’t have the PARCAT1 variable, this variable is created from LBCAT in pre-processing.\nadlb <- adlb %>%\nmutate(\nPARAM = with_label(.data$PARAM, “Laboratory Test”),\nANRIND = with_label(.data$ANRIND, “Direction of Abnormality”)\n)\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\nlibrary(forcats)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadlb <- adlb %>%\n mutate(\n PARAM = with_label(.data$PARAM, \"Laboratory Test\"),\n ANRIND = with_label(.data$ANRIND, \"Direction of Abnormality\")\n ) %>%\n mutate(\n PARCAT1 = LBCAT\n ) %>%\n mutate(\n ANRIND = fct_collapse(.data$ATOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n ),\n BNRIND = fct_collapse(.data$BTOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n ),\n PARCAT1 = LBCAT\n ) %>%\n filter(ONTRTFL == \"Y\")\n\n\nadlb_alt_cut <- adlb %>%\n mutate(\n ANRIND = fct_collapse(.data$ATOXGR,\n \"LOW\" = c(\"-2\", \"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-1\", \"0\", \"1\"),\n \"HIGH\" = c(\"2\", \"3\", \"4\")\n ),\n BNRIND = fct_collapse(.data$BTOXGR,\n \"LOW\" = c(\"-2\", \"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-1\", \"0\", \"1\"),\n \"HIGH\" = c(\"2\", \"3\", \"4\")\n )\n ) %>%\n filter(ONTRTFL == \"Y\")\n\nadlb <- adlb %>% var_relabel(\n PARCAT1 = \"Category for Lab Test\",\n PARAM = \"Parameter\"\n)\n\n\n\n\n\nCode# Argument exclude_base_abn must be TRUE to include patients with normal or abnormal in the opposite direction in the denom\n# So for \"High\" direction, subjects with baseline grade 3-4 are not in the denom.\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\"PARCAT1\", split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb$PARCAT1)) %>%\n split_rows_by(\"PARAM\", split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb$PARAM)) %>%\n count_abnormal(\n var = \"ANRIND\",\n abnormal = list(Low = \"LOW\", High = \"HIGH\"),\n variables = list(id = \"USUBJID\", baseline = \"BNRIND\"),\n exclude_base_abn = TRUE,\n .indent_mods = 4L\n ) %>%\n append_topleft(\" Direction of Abnormality\")\n\nresult <- build_table(lyt, adlb, alt_counts_df = adsl)\nresult\n\nCategory for Lab Test \n Parameter A: Drug X B: Placebo C: Combination All Patients \n Direction of Abnormality (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————\nCHEMISTRY \n Alanine Aminotransferase Measurement \n Low 32/127 (25.2%) 32/128 (25%) 32/128 (25%) 96/383 (25.1%) \n High 0/134 0/134 0/132 0/400 \n C-Reactive Protein Measurement \n Low 36/127 (28.3%) 36/127 (28.3%) 42/123 (34.1%) 114/377 (30.2%)\n High 34/124 (27.4%) 33/128 (25.8%) 31/129 (24%) 98/381 (25.7%) \nIMMUNOLOGY \n Immunoglobulin A Measurement \n Low 0/134 0/134 0/132 0/400 \n High 33/128 (25.8%) 32/124 (25.8%) 28/120 (23.3%) 93/372 (25%) \n\n\n\n\n\nCoderesult <- build_table(lyt, adlb_alt_cut, alt_counts_df = adsl)\nresult\n\nCategory for Lab Test \n Parameter A: Drug X B: Placebo C: Combination All Patients \n Direction of Abnormality (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————\nCHEMISTRY \n Alanine Aminotransferase Measurement \n Low 46/119 (38.7%) 54/123 (43.9%) 47/127 (37%) 147/369 (39.8%)\n High 0/134 0/134 0/132 0/400 \n C-Reactive Protein Measurement \n Low 59/122 (48.4%) 56/118 (47.5%) 58/121 (47.9%) 173/361 (47.9%)\n High 54/122 (44.3%) 46/122 (37.7%) 44/122 (36.1%) 144/366 (39.3%)\nIMMUNOLOGY \n Immunoglobulin A Measurement \n Low 0/134 0/134 0/132 0/400 \n High 47/124 (37.9%) 54/120 (45%) 47/115 (40.9%) 148/359 (41.2%)\n\n\n\n\nThe current module tm_t_abnormality is only displaying rows that are not all-zero, so the result could be a little different from static output where all-zero rows can be shown.\n\nCodelibrary(teal.modules.clinical)\nlibrary(forcats)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n mutate(\n ANRIND = fct_collapse(ATOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n ),\n BNRIND = fct_collapse(.data$BTOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n )\n ) %>%\n filter(ONTRTFL == \"Y\") %>%\n var_relabel(ANRIND = \"Direction of Abnormality\")\n\n\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb, code = '\n ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n mutate(\n ANRIND = fct_collapse(ATOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n ),\n BNRIND = fct_collapse(BTOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n )\n ) %>%\n filter(ONTRTFL == \"Y\") %>%\n var_relabel(ANRIND = \"Direction of Abnormality\")\n '),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality(\n label = \"Abnormality Table\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, subset = c(\"PARAM\")),\n selected = c(\"PARAM\"),\n keep_order = TRUE\n ),\n grade = choices_selected(\n choices = variable_choices(adlb, subset = \"ANRIND\"),\n selected = \"ANRIND\",\n fixed = TRUE\n ),\n baseline_var = choices_selected(\n choices = variable_choices(adlb, subset = \"BNRIND\"),\n selected = \"BNRIND\",\n fixed = TRUE\n ),\n abnormal = list(Low = \"LOW\", High = \"HIGH\"),\n exclude_base_abn = TRUE\n )\n )\n)\n\n[INFO] 2023-09-08 19:27:25.9460 pid:2296 token:[] teal.modules.clinical Initializing tm_t_abnormality\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] forcats_1.0.0 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Modifying Cut Point\nteal App\nReproducibility\n\n\n\nBecause the scda dataset adlb doesn’t have the PARCAT1 variable, this variable is created from LBCAT in pre-processing.\nadlb <- adlb %>%\nmutate(\nPARAM = with_label(.data$PARAM, “Laboratory Test”),\nANRIND = with_label(.data$ANRIND, “Direction of Abnormality”)\n)\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\nlibrary(forcats)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadlb <- adlb %>%\n mutate(\n PARAM = with_label(.data$PARAM, \"Laboratory Test\"),\n ANRIND = with_label(.data$ANRIND, \"Direction of Abnormality\")\n ) %>%\n mutate(\n PARCAT1 = LBCAT\n ) %>%\n mutate(\n ANRIND = fct_collapse(.data$ATOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n ),\n BNRIND = fct_collapse(.data$BTOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n ),\n PARCAT1 = LBCAT\n ) %>%\n filter(ONTRTFL == \"Y\")\n\n\nadlb_alt_cut <- adlb %>%\n mutate(\n ANRIND = fct_collapse(.data$ATOXGR,\n \"LOW\" = c(\"-2\", \"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-1\", \"0\", \"1\"),\n \"HIGH\" = c(\"2\", \"3\", \"4\")\n ),\n BNRIND = fct_collapse(.data$BTOXGR,\n \"LOW\" = c(\"-2\", \"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-1\", \"0\", \"1\"),\n \"HIGH\" = c(\"2\", \"3\", \"4\")\n )\n ) %>%\n filter(ONTRTFL == \"Y\")\n\nadlb <- adlb %>% var_relabel(\n PARCAT1 = \"Category for Lab Test\",\n PARAM = \"Parameter\"\n)\n\n\n\n\n\nCode# Argument exclude_base_abn must be TRUE to include patients with normal or abnormal in the opposite direction in the denom\n# So for \"High\" direction, subjects with baseline grade 3-4 are not in the denom.\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\"PARCAT1\", split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb$PARCAT1)) %>%\n split_rows_by(\"PARAM\", split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb$PARAM)) %>%\n count_abnormal(\n var = \"ANRIND\",\n abnormal = list(Low = \"LOW\", High = \"HIGH\"),\n variables = list(id = \"USUBJID\", baseline = \"BNRIND\"),\n exclude_base_abn = TRUE,\n .indent_mods = 4L\n ) %>%\n append_topleft(\" Direction of Abnormality\")\n\nresult <- build_table(lyt, adlb, alt_counts_df = adsl)\nresult\n\nCategory for Lab Test \n Parameter A: Drug X B: Placebo C: Combination All Patients \n Direction of Abnormality (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————\nCHEMISTRY \n Alanine Aminotransferase Measurement \n Low 32/127 (25.2%) 32/128 (25%) 32/128 (25%) 96/383 (25.1%) \n High 0/134 0/134 0/132 0/400 \n C-Reactive Protein Measurement \n Low 36/127 (28.3%) 36/127 (28.3%) 42/123 (34.1%) 114/377 (30.2%)\n High 34/124 (27.4%) 33/128 (25.8%) 31/129 (24%) 98/381 (25.7%) \nIMMUNOLOGY \n Immunoglobulin A Measurement \n Low 0/134 0/134 0/132 0/400 \n High 33/128 (25.8%) 32/124 (25.8%) 28/120 (23.3%) 93/372 (25%) \n\n\n\n\n\nCoderesult <- build_table(lyt, adlb_alt_cut, alt_counts_df = adsl)\nresult\n\nCategory for Lab Test \n Parameter A: Drug X B: Placebo C: Combination All Patients \n Direction of Abnormality (N=134) (N=134) (N=132) (N=400) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————\nCHEMISTRY \n Alanine Aminotransferase Measurement \n Low 46/119 (38.7%) 54/123 (43.9%) 47/127 (37%) 147/369 (39.8%)\n High 0/134 0/134 0/132 0/400 \n C-Reactive Protein Measurement \n Low 59/122 (48.4%) 56/118 (47.5%) 58/121 (47.9%) 173/361 (47.9%)\n High 54/122 (44.3%) 46/122 (37.7%) 44/122 (36.1%) 144/366 (39.3%)\nIMMUNOLOGY \n Immunoglobulin A Measurement \n Low 0/134 0/134 0/132 0/400 \n High 47/124 (37.9%) 54/120 (45%) 47/115 (40.9%) 148/359 (41.2%)\n\n\n\n\nThe current module tm_t_abnormality is only displaying rows that are not all-zero, so the result could be a little different from static output where all-zero rows can be shown.\n\nCodelibrary(teal.modules.clinical)\nlibrary(forcats)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n mutate(\n ANRIND = fct_collapse(ATOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n ),\n BNRIND = fct_collapse(.data$BTOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n )\n ) %>%\n filter(ONTRTFL == \"Y\") %>%\n var_relabel(ANRIND = \"Direction of Abnormality\")\n\n\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb, code = '\n ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n mutate(\n ANRIND = fct_collapse(ATOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n ),\n BNRIND = fct_collapse(BTOXGR,\n \"LOW\" = c(\"-3\", \"-4\"),\n \"MODERATE/NORMAL\" = c(\"-2\", \"-1\", \"0\", \"1\", \"2\"),\n \"HIGH\" = c(\"3\", \"4\")\n )\n ) %>%\n filter(ONTRTFL == \"Y\") %>%\n var_relabel(ANRIND = \"Direction of Abnormality\")\n '),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality(\n label = \"Abnormality Table\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, subset = c(\"PARAM\")),\n selected = c(\"PARAM\"),\n keep_order = TRUE\n ),\n grade = choices_selected(\n choices = variable_choices(adlb, subset = \"ANRIND\"),\n selected = \"ANRIND\",\n fixed = TRUE\n ),\n baseline_var = choices_selected(\n choices = variable_choices(adlb, subset = \"BNRIND\"),\n selected = \"BNRIND\",\n fixed = TRUE\n ),\n abnormal = list(Low = \"LOW\", High = \"HIGH\"),\n exclude_base_abn = TRUE\n )\n )\n)\n\n[INFO] 2023-09-09 17:42:54.3430 pid:2300 token:[] teal.modules.clinical Initializing tm_t_abnormality\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] forcats_1.0.0 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt10_bl.html",
@@ -473,14 +473,14 @@
"href": "tables/lab-results/lbt01.html",
"title": "LBT01",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\nIn order to generate the LBT01 standard tabulation, the adlb dataset may be pre-processed so as to discriminate baseline from follow-up visits.\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb) %>%\n filter(ANL01FL == \"Y\")\n\n# For illustration purpose, the example focuses on \"Alanine Aminotransferase\n# Measurement\" starting from baseline, while excluding visit at week 1 for\n# subjects who were prescribed a placebo.\nadlb_f <- adlb %>%\n dplyr::filter(\n PARAM == \"Alanine Aminotransferase Measurement\" &\n !(ACTARM == \"B: Placebo\" & AVISIT == \"WEEK 1 DAY 8\") &\n AVISIT != \"SCREENING\"\n )\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nafun <- function(x, .var, .spl_context, ...) {\n n_fun <- sum(!is.na(x), na.rm = TRUE)\n if (n_fun == 0) {\n mean_sd_fun <- c(NA, NA)\n median_fun <- NA\n min_max_fun <- c(NA, NA)\n } else {\n mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))\n median_fun <- median(x, na.rm = TRUE)\n min_max_fun <- c(min(x), max(x))\n }\n is_chg <- .var == \"CHG\"\n is_baseline <- .spl_context$value[which(.spl_context$split == \"AVISIT\")] == \"BASELINE\"\n if (is_baseline && is_chg) n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL\n\n in_rows(\n \"n\" = n_fun,\n \"Mean (SD)\" = mean_sd_fun,\n \"Median\" = median_fun,\n \"Min - Max\" = min_max_fun,\n .formats = list(\"n\" = \"xx\", \"Mean (SD)\" = \"xx.xx (xx.xx)\", \"Median\" = \"xx.xx\", \"Min - Max\" = \"xx.xx - xx.xx\"),\n .format_na_strs = list(\"n\" = \"NE\", \"Mean (SD)\" = \"NE (NE)\", \"Median\" = \"NE\", \"Min - Max\" = \"NE - NE\")\n )\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adlb_f$PARAM)) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adlb_f$AVISIT)) %>%\n split_cols_by_multivar(\n vars = c(\"AVAL\", \"CHG\"),\n varlabels = c(\"Value at Visit\", \"Change from\\nBaseline\")\n ) %>%\n analyze_colvars(afun = afun)\n\nresult <- build_table(lyt, adlb_f)\nresult\n\nParameter A: Drug X B: Placebo C: Combination \n Analysis Visit Change from Change from Change from \n Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline \n (N=804) (N=804) (N=670) (N=670) (N=792) (N=792) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n BASELINE \n n 134 134 132 \n Mean (SD) 17.74 (9.93) 18.71 (9.83) 19.46 (9.08) \n Median 17.46 18.19 18.97 \n Min - Max 0.00 - 44.06 1.48 - 54.40 0.57 - 39.81 \n WEEK 1 DAY 8 \n n 134 134 0 0 132 132 \n Mean (SD) 16.75 (9.08) -0.99 (13.49) NE (NE) NE (NE) 19.61 (9.27) 0.14 (12.85) \n Median 16.02 -1.28 NE NE 19.00 0.06 \n Min - Max 0.05 - 36.30 -31.31 - 27.89 NE - NE NE - NE 0.91 - 44.75 -32.45 - 38.85\n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 17.82 (9.60) 0.08 (14.15) 18.82 (9.73) 0.11 (14.45) 16.55 (8.15) -2.92 (12.64) \n Median 15.92 0.28 17.96 -0.93 17.02 -1.11 \n Min - Max 0.40 - 44.33 -32.89 - 40.55 0.18 - 44.34 -45.93 - 29.85 0.35 - 34.69 -28.36 - 23.98\n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 18.37 (9.30) 0.63 (13.85) 17.65 (9.58) -1.06 (13.58) 16.75 (9.54) -2.71 (13.22) \n Median 18.11 1.13 17.68 -0.49 15.10 -2.66 \n Min - Max 0.59 - 41.73 -40.09 - 31.24 0.02 - 38.61 -46.30 - 31.38 0.48 - 39.23 -30.63 - 26.51\n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 19.17 (10.95) 1.44 (15.39) 17.22 (10.64) -1.48 (15.20) 17.92 (9.32) -1.54 (12.63) \n Median 17.41 0.88 15.88 -2.96 17.71 -1.53 \n Min - Max 0.93 - 54.24 -32.93 - 46.98 0.39 - 47.96 -41.45 - 43.08 0.25 - 41.27 -30.33 - 27.99\n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 19.22 (9.47) 1.48 (14.49) 18.01 (9.92) -0.69 (14.65) 18.51 (9.43) -0.95 (12.92) \n Median 19.80 2.31 18.28 1.82 19.26 -2.48 \n Min - Max 0.01 - 43.42 -40.08 - 30.07 0.11 - 40.64 -47.60 - 26.04 0.02 - 37.46 -29.78 - 25.00\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\"ADLB\",\n adlb,\n code = 'ADLB <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adlb\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Laboratory Test Results and Change from Baseline by Visit\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adlb, c(\"AVAL\", \"CHG\")),\n selected = c(\"AVAL\", \"CHG\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"ALT\"\n ),\n parallel_vars = TRUE\n )\n ),\n filter = list(ADLB = list(AVAL = list()))\n)\n\n[INFO] 2023-09-08 19:26:18.0262 pid:1943 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\nIn order to generate the LBT01 standard tabulation, the adlb dataset may be pre-processed so as to discriminate baseline from follow-up visits.\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb) %>%\n filter(ANL01FL == \"Y\")\n\n# For illustration purpose, the example focuses on \"Alanine Aminotransferase\n# Measurement\" starting from baseline, while excluding visit at week 1 for\n# subjects who were prescribed a placebo.\nadlb_f <- adlb %>%\n dplyr::filter(\n PARAM == \"Alanine Aminotransferase Measurement\" &\n !(ACTARM == \"B: Placebo\" & AVISIT == \"WEEK 1 DAY 8\") &\n AVISIT != \"SCREENING\"\n )\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nafun <- function(x, .var, .spl_context, ...) {\n n_fun <- sum(!is.na(x), na.rm = TRUE)\n if (n_fun == 0) {\n mean_sd_fun <- c(NA, NA)\n median_fun <- NA\n min_max_fun <- c(NA, NA)\n } else {\n mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))\n median_fun <- median(x, na.rm = TRUE)\n min_max_fun <- c(min(x), max(x))\n }\n is_chg <- .var == \"CHG\"\n is_baseline <- .spl_context$value[which(.spl_context$split == \"AVISIT\")] == \"BASELINE\"\n if (is_baseline && is_chg) n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL\n\n in_rows(\n \"n\" = n_fun,\n \"Mean (SD)\" = mean_sd_fun,\n \"Median\" = median_fun,\n \"Min - Max\" = min_max_fun,\n .formats = list(\"n\" = \"xx\", \"Mean (SD)\" = \"xx.xx (xx.xx)\", \"Median\" = \"xx.xx\", \"Min - Max\" = \"xx.xx - xx.xx\"),\n .format_na_strs = list(\"n\" = \"NE\", \"Mean (SD)\" = \"NE (NE)\", \"Median\" = \"NE\", \"Min - Max\" = \"NE - NE\")\n )\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adlb_f$PARAM)) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adlb_f$AVISIT)) %>%\n split_cols_by_multivar(\n vars = c(\"AVAL\", \"CHG\"),\n varlabels = c(\"Value at Visit\", \"Change from\\nBaseline\")\n ) %>%\n analyze_colvars(afun = afun)\n\nresult <- build_table(lyt, adlb_f)\nresult\n\nParameter A: Drug X B: Placebo C: Combination \n Analysis Visit Change from Change from Change from \n Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline \n (N=804) (N=804) (N=670) (N=670) (N=792) (N=792) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n BASELINE \n n 134 134 132 \n Mean (SD) 17.74 (9.93) 18.71 (9.83) 19.46 (9.08) \n Median 17.46 18.19 18.97 \n Min - Max 0.00 - 44.06 1.48 - 54.40 0.57 - 39.81 \n WEEK 1 DAY 8 \n n 134 134 0 0 132 132 \n Mean (SD) 16.75 (9.08) -0.99 (13.49) NE (NE) NE (NE) 19.61 (9.27) 0.14 (12.85) \n Median 16.02 -1.28 NE NE 19.00 0.06 \n Min - Max 0.05 - 36.30 -31.31 - 27.89 NE - NE NE - NE 0.91 - 44.75 -32.45 - 38.85\n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 17.82 (9.60) 0.08 (14.15) 18.82 (9.73) 0.11 (14.45) 16.55 (8.15) -2.92 (12.64) \n Median 15.92 0.28 17.96 -0.93 17.02 -1.11 \n Min - Max 0.40 - 44.33 -32.89 - 40.55 0.18 - 44.34 -45.93 - 29.85 0.35 - 34.69 -28.36 - 23.98\n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 18.37 (9.30) 0.63 (13.85) 17.65 (9.58) -1.06 (13.58) 16.75 (9.54) -2.71 (13.22) \n Median 18.11 1.13 17.68 -0.49 15.10 -2.66 \n Min - Max 0.59 - 41.73 -40.09 - 31.24 0.02 - 38.61 -46.30 - 31.38 0.48 - 39.23 -30.63 - 26.51\n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 19.17 (10.95) 1.44 (15.39) 17.22 (10.64) -1.48 (15.20) 17.92 (9.32) -1.54 (12.63) \n Median 17.41 0.88 15.88 -2.96 17.71 -1.53 \n Min - Max 0.93 - 54.24 -32.93 - 46.98 0.39 - 47.96 -41.45 - 43.08 0.25 - 41.27 -30.33 - 27.99\n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 19.22 (9.47) 1.48 (14.49) 18.01 (9.92) -0.69 (14.65) 18.51 (9.43) -0.95 (12.92) \n Median 19.80 2.31 18.28 1.82 19.26 -2.48 \n Min - Max 0.01 - 43.42 -40.08 - 30.07 0.11 - 40.64 -47.60 - 26.04 0.02 - 37.46 -29.78 - 25.00\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\"ADLB\",\n adlb,\n code = 'ADLB <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adlb\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Laboratory Test Results and Change from Baseline by Visit\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adlb, c(\"AVAL\", \"CHG\")),\n selected = c(\"AVAL\", \"CHG\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"ALT\"\n ),\n parallel_vars = TRUE\n )\n ),\n filter = list(ADLB = list(AVAL = list()))\n)\n\n[INFO] 2023-09-09 17:41:20.9814 pid:1945 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt04.html",
"href": "tables/lab-results/lbt04.html",
"title": "LBT04",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\nadlb_f <- adlb %>%\n filter(ONTRTFL == \"Y\", ANRIND != \"<Missing>\") %>%\n var_relabel(\n PARAM = \"Laboratory Test\",\n ANRIND = \"Direction of Abnormality\"\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = obj_label(adlb_f$PARAM)\n ) %>%\n count_abnormal(\n var = \"ANRIND\",\n abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")),\n exclude_base_abn = TRUE\n ) %>%\n append_varlabels(adlb_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adlb_f, alt_counts_df = adsl)\n\nresult\n\nLaboratory Test A: Drug X B: Placebo C: Combination\n Direction of Abnormality (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Low 57/113 (50.4%) 62/117 (53%) 61/123 (49.6%)\n High 0/134 0/134 0/132 \nC-Reactive Protein Measurement \n Low 78/119 (65.5%) 71/113 (62.8%) 62/112 (55.4%)\n High 69/114 (60.5%) 57/112 (50.9%) 58/115 (50.4%)\nImmunoglobulin A Measurement \n Low 0/134 0/134 0/132 \n High 64/119 (53.8%) 62/116 (53.4%) 62/113 (54.9%)\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n var_relabel(PARAM = \"Laboratory Test\", ANRIND = \"Direction of Abnormality\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb, code = '\n ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n var_relabel(PARAM = \"Laboratory Test\", ANRIND = \"Direction of Abnormality\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality(\n label = \"Abnormality Table\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, subset = c(\"LBCAT\", \"PARAM\", \"AVISIT\")),\n selected = c(\"LBCAT\", \"PARAM\"),\n keep_order = TRUE\n ),\n grade = choices_selected(\n choices = variable_choices(adlb, subset = \"ANRIND\"),\n selected = \"ANRIND\",\n fixed = TRUE\n ),\n abnormal = list(low = \"LOW\", high = \"HIGH\"),\n exclude_base_abn = TRUE\n )\n )\n)\n\n[INFO] 2023-09-08 19:25:21.9551 pid:1746 token:[] teal.modules.clinical Initializing tm_t_abnormality\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\nadlb_f <- adlb %>%\n filter(ONTRTFL == \"Y\", ANRIND != \"<Missing>\") %>%\n var_relabel(\n PARAM = \"Laboratory Test\",\n ANRIND = \"Direction of Abnormality\"\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARAM\",\n split_fun = drop_split_levels,\n label_pos = \"topleft\",\n split_label = obj_label(adlb_f$PARAM)\n ) %>%\n count_abnormal(\n var = \"ANRIND\",\n abnormal = list(Low = c(\"LOW\", \"LOW LOW\"), High = c(\"HIGH\", \"HIGH HIGH\")),\n exclude_base_abn = TRUE\n ) %>%\n append_varlabels(adlb_f, \"ANRIND\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = adlb_f, alt_counts_df = adsl)\n\nresult\n\nLaboratory Test A: Drug X B: Placebo C: Combination\n Direction of Abnormality (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement \n Low 57/113 (50.4%) 62/117 (53%) 61/123 (49.6%)\n High 0/134 0/134 0/132 \nC-Reactive Protein Measurement \n Low 78/119 (65.5%) 71/113 (62.8%) 62/112 (55.4%)\n High 69/114 (60.5%) 57/112 (50.9%) 58/115 (50.4%)\nImmunoglobulin A Measurement \n Low 0/134 0/134 0/132 \n High 64/119 (53.8%) 62/116 (53.4%) 62/113 (54.9%)\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n var_relabel(PARAM = \"Laboratory Test\", ANRIND = \"Direction of Abnormality\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb, code = '\n ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n var_relabel(PARAM = \"Laboratory Test\", ANRIND = \"Direction of Abnormality\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality(\n label = \"Abnormality Table\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, subset = c(\"LBCAT\", \"PARAM\", \"AVISIT\")),\n selected = c(\"LBCAT\", \"PARAM\"),\n keep_order = TRUE\n ),\n grade = choices_selected(\n choices = variable_choices(adlb, subset = \"ANRIND\"),\n selected = \"ANRIND\",\n fixed = TRUE\n ),\n abnormal = list(low = \"LOW\", high = \"HIGH\"),\n exclude_base_abn = TRUE\n )\n )\n)\n\n[INFO] 2023-09-09 17:40:15.4994 pid:1749 token:[] teal.modules.clinical Initializing tm_t_abnormality\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "index.html#introduction",
@@ -501,7 +501,7 @@
"href": "appendix/reproducibility.html#session-info",
"title": "Reproducibility",
"section": "Session Info",
- "text": "Session Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nloaded via a namespace (and not attached):\n [1] digest_0.6.33 R6_2.5.1 codetools_0.2-19 fastmap_1.1.1 \n [5] xfun_0.40 magrittr_2.0.3 knitr_1.43 htmltools_0.5.6 \n [9] rmarkdown_2.24 cli_3.6.1 testthat_3.1.10 compiler_4.3.1 \n[13] rstudioapi_0.15.0 tools_4.3.1 brio_1.1.3 evaluate_0.21 \n[17] yaml_2.3.7 rlang_1.1.1 jsonlite_1.8.7 htmlwidgets_1.6.2\n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodewithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(\"..\", lockfile = \"../assets/www/renv.lock\", prompt = FALSE, force = TRUE)\n)\n\n\nNOTE: Dependency discovery took 12 seconds during snapshot.\nConsider using .renvignore to ignore files, or switching to explicit snapshots.\nSee `?renv::dependencies` for more information.\n\n\nDownload"
+ "text": "Session Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nloaded via a namespace (and not attached):\n [1] digest_0.6.33 R6_2.5.1 codetools_0.2-19 fastmap_1.1.1 \n [5] xfun_0.40 magrittr_2.0.3 knitr_1.43 htmltools_0.5.6 \n [9] rmarkdown_2.24 cli_3.6.1 testthat_3.1.10 compiler_4.3.1 \n[13] rstudioapi_0.15.0 tools_4.3.1 brio_1.1.3 evaluate_0.21 \n[17] yaml_2.3.7 rlang_1.1.1 jsonlite_1.8.7 htmlwidgets_1.6.2\n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodewithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(\"..\", lockfile = \"../assets/www/renv.lock\", prompt = FALSE, force = TRUE)\n)\n\n\nNOTE: Dependency discovery took 18 seconds during snapshot.\nConsider using .renvignore to ignore files, or switching to explicit snapshots.\nSee `?renv::dependencies` for more information.\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt12_bl.html",
@@ -515,7 +515,7 @@
"href": "tables/lab-results/lbt02.html",
"title": "LBT02",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCode# Preparation of an illustrative dataset\nlibrary(scda)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadlb_labels <- var_labels(adlb)\n\n# For illustration purposes, the example focuses on ALT\n# Measurements starting from baseline and excluding all screening visits\nadlb <- subset(adlb, AVISIT != \"SCREENING\" & PARAMCD == \"ALT\")\nadlb$AVISIT <- droplevels(adlb$AVISIT)\n\nvar_labels(adlb) <- adlb_labels\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\n var = \"AVISIT\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adlb$AVISIT)\n ) %>%\n analyze_vars(vars = \"AVAL\")\n\nresult <- build_table(l,\n df = adlb,\n alt_counts_df = adsl\n)\nresult\n\nAnalysis Visit A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n——————————————————————————————————————————————————————————————————————————\nBASELINE \n n 134 134 132 400 \n Mean (SD) 17.7 (9.9) 18.7 (9.8) 19.5 (9.1) 18.6 (9.6) \n Median 17.5 18.2 19.0 18.0 \n Min - Max 0.0 - 44.1 1.5 - 54.4 0.6 - 39.8 0.0 - 54.4 \nWEEK 1 DAY 8 \n n 134 134 132 400 \n Mean (SD) 16.8 (9.1) 18.9 (9.2) 19.6 (9.3) 18.4 (9.2) \n Median 16.0 18.2 19.0 18.0 \n Min - Max 0.1 - 36.3 0.7 - 39.9 0.9 - 44.7 0.1 - 44.7 \nWEEK 2 DAY 15 \n n 134 134 132 400 \n Mean (SD) 17.8 (9.6) 18.8 (9.7) 16.5 (8.2) 17.7 (9.2) \n Median 15.9 18.0 17.0 17.0 \n Min - Max 0.4 - 44.3 0.2 - 44.3 0.3 - 34.7 0.2 - 44.3 \nWEEK 3 DAY 22 \n n 134 134 132 400 \n Mean (SD) 18.4 (9.3) 17.6 (9.6) 16.8 (9.5) 17.6 (9.5) \n Median 18.1 17.7 15.1 17.2 \n Min - Max 0.6 - 41.7 0.0 - 38.6 0.5 - 39.2 0.0 - 41.7 \nWEEK 4 DAY 29 \n n 134 134 132 400 \n Mean (SD) 19.2 (11.0) 17.2 (10.6) 17.9 (9.3) 18.1 (10.3) \n Median 17.4 15.9 17.7 17.3 \n Min - Max 0.9 - 54.2 0.4 - 48.0 0.2 - 41.3 0.2 - 54.2 \nWEEK 5 DAY 36 \n n 134 134 132 400 \n Mean (SD) 19.2 (9.5) 18.0 (9.9) 18.5 (9.4) 18.6 (9.6) \n Median 19.8 18.3 19.3 19.0 \n Min - Max 0.0 - 43.4 0.1 - 40.6 0.0 - 37.5 0.0 - 43.4 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure missing and NA values are cleaned up and convert variables to factors.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)'),\n cdisc_dataset(\"ADLB\", adlb, code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n ADLB <- df_explicit_na(ADLB)'),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Laboratory Test Results by Visit\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, c(\"PARAM\", \"AVISIT\")), # note: order matters here. If `PARAM` is first, the split will be first by `PARAM`and then by `AVISIT`\n selected = c(\"PARAM\", \"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adlb, c(\"AVAL\")),\n selected = c(\"AVAL\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"ALT\"\n )\n )\n ),\n filter = list(ADLB = list(AVAL = list()))\n)\n\n[INFO] 2023-09-08 19:25:55.6115 pid:1845 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] dplyr_1.1.2 teal.modules.clinical_0.8.16.9003\n [3] teal_0.14.0.9005 teal.transform_0.4.0.9003 \n [5] teal.slice_0.4.0.9011 teal.data_0.3.0.9003 \n [7] shiny_1.7.5 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCode# Preparation of an illustrative dataset\nlibrary(scda)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadlb_labels <- var_labels(adlb)\n\n# For illustration purposes, the example focuses on ALT\n# Measurements starting from baseline and excluding all screening visits\nadlb <- subset(adlb, AVISIT != \"SCREENING\" & PARAMCD == \"ALT\")\nadlb$AVISIT <- droplevels(adlb$AVISIT)\n\nvar_labels(adlb) <- adlb_labels\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n add_overall_col(\"All Patients\") %>%\n split_rows_by(\n var = \"AVISIT\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adlb$AVISIT)\n ) %>%\n analyze_vars(vars = \"AVAL\")\n\nresult <- build_table(l,\n df = adlb,\n alt_counts_df = adsl\n)\nresult\n\nAnalysis Visit A: Drug X B: Placebo C: Combination All Patients\n (N=134) (N=134) (N=132) (N=400) \n——————————————————————————————————————————————————————————————————————————\nBASELINE \n n 134 134 132 400 \n Mean (SD) 17.7 (9.9) 18.7 (9.8) 19.5 (9.1) 18.6 (9.6) \n Median 17.5 18.2 19.0 18.0 \n Min - Max 0.0 - 44.1 1.5 - 54.4 0.6 - 39.8 0.0 - 54.4 \nWEEK 1 DAY 8 \n n 134 134 132 400 \n Mean (SD) 16.8 (9.1) 18.9 (9.2) 19.6 (9.3) 18.4 (9.2) \n Median 16.0 18.2 19.0 18.0 \n Min - Max 0.1 - 36.3 0.7 - 39.9 0.9 - 44.7 0.1 - 44.7 \nWEEK 2 DAY 15 \n n 134 134 132 400 \n Mean (SD) 17.8 (9.6) 18.8 (9.7) 16.5 (8.2) 17.7 (9.2) \n Median 15.9 18.0 17.0 17.0 \n Min - Max 0.4 - 44.3 0.2 - 44.3 0.3 - 34.7 0.2 - 44.3 \nWEEK 3 DAY 22 \n n 134 134 132 400 \n Mean (SD) 18.4 (9.3) 17.6 (9.6) 16.8 (9.5) 17.6 (9.5) \n Median 18.1 17.7 15.1 17.2 \n Min - Max 0.6 - 41.7 0.0 - 38.6 0.5 - 39.2 0.0 - 41.7 \nWEEK 4 DAY 29 \n n 134 134 132 400 \n Mean (SD) 19.2 (11.0) 17.2 (10.6) 17.9 (9.3) 18.1 (10.3) \n Median 17.4 15.9 17.7 17.3 \n Min - Max 0.9 - 54.2 0.4 - 48.0 0.2 - 41.3 0.2 - 54.2 \nWEEK 5 DAY 36 \n n 134 134 132 400 \n Mean (SD) 19.2 (9.5) 18.0 (9.9) 18.5 (9.4) 18.6 (9.6) \n Median 19.8 18.3 19.3 19.0 \n Min - Max 0.0 - 43.4 0.1 - 40.6 0.0 - 37.5 0.0 - 43.4 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\n# Ensure missing and NA values are cleaned up and convert variables to factors.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)'),\n cdisc_dataset(\"ADLB\", adlb, code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n ADLB <- df_explicit_na(ADLB)'),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Laboratory Test Results by Visit\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adlb, c(\"PARAM\", \"AVISIT\")), # note: order matters here. If `PARAM` is first, the split will be first by `PARAM`and then by `AVISIT`\n selected = c(\"PARAM\", \"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adlb, c(\"AVAL\")),\n selected = c(\"AVAL\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"ALT\"\n )\n )\n ),\n filter = list(ADLB = list(AVAL = list()))\n)\n\n[INFO] 2023-09-09 17:40:53.5277 pid:1847 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] dplyr_1.1.2 teal.modules.clinical_0.8.16.9003\n [3] teal_0.14.0.9005 teal.transform_0.4.0.9003 \n [5] teal.slice_0.4.0.9012 teal.data_0.3.0.9003 \n [7] shiny_1.7.5 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt05.html",
@@ -550,21 +550,21 @@
"href": "tables/lab-results/lbt07.html",
"title": "LBT07",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\nlibrary(forcats)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadlb_labels <- var_labels(adlb)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\n# Select worst post-baseline records.\nadlb_f <- adlb %>%\n filter(ATOXGR != \"<Missing>\") %>%\n filter(ONTRTFL == \"Y\") %>%\n filter(WGRLOFL == \"Y\" | WGRHIFL == \"Y\")\n\nvar_labels(adlb_f) <- adlb_labels\n\n# Derive GRADE_DIR and GRADE_ANL to use in layout from ATOXGR\nadlb_f <- adlb_f %>%\n mutate(\n GRADE_DIR = factor(\n case_when(\n ATOXGR %in% c(\"-1\", \"-2\", \"-3\", \"-4\") & .data$WGRLOFL == \"Y\" ~ \"LOW\",\n ATOXGR == \"0\" ~ \"ZERO\",\n ATOXGR %in% c(\"1\", \"2\", \"3\", \"4\") & .data$WGRHIFL == \"Y\" ~ \"HIGH\",\n TRUE ~ \"NONE\"\n ),\n levels = c(\"LOW\", \"ZERO\", \"HIGH\", \"NONE\")\n ),\n GRADE_ANL = forcats::fct_relevel(\n forcats::fct_recode(ATOXGR,\n `1` = \"-1\", `2` = \"-2\", `3` = \"-3\", `4` = \"-4\"\n ),\n c(\"0\", \"1\", \"2\", \"3\", \"4\")\n )\n ) %>%\n var_relabel(\n GRADE_DIR = \"Direction of Abnormality\",\n GRADE_ANL = \"Analysis Grade\"\n )\n\n# Construct analysis map\nmap <- expand.grid(\n PARAM = levels(adlb$PARAM),\n GRADE_DIR = c(\"LOW\", \"HIGH\"),\n GRADE_ANL = as.character(1:4),\n stringsAsFactors = FALSE\n) %>%\n arrange(PARAM, desc(GRADE_DIR), GRADE_ANL)\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n label_pos = \"topleft\",\n split_label = obj_label(adlb_f$PARAM)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n required = \"ATOXGR\",\n .stats = \"unique_count\"\n ) %>%\n split_rows_by(\n \"GRADE_DIR\",\n label_pos = \"topleft\",\n split_label = obj_label(adlb_f$GRADE_DIR),\n split_fun = trim_levels_to_map(map)\n ) %>%\n count_abnormal_by_worst_grade(\n var = \"GRADE_ANL\",\n variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\"),\n .indent_mods = 4L\n ) %>%\n append_topleft(\" Highest NCI CTCAE Grade\")\n\nresult <- build_table(lyt = lyt, df = adlb_f, alt_counts_df = adsl)\nresult <- result %>% prune_table()\n\nresult\n\nParameter \n Direction of Abnormality A: Drug X B: Placebo C: Combination\n Highest NCI CTCAE Grade (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement (n) 134 134 132 \n LOW \n 1 15 (11.2%) 11 (8.2%) 15 (11.4%) \n 2 18 (13.4%) 24 (17.9%) 17 (12.9%) \n 3 16 (11.9%) 24 (17.9%) 16 (12.1%) \n 4 17 (12.7%) 10 (7.5%) 18 (13.6%) \n Any 66 (49.3%) 69 (51.5%) 66 (50%) \nC-Reactive Protein Measurement (n) 134 134 132 \n LOW \n 1 21 (15.7%) 22 (16.4%) 12 (9.1%) \n 2 24 (17.9%) 22 (16.4%) 18 (13.6%) \n 3 29 (21.6%) 21 (15.7%) 25 (18.9%) \n 4 10 (7.5%) 16 (11.9%) 22 (16.7%) \n Any 84 (62.7%) 81 (60.4%) 77 (58.3%) \n HIGH \n 1 20 (14.9%) 22 (16.4%) 22 (16.7%) \n 2 21 (15.7%) 15 (11.2%) 14 (10.6%) \n 3 25 (18.7%) 16 (11.9%) 20 (15.2%) \n 4 13 (9.7%) 20 (14.9%) 11 (8.3%) \n Any 79 (59%) 73 (54.5%) 67 (50.8%) \nImmunoglobulin A Measurement (n) 134 134 132 \n HIGH \n 1 19 (14.2%) 12 (9%) 18 (13.6%) \n 2 17 (12.7%) 24 (17.9%) 19 (14.4%) \n 3 21 (15.7%) 23 (17.2%) 23 (17.4%) \n 4 13 (9.7%) 13 (9.7%) 9 (6.8%) \n Any 70 (52.2%) 72 (53.7%) 69 (52.3%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n filter(!AVISIT %in% c(\"SCREENING\", \"BASELINE\"))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb,\n code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n filter(!AVISIT %in% c(\"SCREENING\", \"BASELINE\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality_by_worst_grade(\n label = \"Laboratory Test Results with Highest Grade Post-Baseline\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = c(\"ALT\", \"CRP\", \"IGA\")\n ),\n add_total = FALSE\n )\n ),\n filter = (\n list(\n ADSL = list(SAFFL = \"Y\"),\n ADLB = list(ONTRTFL = \"Y\")\n )\n )\n)\n\n[INFO] 2023-09-08 19:28:06.8440 pid:2496 token:[] teal.modules.clinical Initializing tm_t_abnormality_by_worst_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] forcats_1.0.0 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\nlibrary(forcats)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadlb_labels <- var_labels(adlb)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\n# Select worst post-baseline records.\nadlb_f <- adlb %>%\n filter(ATOXGR != \"<Missing>\") %>%\n filter(ONTRTFL == \"Y\") %>%\n filter(WGRLOFL == \"Y\" | WGRHIFL == \"Y\")\n\nvar_labels(adlb_f) <- adlb_labels\n\n# Derive GRADE_DIR and GRADE_ANL to use in layout from ATOXGR\nadlb_f <- adlb_f %>%\n mutate(\n GRADE_DIR = factor(\n case_when(\n ATOXGR %in% c(\"-1\", \"-2\", \"-3\", \"-4\") & .data$WGRLOFL == \"Y\" ~ \"LOW\",\n ATOXGR == \"0\" ~ \"ZERO\",\n ATOXGR %in% c(\"1\", \"2\", \"3\", \"4\") & .data$WGRHIFL == \"Y\" ~ \"HIGH\",\n TRUE ~ \"NONE\"\n ),\n levels = c(\"LOW\", \"ZERO\", \"HIGH\", \"NONE\")\n ),\n GRADE_ANL = forcats::fct_relevel(\n forcats::fct_recode(ATOXGR,\n `1` = \"-1\", `2` = \"-2\", `3` = \"-3\", `4` = \"-4\"\n ),\n c(\"0\", \"1\", \"2\", \"3\", \"4\")\n )\n ) %>%\n var_relabel(\n GRADE_DIR = \"Direction of Abnormality\",\n GRADE_ANL = \"Analysis Grade\"\n )\n\n# Construct analysis map\nmap <- expand.grid(\n PARAM = levels(adlb$PARAM),\n GRADE_DIR = c(\"LOW\", \"HIGH\"),\n GRADE_ANL = as.character(1:4),\n stringsAsFactors = FALSE\n) %>%\n arrange(PARAM, desc(GRADE_DIR), GRADE_ANL)\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAM\",\n label_pos = \"topleft\",\n split_label = obj_label(adlb_f$PARAM)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n required = \"ATOXGR\",\n .stats = \"unique_count\"\n ) %>%\n split_rows_by(\n \"GRADE_DIR\",\n label_pos = \"topleft\",\n split_label = obj_label(adlb_f$GRADE_DIR),\n split_fun = trim_levels_to_map(map)\n ) %>%\n count_abnormal_by_worst_grade(\n var = \"GRADE_ANL\",\n variables = list(id = \"USUBJID\", param = \"PARAM\", grade_dir = \"GRADE_DIR\"),\n .indent_mods = 4L\n ) %>%\n append_topleft(\" Highest NCI CTCAE Grade\")\n\nresult <- build_table(lyt = lyt, df = adlb_f, alt_counts_df = adsl)\nresult <- result %>% prune_table()\n\nresult\n\nParameter \n Direction of Abnormality A: Drug X B: Placebo C: Combination\n Highest NCI CTCAE Grade (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nAlanine Aminotransferase Measurement (n) 134 134 132 \n LOW \n 1 15 (11.2%) 11 (8.2%) 15 (11.4%) \n 2 18 (13.4%) 24 (17.9%) 17 (12.9%) \n 3 16 (11.9%) 24 (17.9%) 16 (12.1%) \n 4 17 (12.7%) 10 (7.5%) 18 (13.6%) \n Any 66 (49.3%) 69 (51.5%) 66 (50%) \nC-Reactive Protein Measurement (n) 134 134 132 \n LOW \n 1 21 (15.7%) 22 (16.4%) 12 (9.1%) \n 2 24 (17.9%) 22 (16.4%) 18 (13.6%) \n 3 29 (21.6%) 21 (15.7%) 25 (18.9%) \n 4 10 (7.5%) 16 (11.9%) 22 (16.7%) \n Any 84 (62.7%) 81 (60.4%) 77 (58.3%) \n HIGH \n 1 20 (14.9%) 22 (16.4%) 22 (16.7%) \n 2 21 (15.7%) 15 (11.2%) 14 (10.6%) \n 3 25 (18.7%) 16 (11.9%) 20 (15.2%) \n 4 13 (9.7%) 20 (14.9%) 11 (8.3%) \n Any 79 (59%) 73 (54.5%) 67 (50.8%) \nImmunoglobulin A Measurement (n) 134 134 132 \n HIGH \n 1 19 (14.2%) 12 (9%) 18 (13.6%) \n 2 17 (12.7%) 24 (17.9%) 19 (14.4%) \n 3 21 (15.7%) 23 (17.2%) 23 (17.4%) \n 4 13 (9.7%) 13 (9.7%) 9 (6.8%) \n Any 70 (52.2%) 72 (53.7%) 69 (52.3%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n filter(!AVISIT %in% c(\"SCREENING\", \"BASELINE\"))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb,\n code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n filter(!AVISIT %in% c(\"SCREENING\", \"BASELINE\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_abnormality_by_worst_grade(\n label = \"Laboratory Test Results with Highest Grade Post-Baseline\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = c(\"ALT\", \"CRP\", \"IGA\")\n ),\n add_total = FALSE\n )\n ),\n filter = (\n list(\n ADSL = list(SAFFL = \"Y\"),\n ADLB = list(ONTRTFL = \"Y\")\n )\n )\n)\n\n[INFO] 2023-09-09 17:43:48.8125 pid:2501 token:[] teal.modules.clinical Initializing tm_t_abnormality_by_worst_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] forcats_1.0.0 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt11_bl.html",
"href": "tables/lab-results/lbt11_bl.html",
"title": "LBT11_BL",
"section": "",
- "text": "Data Setup\nTime-To-Event Summary\nTime-To-Event Summary Selecting Sections to Display\nTime-To-Event Summary with Stratified Analysis\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsaftte <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadsaftte <- df_explicit_na(adsaftte)\n\nadsl_safl <- dplyr::filter(adsl, .data$SAFFL == \"Y\")\n\nanl <- adsaftte %>%\n dplyr::filter(\n SAFFL == \"Y\",\n PARAMCD == \"HYSTTEBL\"\n ) %>%\n dplyr::mutate(\n AVAL = .data$AVAL * dplyr::case_when( # convert to days, if possible\n .data$AVALU == \"WEEKS\" ~ 7,\n .data$AVALU == \"MONTHS\" ~ 30.4375,\n .data$AVALU == \"YEARS\" ~ 365,\n TRUE ~ 1\n ),\n AVALU = factor(dplyr::case_when(\n .data$AVALU %in% c(\"WEEKS\", \"MONTHS\", \"YEARS\") ~ factor(\"DAYS\"),\n TRUE ~ .data$AVALU\n ), levels = \"DAYS\"),\n is_event = CNSR == 0, # this will be a LLT event\n event_grp = factor(\n dplyr::case_when(\n CNSR == 0 ~ \"Patients with LLT event (%)\",\n CNSR == 1 ~ \"Patients without LLT event (%)\"\n ),\n levels = c(\n \"Patients with LLT event (%)\",\n \"Patients without LLT event (%)\"\n )\n )\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 14 (10.4%) 18 (13.4%) 15 (11.4%) \nPatients without LLT event (%) 120 (89.6%) 116 (86.6%) 117 (88.6%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 721.0 \n 95% CI NA (681.0, NA) (691.0, NA) \n 25% and 75%-ile 608.0, NA 558.0, NA 644.0, NA \n Range (censored) 1.0 to 728.0 1.0 to 726.0 1.0 to 724.0 \n Range (event) 23.0 to 608.0 36.0 to 681.0 61.0 to 721.0\nUnstratified Analysis \n p-value (log-rank) 0.5013 0.6413 \n Hazard Ratio 1.27 0.84 \n 95% CI (0.63, 2.56) (0.40, 1.75) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 14 (10.4%) 18 (13.4%) 15 (11.4%) \nPatients without LLT event (%) 120 (89.6%) 116 (86.6%) 117 (88.6%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 721.0 \n 95% CI NA (681.0, NA) (691.0, NA) \n 25% and 75%-ile 608.0, NA 558.0, NA 644.0, NA \n Range (censored) 1.0 to 728.0 1.0 to 726.0 1.0 to 724.0 \n Range (event) 23.0 to 608.0 36.0 to 681.0 61.0 to 721.0\n\n\n\n\n\nCodestrata <- c(\"RACE\", \"SEX\")\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = paste0(\"Stratified By: \", paste(strata, collapse = \", \")),\n strat = strata,\n table_names = \"coxph_stratified\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 14 (10.4%) 18 (13.4%) 15 (11.4%) \nPatients without LLT event (%) 120 (89.6%) 116 (86.6%) 117 (88.6%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 721.0 \n 95% CI NA (681.0, NA) (691.0, NA) \n 25% and 75%-ile 608.0, NA 558.0, NA 644.0, NA \n Range (censored) 1.0 to 728.0 1.0 to 726.0 1.0 to 724.0 \n Range (event) 23.0 to 608.0 36.0 to 681.0 61.0 to 721.0\nUnstratified Analysis \n p-value (log-rank) 0.5013 0.6413 \n Hazard Ratio 1.27 0.84 \n 95% CI (0.63, 2.56) (0.40, 1.75) \nStratified By: RACE, SEX \n p-value (log-rank) 0.3886 0.7970 \n Hazard Ratio 1.39 0.91 \n 95% CI (0.65, 2.97) (0.43, 1.93) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsaftte <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadsaftte <- df_explicit_na(adsaftte)\n\nadsl <- dplyr::filter(adsl, .data$SAFFL == \"Y\")\nadsaftte <- dplyr::filter(adsaftte, .data$SAFFL == \"Y\")\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% df_explicit_na() %>% dplyr::filter(.data$SAFFL == \"Y\")'\n ),\n cdisc_dataset(\n \"ADSAFTTE\",\n adsaftte,\n keys = c(\"STUDYID\", \"USUBJID\", \"PARAMCD\"),\n code = 'ADSAFTTE <- synthetic_cdisc_dataset(\"latest\", \"adaette\") %>% df_explicit_na() %>% dplyr::filter(.data$SAFFL == \"Y\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_tte(\n label = \"Time To LLT Event Table\",\n dataname = \"ADSAFTTE\",\n arm_var = choices_selected(\n variable_choices(adsl, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adsaftte, \"PARAMCD\", \"PARAM\"),\n \"HYSTTEBL\"\n ),\n strata_var = choices_selected(\n variable_choices(adsl, c(\"RACE\", \"SEX\")),\n c(\"RACE\", \"SEX\")\n ),\n time_points = choices_selected(0, NULL),\n event_desc_var = choices_selected(\"EVNTDESC\", \"EVNTDESC\", fixed = TRUE)\n )\n )\n)\n\n[INFO] 2023-09-08 19:29:17.3039 pid:2692 token:[] teal.modules.clinical Initializing tm_t_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nTime-To-Event Summary\nTime-To-Event Summary Selecting Sections to Display\nTime-To-Event Summary with Stratified Analysis\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsaftte <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadsaftte <- df_explicit_na(adsaftte)\n\nadsl_safl <- dplyr::filter(adsl, .data$SAFFL == \"Y\")\n\nanl <- adsaftte %>%\n dplyr::filter(\n SAFFL == \"Y\",\n PARAMCD == \"HYSTTEBL\"\n ) %>%\n dplyr::mutate(\n AVAL = .data$AVAL * dplyr::case_when( # convert to days, if possible\n .data$AVALU == \"WEEKS\" ~ 7,\n .data$AVALU == \"MONTHS\" ~ 30.4375,\n .data$AVALU == \"YEARS\" ~ 365,\n TRUE ~ 1\n ),\n AVALU = factor(dplyr::case_when(\n .data$AVALU %in% c(\"WEEKS\", \"MONTHS\", \"YEARS\") ~ factor(\"DAYS\"),\n TRUE ~ .data$AVALU\n ), levels = \"DAYS\"),\n is_event = CNSR == 0, # this will be a LLT event\n event_grp = factor(\n dplyr::case_when(\n CNSR == 0 ~ \"Patients with LLT event (%)\",\n CNSR == 1 ~ \"Patients without LLT event (%)\"\n ),\n levels = c(\n \"Patients with LLT event (%)\",\n \"Patients without LLT event (%)\"\n )\n )\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 14 (10.4%) 18 (13.4%) 15 (11.4%) \nPatients without LLT event (%) 120 (89.6%) 116 (86.6%) 117 (88.6%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 721.0 \n 95% CI NA (681.0, NA) (691.0, NA) \n 25% and 75%-ile 608.0, NA 558.0, NA 644.0, NA \n Range (censored) 1.0 to 728.0 1.0 to 726.0 1.0 to 724.0 \n Range (event) 23.0 to 608.0 36.0 to 681.0 61.0 to 721.0\nUnstratified Analysis \n p-value (log-rank) 0.5013 0.6413 \n Hazard Ratio 1.27 0.84 \n 95% CI (0.63, 2.56) (0.40, 1.75) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 14 (10.4%) 18 (13.4%) 15 (11.4%) \nPatients without LLT event (%) 120 (89.6%) 116 (86.6%) 117 (88.6%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 721.0 \n 95% CI NA (681.0, NA) (691.0, NA) \n 25% and 75%-ile 608.0, NA 558.0, NA 644.0, NA \n Range (censored) 1.0 to 728.0 1.0 to 726.0 1.0 to 724.0 \n Range (event) 23.0 to 608.0 36.0 to 681.0 61.0 to 721.0\n\n\n\n\n\nCodestrata <- c(\"RACE\", \"SEX\")\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARMCD\", ref_group = \"ARM A\") %>%\n count_occurrences(vars = \"event_grp\") %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = paste0(\"Time to 1st LLT Event (\", levels(anl$AVALU), \")\"),\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = paste0(\"Stratified By: \", paste(strata, collapse = \", \")),\n strat = strata,\n table_names = \"coxph_stratified\"\n )\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_safl)\nresult\n\n ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————\nPatients with LLT event (%) 14 (10.4%) 18 (13.4%) 15 (11.4%) \nPatients without LLT event (%) 120 (89.6%) 116 (86.6%) 117 (88.6%) \nTime to 1st LLT Event (DAYS) \n Median NA NA 721.0 \n 95% CI NA (681.0, NA) (691.0, NA) \n 25% and 75%-ile 608.0, NA 558.0, NA 644.0, NA \n Range (censored) 1.0 to 728.0 1.0 to 726.0 1.0 to 724.0 \n Range (event) 23.0 to 608.0 36.0 to 681.0 61.0 to 721.0\nUnstratified Analysis \n p-value (log-rank) 0.5013 0.6413 \n Hazard Ratio 1.27 0.84 \n 95% CI (0.63, 2.56) (0.40, 1.75) \nStratified By: RACE, SEX \n p-value (log-rank) 0.3886 0.7970 \n Hazard Ratio 1.39 0.91 \n 95% CI (0.65, 2.97) (0.43, 1.93) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadsaftte <- synthetic_cdisc_dataset(\"latest\", \"adaette\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadsaftte <- df_explicit_na(adsaftte)\n\nadsl <- dplyr::filter(adsl, .data$SAFFL == \"Y\")\nadsaftte <- dplyr::filter(adsaftte, .data$SAFFL == \"Y\")\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% df_explicit_na() %>% dplyr::filter(.data$SAFFL == \"Y\")'\n ),\n cdisc_dataset(\n \"ADSAFTTE\",\n adsaftte,\n keys = c(\"STUDYID\", \"USUBJID\", \"PARAMCD\"),\n code = 'ADSAFTTE <- synthetic_cdisc_dataset(\"latest\", \"adaette\") %>% df_explicit_na() %>% dplyr::filter(.data$SAFFL == \"Y\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_tte(\n label = \"Time To LLT Event Table\",\n dataname = \"ADSAFTTE\",\n arm_var = choices_selected(\n variable_choices(adsl, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adsaftte, \"PARAMCD\", \"PARAM\"),\n \"HYSTTEBL\"\n ),\n strata_var = choices_selected(\n variable_choices(adsl, c(\"RACE\", \"SEX\")),\n c(\"RACE\", \"SEX\")\n ),\n time_points = choices_selected(0, NULL),\n event_desc_var = choices_selected(\"EVNTDESC\", \"EVNTDESC\", fixed = TRUE)\n )\n )\n)\n\n[INFO] 2023-09-09 17:45:10.1525 pid:2697 token:[] teal.modules.clinical Initializing tm_t_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/lab-results/lbt13.html",
"href": "tables/lab-results/lbt13.html",
"title": "LBT13",
"section": "",
- "text": "Data Setup\nStandard Table (Low)\nStandard Table (High)\nTable Without Patients with Missing Baseline (Low)\nTable with Missing Baseline Considered as Grade 0 (High)\nTable with Fill-In of Grades (High)\nteal App\nReproducibility\n\n\n\nPlease note that for each variant, the adlb dataset needs to be filtered on correct flags like WGRLOVFL, WGRHIVFL, et al., otherwise the layout function will not return the correct counts. There is an option to create a record for a lab test where no record is found at that visit. If you specified add_derived_type = \"PHANTOM\" & dtype_phantom_cond, you don’t have to use the h_adsl_adlb_merge_using_worst_flag function to preprocess your adlb dataset. Otherwise please follow the pre-processing steps below before applying the layout functions.\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\n# Please note that in real clinical data, population flag like SAFFL, and parameter category like PARCAT2 needs to be\n# selected properly.\nadsl_f <- adsl %>% filter(SAFFL == \"Y\")\nadlb <- adlb %>% filter(PARAMCD == \"CRP\" & SAFFL == \"Y\")\n\n\n\n\nNote that the worst laboratory flag (below WGRLOVFL) must be selected appropriately to match the direction of abnormality (here Low). New grouping variables ATOXGR_GP and BTOXGR_GP are created to display the correct output.\n\nCodeadlb_f <- adlb %>% filter(WGRLOVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRLOVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n ATOXGR == -1 ~ \"1\",\n ATOXGR == -2 ~ \"2\",\n ATOXGR == -3 ~ \"3\",\n ATOXGR == -4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n BTOXGR == -1 ~ \"1\",\n BTOXGR == -2 ~ \"2\",\n BTOXGR == -3 ~ \"3\",\n BTOXGR == -4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = TRUE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not Low (n) 116 110 101 \n Not Low 103 (88.8%) 91 (82.7%) 88 (87.1%) \n 1 3 (2.6%) 5 (4.5%) 6 (5.9%) \n 2 4 (3.4%) 9 (8.2%) 2 (2.0%) \n 3 3 (2.6%) 4 (3.6%) 4 (4.0%) \n 4 3 (2.6%) 1 (0.9%) 1 (1.0%) \n 1 (n) 4 7 5 \n Not Low 3 (75.0%) 7 (100%) 4 (80.0%) \n 3 1 (25.0%) 0 1 (20.0%) \n 2 (n) 5 6 11 \n Not Low 5 (100%) 5 (83.3%) 8 (72.7%) \n 1 0 0 1 (9.1%) \n 3 0 0 2 (18.2%) \n 4 0 1 (16.7%) 0 \n 3 (n) 6 8 5 \n Not Low 6 (100%) 7 (87.5%) 5 (100%) \n 3 0 1 (12.5%) 0 \n 4 (n) 3 3 10 \n Not Low 2 (66.7%) 3 (100%) 7 (70.0%) \n 1 0 0 2 (20.0%) \n 2 1 (33.3%) 0 0 \n 4 0 0 1 (10.0%) \n WEEK 2 DAY 15 \n Not Low (n) 106 111 116 \n Not Low 93 (87.7%) 93 (83.8%) 100 (86.2%) \n 1 3 (2.8%) 4 (3.6%) 8 (6.9%) \n 2 5 (4.7%) 7 (6.3%) 2 (1.7%) \n 3 2 (1.9%) 5 (4.5%) 6 (5.2%) \n 4 3 (2.8%) 2 (1.8%) 0 \n 1 (n) 15 9 2 \n Not Low 13 (86.7%) 8 (88.9%) 1 (50.0%) \n 2 0 1 (11.1%) 0 \n 3 2 (13.3%) 0 0 \n 4 0 0 1 (50.0%) \n 2 (n) 3 3 6 \n Not Low 3 (100%) 3 (100%) 4 (66.7%) \n 1 0 0 1 (16.7%) \n 3 0 0 1 (16.7%) \n 3 (n) 7 7 6 \n Not Low 7 (100%) 6 (85.7%) 5 (83.3%) \n 2 0 1 (14.3%) 0 \n 4 0 0 1 (16.7%) \n 4 (n) 3 4 2 \n Not Low 3 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n WEEK 3 DAY 22 \n Not Low (n) 119 110 114 \n Not Low 104 (87.4%) 92 (83.6%) 94 (82.5%) \n 1 3 (2.5%) 4 (3.6%) 9 (7.9%) \n 2 5 (4.2%) 7 (6.4%) 2 (1.8%) \n 3 4 (3.4%) 5 (4.5%) 7 (6.1%) \n 4 3 (2.5%) 2 (1.8%) 2 (1.8%) \n 1 (n) 9 9 6 \n Not Low 9 (100%) 7 (77.8%) 6 (100%) \n 2 0 2 (22.2%) 0 \n 2 (n) 1 7 3 \n Not Low 1 (100%) 6 (85.7%) 3 (100%) \n 1 0 1 (14.3%) 0 \n 3 (n) 4 5 4 \n Not Low 4 (100%) 5 (100%) 4 (100%) \n 4 (n) 1 3 5 \n Not Low 1 (100%) 3 (100%) 5 (100%) \n WEEK 4 DAY 29 \n Not Low (n) 101 119 111 \n Not Low 89 (88.1%) 100 (84.0%) 96 (86.5%) \n 1 3 (3.0%) 4 (3.4%) 6 (5.4%) \n 2 4 (4.0%) 8 (6.7%) 1 (0.9%) \n 3 2 (2.0%) 5 (4.2%) 6 (5.4%) \n 4 3 (3.0%) 2 (1.7%) 2 (1.8%) \n 1 (n) 10 5 6 \n Not Low 9 (90.0%) 5 (100%) 5 (83.3%) \n 1 0 0 1 (16.7%) \n 2 1 (10.0%) 0 0 \n 2 (n) 13 4 6 \n Not Low 13 (100%) 3 (75.0%) 5 (83.3%) \n 1 0 0 1 (16.7%) \n 2 0 1 (25.0%) 0 \n 3 (n) 8 2 6 \n Not Low 6 (75.0%) 1 (50.0%) 5 (83.3%) \n 1 0 1 (50.0%) 0 \n 2 0 0 1 (16.7%) \n 3 2 (25.0%) 0 0 \n 4 (n) 2 4 3 \n Not Low 2 (100%) 4 (100%) 1 (33.3%) \n 1 0 0 1 (33.3%) \n 3 0 0 1 (33.3%) \n WEEK 5 DAY 36 \n Not Low (n) 115 112 111 \n Not Low 102 (88.7%) 94 (83.9%) 96 (86.5%) \n 1 2 (1.7%) 4 (3.6%) 6 (5.4%) \n 2 5 (4.3%) 7 (6.2%) 2 (1.8%) \n 3 3 (2.6%) 5 (4.5%) 5 (4.5%) \n 4 3 (2.6%) 2 (1.8%) 2 (1.8%) \n 1 (n) 5 7 6 \n Not Low 5 (100%) 4 (57.1%) 5 (83.3%) \n 1 0 1 (14.3%) 1 (16.7%) \n 2 0 2 (28.6%) 0 \n 2 (n) 5 11 6 \n Not Low 5 (100%) 11 (100%) 6 (100%) \n 3 (n) 8 2 7 \n Not Low 6 (75.0%) 2 (100%) 4 (57.1%) \n 1 1 (12.5%) 0 1 (14.3%) \n 3 1 (12.5%) 0 2 (28.6%) \n 4 (n) 1 2 2 \n Not Low 1 (100%) 2 (100%) 1 (50.0%) \n 1 0 0 1 (50.0%) \n\n\n\n\nNote that the worst laboratory flag (below WGRHIVFL) must be selected appropriately to match the direction of abnormality (here High). New grouping variables ATOXGR_GP and BTOXGR_GP are created to display the correct output.\n\nCodeadlb_f <- adlb %>% filter(WGRHIVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRHIVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = TRUE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not High (n) 111 110 112 \n Not High 93 (83.8%) 92 (83.6%) 98 (87.5%) \n 1 8 (7.2%) 7 (6.4%) 5 (4.5%) \n 2 2 (1.8%) 6 (5.5%) 7 (6.2%) \n 3 6 (5.4%) 3 (2.7%) 2 (1.8%) \n 4 2 (1.8%) 2 (1.8%) 0 \n 1 (n) 8 11 6 \n Not High 7 (87.5%) 11 (100%) 5 (83.3%) \n 3 1 (12.5%) 0 1 (16.7%) \n 2 (n) 6 4 5 \n Not High 6 (100%) 1 (25.0%) 4 (80.0%) \n 1 0 3 (75.0%) 1 (20.0%) \n 3 (n) 8 3 4 \n Not High 7 (87.5%) 3 (100%) 4 (100%) \n 4 1 (12.5%) 0 0 \n 4 (n) 1 6 5 \n Not High 1 (100%) 5 (83.3%) 4 (80.0%) \n 1 0 0 1 (20.0%) \n 3 0 1 (16.7%) 0 \n WEEK 2 DAY 15 \n Not High (n) 117 113 113 \n Not High 99 (84.6%) 95 (84.1%) 100 (88.5%) \n 1 7 (6.0%) 6 (5.3%) 4 (3.5%) \n 2 2 (1.7%) 6 (5.3%) 6 (5.3%) \n 3 6 (5.1%) 4 (3.5%) 3 (2.7%) \n 4 3 (2.6%) 2 (1.8%) 0 \n 1 (n) 6 9 7 \n Not High 5 (83.3%) 8 (88.9%) 6 (85.7%) \n 1 0 1 (11.1%) 0 \n 2 0 0 1 (14.3%) \n 3 1 (16.7%) 0 0 \n 2 (n) 4 4 6 \n Not High 4 (100%) 4 (100%) 3 (50.0%) \n 1 0 0 3 (50.0%) \n 3 (n) 5 3 5 \n Not High 4 (80.0%) 2 (66.7%) 5 (100%) \n 1 1 (20.0%) 1 (33.3%) 0 \n 4 (n) 2 5 1 \n Not High 2 (100%) 3 (60.0%) 1 (100%) \n 1 0 2 (40.0%) 0 \n WEEK 3 DAY 22 \n Not High (n) 110 111 114 \n Not High 92 (83.6%) 94 (84.7%) 98 (86.0%) \n 1 8 (7.3%) 9 (8.1%) 7 (6.1%) \n 2 2 (1.8%) 5 (4.5%) 6 (5.3%) \n 3 5 (4.5%) 2 (1.8%) 3 (2.6%) \n 4 3 (2.7%) 1 (0.9%) 0 \n 1 (n) 7 8 7 \n Not High 7 (100%) 5 (62.5%) 6 (85.7%) \n 1 0 1 (12.5%) 0 \n 2 0 1 (12.5%) 1 (14.3%) \n 3 0 1 (12.5%) 0 \n 2 (n) 9 7 5 \n Not High 9 (100%) 6 (85.7%) 5 (100%) \n 3 0 1 (14.3%) 0 \n 3 (n) 6 3 4 \n Not High 5 (83.3%) 2 (66.7%) 4 (100%) \n 3 1 (16.7%) 0 0 \n 4 0 1 (33.3%) 0 \n 4 (n) 2 5 2 \n Not High 1 (50.0%) 5 (100%) 2 (100%) \n 3 1 (50.0%) 0 0 \n WEEK 4 DAY 29 \n Not High (n) 115 117 113 \n Not High 97 (84.3%) 101 (86.3%) 99 (87.6%) \n 1 8 (7.0%) 7 (6.0%) 6 (5.3%) \n 2 2 (1.7%) 6 (5.1%) 5 (4.4%) \n 3 7 (6.1%) 3 (2.6%) 3 (2.7%) \n 4 1 (0.9%) 0 0 \n 1 (n) 4 3 11 \n Not High 4 (100%) 2 (66.7%) 10 (90.9%) \n 2 0 0 1 (9.1%) \n 4 0 1 (33.3%) 0 \n 2 (n) 6 4 2 \n Not High 6 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n 3 (n) 6 7 4 \n Not High 5 (83.3%) 4 (57.1%) 4 (100%) \n 1 0 1 (14.3%) 0 \n 3 0 1 (14.3%) 0 \n 4 1 (16.7%) 1 (14.3%) 0 \n 4 (n) 3 3 2 \n Not High 2 (66.7%) 2 (66.7%) 0 \n 1 0 1 (33.3%) 1 (50.0%) \n 2 0 0 1 (50.0%) \n 4 1 (33.3%) 0 0 \n WEEK 5 DAY 36 \n Not High (n) 111 111 119 \n Not High 95 (85.6%) 95 (85.6%) 104 (87.4%) \n 1 6 (5.4%) 8 (7.2%) 6 (5.0%) \n 2 1 (0.9%) 5 (4.5%) 6 (5.0%) \n 3 6 (5.4%) 2 (1.8%) 3 (2.5%) \n 4 3 (2.7%) 1 (0.9%) 0 \n 1 (n) 8 11 5 \n Not High 7 (87.5%) 9 (81.8%) 4 (80.0%) \n 1 0 1 (9.1%) 0 \n 2 0 0 1 (20.0%) \n 3 1 (12.5%) 1 (9.1%) 0 \n 2 (n) 7 6 3 \n Not High 5 (71.4%) 3 (50.0%) 2 (66.7%) \n 1 1 (14.3%) 1 (16.7%) 1 (33.3%) \n 2 1 (14.3%) 1 (16.7%) 0 \n 4 0 1 (16.7%) 0 \n 3 (n) 3 3 4 \n Not High 3 (100%) 3 (100%) 4 (100%) \n 4 (n) 5 3 1 \n Not High 4 (80.0%) 2 (66.7%) 1 (100%) \n 1 1 (20.0%) 0 0 \n 3 0 1 (33.3%) 0 \n\n\n\n\nNote that missing baseline values are filtered out in the pre-processing step.\n\nCodeadlb_f <- adlb %>% filter(WGRLOVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRLOVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n filter(BTOXGR != \"<Missing>\") %>% # filter out missing baseline grade\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n ATOXGR == -1 ~ \"1\",\n ATOXGR == -2 ~ \"2\",\n ATOXGR == -3 ~ \"3\",\n ATOXGR == -4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n BTOXGR == -1 ~ \"1\",\n BTOXGR == -2 ~ \"2\",\n BTOXGR == -3 ~ \"3\",\n BTOXGR == -4 ~ \"4\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = TRUE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not Low (n) 116 110 101 \n Not Low 103 (88.8%) 91 (82.7%) 88 (87.1%) \n 1 3 (2.6%) 5 (4.5%) 6 (5.9%) \n 2 4 (3.4%) 9 (8.2%) 2 (2.0%) \n 3 3 (2.6%) 4 (3.6%) 4 (4.0%) \n 4 3 (2.6%) 1 (0.9%) 1 (1.0%) \n 1 (n) 4 7 5 \n Not Low 3 (75.0%) 7 (100%) 4 (80.0%) \n 3 1 (25.0%) 0 1 (20.0%) \n 2 (n) 5 6 11 \n Not Low 5 (100%) 5 (83.3%) 8 (72.7%) \n 1 0 0 1 (9.1%) \n 3 0 0 2 (18.2%) \n 4 0 1 (16.7%) 0 \n 3 (n) 6 8 5 \n Not Low 6 (100%) 7 (87.5%) 5 (100%) \n 3 0 1 (12.5%) 0 \n 4 (n) 3 3 10 \n Not Low 2 (66.7%) 3 (100%) 7 (70.0%) \n 1 0 0 2 (20.0%) \n 2 1 (33.3%) 0 0 \n 4 0 0 1 (10.0%) \n WEEK 2 DAY 15 \n Not Low (n) 106 111 116 \n Not Low 93 (87.7%) 93 (83.8%) 100 (86.2%) \n 1 3 (2.8%) 4 (3.6%) 8 (6.9%) \n 2 5 (4.7%) 7 (6.3%) 2 (1.7%) \n 3 2 (1.9%) 5 (4.5%) 6 (5.2%) \n 4 3 (2.8%) 2 (1.8%) 0 \n 1 (n) 15 9 2 \n Not Low 13 (86.7%) 8 (88.9%) 1 (50.0%) \n 2 0 1 (11.1%) 0 \n 3 2 (13.3%) 0 0 \n 4 0 0 1 (50.0%) \n 2 (n) 3 3 6 \n Not Low 3 (100%) 3 (100%) 4 (66.7%) \n 1 0 0 1 (16.7%) \n 3 0 0 1 (16.7%) \n 3 (n) 7 7 6 \n Not Low 7 (100%) 6 (85.7%) 5 (83.3%) \n 2 0 1 (14.3%) 0 \n 4 0 0 1 (16.7%) \n 4 (n) 3 4 2 \n Not Low 3 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n WEEK 3 DAY 22 \n Not Low (n) 119 110 114 \n Not Low 104 (87.4%) 92 (83.6%) 94 (82.5%) \n 1 3 (2.5%) 4 (3.6%) 9 (7.9%) \n 2 5 (4.2%) 7 (6.4%) 2 (1.8%) \n 3 4 (3.4%) 5 (4.5%) 7 (6.1%) \n 4 3 (2.5%) 2 (1.8%) 2 (1.8%) \n 1 (n) 9 9 6 \n Not Low 9 (100%) 7 (77.8%) 6 (100%) \n 2 0 2 (22.2%) 0 \n 2 (n) 1 7 3 \n Not Low 1 (100%) 6 (85.7%) 3 (100%) \n 1 0 1 (14.3%) 0 \n 3 (n) 4 5 4 \n Not Low 4 (100%) 5 (100%) 4 (100%) \n 4 (n) 1 3 5 \n Not Low 1 (100%) 3 (100%) 5 (100%) \n WEEK 4 DAY 29 \n Not Low (n) 101 119 111 \n Not Low 89 (88.1%) 100 (84.0%) 96 (86.5%) \n 1 3 (3.0%) 4 (3.4%) 6 (5.4%) \n 2 4 (4.0%) 8 (6.7%) 1 (0.9%) \n 3 2 (2.0%) 5 (4.2%) 6 (5.4%) \n 4 3 (3.0%) 2 (1.7%) 2 (1.8%) \n 1 (n) 10 5 6 \n Not Low 9 (90.0%) 5 (100%) 5 (83.3%) \n 1 0 0 1 (16.7%) \n 2 1 (10.0%) 0 0 \n 2 (n) 13 4 6 \n Not Low 13 (100%) 3 (75.0%) 5 (83.3%) \n 1 0 0 1 (16.7%) \n 2 0 1 (25.0%) 0 \n 3 (n) 8 2 6 \n Not Low 6 (75.0%) 1 (50.0%) 5 (83.3%) \n 1 0 1 (50.0%) 0 \n 2 0 0 1 (16.7%) \n 3 2 (25.0%) 0 0 \n 4 (n) 2 4 3 \n Not Low 2 (100%) 4 (100%) 1 (33.3%) \n 1 0 0 1 (33.3%) \n 3 0 0 1 (33.3%) \n WEEK 5 DAY 36 \n Not Low (n) 115 112 111 \n Not Low 102 (88.7%) 94 (83.9%) 96 (86.5%) \n 1 2 (1.7%) 4 (3.6%) 6 (5.4%) \n 2 5 (4.3%) 7 (6.2%) 2 (1.8%) \n 3 3 (2.6%) 5 (4.5%) 5 (4.5%) \n 4 3 (2.6%) 2 (1.8%) 2 (1.8%) \n 1 (n) 5 7 6 \n Not Low 5 (100%) 4 (57.1%) 5 (83.3%) \n 1 0 1 (14.3%) 1 (16.7%) \n 2 0 2 (28.6%) 0 \n 2 (n) 5 11 6 \n Not Low 5 (100%) 11 (100%) 6 (100%) \n 3 (n) 8 2 7 \n Not Low 6 (75.0%) 2 (100%) 4 (57.1%) \n 1 1 (12.5%) 0 1 (14.3%) \n 3 1 (12.5%) 0 2 (28.6%) \n 4 (n) 1 2 2 \n Not Low 1 (100%) 2 (100%) 1 (50.0%) \n 1 0 0 1 (50.0%) \n\n\n\n\nNote that when BTOXGR is missing, the grouping variable BTOXGR_GP is now \"Not High\" instead of \"Missing\" compared to Standard Table (High).\n\nCodeadlb_f <- adlb %>% filter(WGRHIVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRHIVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4, \"<Missing>\") ~ \"Not High\", # Missing BTOXGR now grouped to \"Not High\"\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = TRUE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not High (n) 111 110 112 \n Not High 93 (83.8%) 92 (83.6%) 98 (87.5%) \n 1 8 (7.2%) 7 (6.4%) 5 (4.5%) \n 2 2 (1.8%) 6 (5.5%) 7 (6.2%) \n 3 6 (5.4%) 3 (2.7%) 2 (1.8%) \n 4 2 (1.8%) 2 (1.8%) 0 \n 1 (n) 8 11 6 \n Not High 7 (87.5%) 11 (100%) 5 (83.3%) \n 3 1 (12.5%) 0 1 (16.7%) \n 2 (n) 6 4 5 \n Not High 6 (100%) 1 (25.0%) 4 (80.0%) \n 1 0 3 (75.0%) 1 (20.0%) \n 3 (n) 8 3 4 \n Not High 7 (87.5%) 3 (100%) 4 (100%) \n 4 1 (12.5%) 0 0 \n 4 (n) 1 6 5 \n Not High 1 (100%) 5 (83.3%) 4 (80.0%) \n 1 0 0 1 (20.0%) \n 3 0 1 (16.7%) 0 \n WEEK 2 DAY 15 \n Not High (n) 117 113 113 \n Not High 99 (84.6%) 95 (84.1%) 100 (88.5%) \n 1 7 (6.0%) 6 (5.3%) 4 (3.5%) \n 2 2 (1.7%) 6 (5.3%) 6 (5.3%) \n 3 6 (5.1%) 4 (3.5%) 3 (2.7%) \n 4 3 (2.6%) 2 (1.8%) 0 \n 1 (n) 6 9 7 \n Not High 5 (83.3%) 8 (88.9%) 6 (85.7%) \n 1 0 1 (11.1%) 0 \n 2 0 0 1 (14.3%) \n 3 1 (16.7%) 0 0 \n 2 (n) 4 4 6 \n Not High 4 (100%) 4 (100%) 3 (50.0%) \n 1 0 0 3 (50.0%) \n 3 (n) 5 3 5 \n Not High 4 (80.0%) 2 (66.7%) 5 (100%) \n 1 1 (20.0%) 1 (33.3%) 0 \n 4 (n) 2 5 1 \n Not High 2 (100%) 3 (60.0%) 1 (100%) \n 1 0 2 (40.0%) 0 \n WEEK 3 DAY 22 \n Not High (n) 110 111 114 \n Not High 92 (83.6%) 94 (84.7%) 98 (86.0%) \n 1 8 (7.3%) 9 (8.1%) 7 (6.1%) \n 2 2 (1.8%) 5 (4.5%) 6 (5.3%) \n 3 5 (4.5%) 2 (1.8%) 3 (2.6%) \n 4 3 (2.7%) 1 (0.9%) 0 \n 1 (n) 7 8 7 \n Not High 7 (100%) 5 (62.5%) 6 (85.7%) \n 1 0 1 (12.5%) 0 \n 2 0 1 (12.5%) 1 (14.3%) \n 3 0 1 (12.5%) 0 \n 2 (n) 9 7 5 \n Not High 9 (100%) 6 (85.7%) 5 (100%) \n 3 0 1 (14.3%) 0 \n 3 (n) 6 3 4 \n Not High 5 (83.3%) 2 (66.7%) 4 (100%) \n 3 1 (16.7%) 0 0 \n 4 0 1 (33.3%) 0 \n 4 (n) 2 5 2 \n Not High 1 (50.0%) 5 (100%) 2 (100%) \n 3 1 (50.0%) 0 0 \n WEEK 4 DAY 29 \n Not High (n) 115 117 113 \n Not High 97 (84.3%) 101 (86.3%) 99 (87.6%) \n 1 8 (7.0%) 7 (6.0%) 6 (5.3%) \n 2 2 (1.7%) 6 (5.1%) 5 (4.4%) \n 3 7 (6.1%) 3 (2.6%) 3 (2.7%) \n 4 1 (0.9%) 0 0 \n 1 (n) 4 3 11 \n Not High 4 (100%) 2 (66.7%) 10 (90.9%) \n 2 0 0 1 (9.1%) \n 4 0 1 (33.3%) 0 \n 2 (n) 6 4 2 \n Not High 6 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n 3 (n) 6 7 4 \n Not High 5 (83.3%) 4 (57.1%) 4 (100%) \n 1 0 1 (14.3%) 0 \n 3 0 1 (14.3%) 0 \n 4 1 (16.7%) 1 (14.3%) 0 \n 4 (n) 3 3 2 \n Not High 2 (66.7%) 2 (66.7%) 0 \n 1 0 1 (33.3%) 1 (50.0%) \n 2 0 0 1 (50.0%) \n 4 1 (33.3%) 0 0 \n WEEK 5 DAY 36 \n Not High (n) 111 111 119 \n Not High 95 (85.6%) 95 (85.6%) 104 (87.4%) \n 1 6 (5.4%) 8 (7.2%) 6 (5.0%) \n 2 1 (0.9%) 5 (4.5%) 6 (5.0%) \n 3 6 (5.4%) 2 (1.8%) 3 (2.5%) \n 4 3 (2.7%) 1 (0.9%) 0 \n 1 (n) 8 11 5 \n Not High 7 (87.5%) 9 (81.8%) 4 (80.0%) \n 1 0 1 (9.1%) 0 \n 2 0 0 1 (20.0%) \n 3 1 (12.5%) 1 (9.1%) 0 \n 2 (n) 7 6 3 \n Not High 5 (71.4%) 3 (50.0%) 2 (66.7%) \n 1 1 (14.3%) 1 (16.7%) 1 (33.3%) \n 2 1 (14.3%) 1 (16.7%) 0 \n 4 0 1 (16.7%) 0 \n 3 (n) 3 3 4 \n Not High 3 (100%) 3 (100%) 4 (100%) \n 4 (n) 5 3 1 \n Not High 4 (80.0%) 2 (66.7%) 1 (100%) \n 1 1 (20.0%) 0 0 \n 3 0 1 (33.3%) 0 \n\n\n\n\nPre-processing is the same as for Standard Table (High), but in order to keep all levels, the drop argument in count_occurrences is set to FALSE.\n\nCodeadlb_f <- adlb %>% filter(WGRHIVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRHIVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = keep_split_levels(c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n label_pos = \"topleft\",\n split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = FALSE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not High (n) 111 110 112 \n Not High 93 (83.8%) 92 (83.6%) 98 (87.5%) \n 1 8 (7.2%) 7 (6.4%) 5 (4.5%) \n 2 2 (1.8%) 6 (5.5%) 7 (6.2%) \n 3 6 (5.4%) 3 (2.7%) 2 (1.8%) \n 4 2 (1.8%) 2 (1.8%) 0 \n Missing 0 0 0 \n 1 (n) 8 11 6 \n Not High 7 (87.5%) 11 (100%) 5 (83.3%) \n 1 0 0 0 \n 2 0 0 0 \n 3 1 (12.5%) 0 1 (16.7%) \n 4 0 0 0 \n Missing 0 0 0 \n 2 (n) 6 4 5 \n Not High 6 (100%) 1 (25.0%) 4 (80.0%) \n 1 0 3 (75.0%) 1 (20.0%) \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 (n) 8 3 4 \n Not High 7 (87.5%) 3 (100%) 4 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 1 (12.5%) 0 0 \n Missing 0 0 0 \n 4 (n) 1 6 5 \n Not High 1 (100%) 5 (83.3%) 4 (80.0%) \n 1 0 0 1 (20.0%) \n 2 0 0 0 \n 3 0 1 (16.7%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n WEEK 2 DAY 15 \n Not High (n) 117 113 113 \n Not High 99 (84.6%) 95 (84.1%) 100 (88.5%) \n 1 7 (6.0%) 6 (5.3%) 4 (3.5%) \n 2 2 (1.7%) 6 (5.3%) 6 (5.3%) \n 3 6 (5.1%) 4 (3.5%) 3 (2.7%) \n 4 3 (2.6%) 2 (1.8%) 0 \n Missing 0 0 0 \n 1 (n) 6 9 7 \n Not High 5 (83.3%) 8 (88.9%) 6 (85.7%) \n 1 0 1 (11.1%) 0 \n 2 0 0 1 (14.3%) \n 3 1 (16.7%) 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 (n) 4 4 6 \n Not High 4 (100%) 4 (100%) 3 (50.0%) \n 1 0 0 3 (50.0%) \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 (n) 5 3 5 \n Not High 4 (80.0%) 2 (66.7%) 5 (100%) \n 1 1 (20.0%) 1 (33.3%) 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 4 (n) 2 5 1 \n Not High 2 (100%) 3 (60.0%) 1 (100%) \n 1 0 2 (40.0%) 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n WEEK 3 DAY 22 \n Not High (n) 110 111 114 \n Not High 92 (83.6%) 94 (84.7%) 98 (86.0%) \n 1 8 (7.3%) 9 (8.1%) 7 (6.1%) \n 2 2 (1.8%) 5 (4.5%) 6 (5.3%) \n 3 5 (4.5%) 2 (1.8%) 3 (2.6%) \n 4 3 (2.7%) 1 (0.9%) 0 \n Missing 0 0 0 \n 1 (n) 7 8 7 \n Not High 7 (100%) 5 (62.5%) 6 (85.7%) \n 1 0 1 (12.5%) 0 \n 2 0 1 (12.5%) 1 (14.3%) \n 3 0 1 (12.5%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 (n) 9 7 5 \n Not High 9 (100%) 6 (85.7%) 5 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 0 1 (14.3%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 (n) 6 3 4 \n Not High 5 (83.3%) 2 (66.7%) 4 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 1 (16.7%) 0 0 \n 4 0 1 (33.3%) 0 \n Missing 0 0 0 \n 4 (n) 2 5 2 \n Not High 1 (50.0%) 5 (100%) 2 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 1 (50.0%) 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n WEEK 4 DAY 29 \n Not High (n) 115 117 113 \n Not High 97 (84.3%) 101 (86.3%) 99 (87.6%) \n 1 8 (7.0%) 7 (6.0%) 6 (5.3%) \n 2 2 (1.7%) 6 (5.1%) 5 (4.4%) \n 3 7 (6.1%) 3 (2.6%) 3 (2.7%) \n 4 1 (0.9%) 0 0 \n Missing 0 0 0 \n 1 (n) 4 3 11 \n Not High 4 (100%) 2 (66.7%) 10 (90.9%) \n 1 0 0 0 \n 2 0 0 1 (9.1%) \n 3 0 0 0 \n 4 0 1 (33.3%) 0 \n Missing 0 0 0 \n 2 (n) 6 4 2 \n Not High 6 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 (n) 6 7 4 \n Not High 5 (83.3%) 4 (57.1%) 4 (100%) \n 1 0 1 (14.3%) 0 \n 2 0 0 0 \n 3 0 1 (14.3%) 0 \n 4 1 (16.7%) 1 (14.3%) 0 \n Missing 0 0 0 \n 4 (n) 3 3 2 \n Not High 2 (66.7%) 2 (66.7%) 0 \n 1 0 1 (33.3%) 1 (50.0%) \n 2 0 0 1 (50.0%) \n 3 0 0 0 \n 4 1 (33.3%) 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n WEEK 5 DAY 36 \n Not High (n) 111 111 119 \n Not High 95 (85.6%) 95 (85.6%) 104 (87.4%) \n 1 6 (5.4%) 8 (7.2%) 6 (5.0%) \n 2 1 (0.9%) 5 (4.5%) 6 (5.0%) \n 3 6 (5.4%) 2 (1.8%) 3 (2.5%) \n 4 3 (2.7%) 1 (0.9%) 0 \n Missing 0 0 0 \n 1 (n) 8 11 5 \n Not High 7 (87.5%) 9 (81.8%) 4 (80.0%) \n 1 0 1 (9.1%) 0 \n 2 0 0 1 (20.0%) \n 3 1 (12.5%) 1 (9.1%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 (n) 7 6 3 \n Not High 5 (71.4%) 3 (50.0%) 2 (66.7%) \n 1 1 (14.3%) 1 (16.7%) 1 (33.3%) \n 2 1 (14.3%) 1 (16.7%) 0 \n 3 0 0 0 \n 4 0 1 (16.7%) 0 \n Missing 0 0 0 \n 3 (n) 3 3 4 \n Not High 3 (100%) 3 (100%) 4 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 4 (n) 5 3 1 \n Not High 4 (80.0%) 2 (66.7%) 1 (100%) \n 1 1 (20.0%) 0 0 \n 2 0 0 0 \n 3 0 1 (33.3%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb,\n code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_shift_by_grade(\n label = \"Grade Laboratory Abnormality Table\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"ALT\"\n ),\n worst_flag_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"WGRLOVFL\", \"WGRLOFL\", \"WGRHIVFL\", \"WGRHIFL\")),\n selected = c(\"WGRLOVFL\")\n ),\n worst_flag_indicator = choices_selected(\n value_choices(adlb, \"WGRLOVFL\"),\n selected = \"Y\", fixed = TRUE\n ),\n anl_toxgrade_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"ATOXGR\")),\n selected = c(\"ATOXGR\"),\n fixed = TRUE\n ),\n base_toxgrade_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"BTOXGR\")),\n selected = c(\"BTOXGR\"),\n fixed = TRUE\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-08 19:30:41.5793 pid:2888 token:[] teal.modules.clinical Initializing tm_t_shift_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table (Low)\nStandard Table (High)\nTable Without Patients with Missing Baseline (Low)\nTable with Missing Baseline Considered as Grade 0 (High)\nTable with Fill-In of Grades (High)\nteal App\nReproducibility\n\n\n\nPlease note that for each variant, the adlb dataset needs to be filtered on correct flags like WGRLOVFL, WGRHIVFL, et al., otherwise the layout function will not return the correct counts. There is an option to create a record for a lab test where no record is found at that visit. If you specified add_derived_type = \"PHANTOM\" & dtype_phantom_cond, you don’t have to use the h_adsl_adlb_merge_using_worst_flag function to preprocess your adlb dataset. Otherwise please follow the pre-processing steps below before applying the layout functions.\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\nadsl <- df_explicit_na(adsl)\nadlb <- df_explicit_na(adlb)\n\n# Please note that in real clinical data, population flag like SAFFL, and parameter category like PARCAT2 needs to be\n# selected properly.\nadsl_f <- adsl %>% filter(SAFFL == \"Y\")\nadlb <- adlb %>% filter(PARAMCD == \"CRP\" & SAFFL == \"Y\")\n\n\n\n\nNote that the worst laboratory flag (below WGRLOVFL) must be selected appropriately to match the direction of abnormality (here Low). New grouping variables ATOXGR_GP and BTOXGR_GP are created to display the correct output.\n\nCodeadlb_f <- adlb %>% filter(WGRLOVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRLOVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n ATOXGR == -1 ~ \"1\",\n ATOXGR == -2 ~ \"2\",\n ATOXGR == -3 ~ \"3\",\n ATOXGR == -4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n BTOXGR == -1 ~ \"1\",\n BTOXGR == -2 ~ \"2\",\n BTOXGR == -3 ~ \"3\",\n BTOXGR == -4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = TRUE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not Low (n) 116 110 101 \n Not Low 103 (88.8%) 91 (82.7%) 88 (87.1%) \n 1 3 (2.6%) 5 (4.5%) 6 (5.9%) \n 2 4 (3.4%) 9 (8.2%) 2 (2.0%) \n 3 3 (2.6%) 4 (3.6%) 4 (4.0%) \n 4 3 (2.6%) 1 (0.9%) 1 (1.0%) \n 1 (n) 4 7 5 \n Not Low 3 (75.0%) 7 (100%) 4 (80.0%) \n 3 1 (25.0%) 0 1 (20.0%) \n 2 (n) 5 6 11 \n Not Low 5 (100%) 5 (83.3%) 8 (72.7%) \n 1 0 0 1 (9.1%) \n 3 0 0 2 (18.2%) \n 4 0 1 (16.7%) 0 \n 3 (n) 6 8 5 \n Not Low 6 (100%) 7 (87.5%) 5 (100%) \n 3 0 1 (12.5%) 0 \n 4 (n) 3 3 10 \n Not Low 2 (66.7%) 3 (100%) 7 (70.0%) \n 1 0 0 2 (20.0%) \n 2 1 (33.3%) 0 0 \n 4 0 0 1 (10.0%) \n WEEK 2 DAY 15 \n Not Low (n) 106 111 116 \n Not Low 93 (87.7%) 93 (83.8%) 100 (86.2%) \n 1 3 (2.8%) 4 (3.6%) 8 (6.9%) \n 2 5 (4.7%) 7 (6.3%) 2 (1.7%) \n 3 2 (1.9%) 5 (4.5%) 6 (5.2%) \n 4 3 (2.8%) 2 (1.8%) 0 \n 1 (n) 15 9 2 \n Not Low 13 (86.7%) 8 (88.9%) 1 (50.0%) \n 2 0 1 (11.1%) 0 \n 3 2 (13.3%) 0 0 \n 4 0 0 1 (50.0%) \n 2 (n) 3 3 6 \n Not Low 3 (100%) 3 (100%) 4 (66.7%) \n 1 0 0 1 (16.7%) \n 3 0 0 1 (16.7%) \n 3 (n) 7 7 6 \n Not Low 7 (100%) 6 (85.7%) 5 (83.3%) \n 2 0 1 (14.3%) 0 \n 4 0 0 1 (16.7%) \n 4 (n) 3 4 2 \n Not Low 3 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n WEEK 3 DAY 22 \n Not Low (n) 119 110 114 \n Not Low 104 (87.4%) 92 (83.6%) 94 (82.5%) \n 1 3 (2.5%) 4 (3.6%) 9 (7.9%) \n 2 5 (4.2%) 7 (6.4%) 2 (1.8%) \n 3 4 (3.4%) 5 (4.5%) 7 (6.1%) \n 4 3 (2.5%) 2 (1.8%) 2 (1.8%) \n 1 (n) 9 9 6 \n Not Low 9 (100%) 7 (77.8%) 6 (100%) \n 2 0 2 (22.2%) 0 \n 2 (n) 1 7 3 \n Not Low 1 (100%) 6 (85.7%) 3 (100%) \n 1 0 1 (14.3%) 0 \n 3 (n) 4 5 4 \n Not Low 4 (100%) 5 (100%) 4 (100%) \n 4 (n) 1 3 5 \n Not Low 1 (100%) 3 (100%) 5 (100%) \n WEEK 4 DAY 29 \n Not Low (n) 101 119 111 \n Not Low 89 (88.1%) 100 (84.0%) 96 (86.5%) \n 1 3 (3.0%) 4 (3.4%) 6 (5.4%) \n 2 4 (4.0%) 8 (6.7%) 1 (0.9%) \n 3 2 (2.0%) 5 (4.2%) 6 (5.4%) \n 4 3 (3.0%) 2 (1.7%) 2 (1.8%) \n 1 (n) 10 5 6 \n Not Low 9 (90.0%) 5 (100%) 5 (83.3%) \n 1 0 0 1 (16.7%) \n 2 1 (10.0%) 0 0 \n 2 (n) 13 4 6 \n Not Low 13 (100%) 3 (75.0%) 5 (83.3%) \n 1 0 0 1 (16.7%) \n 2 0 1 (25.0%) 0 \n 3 (n) 8 2 6 \n Not Low 6 (75.0%) 1 (50.0%) 5 (83.3%) \n 1 0 1 (50.0%) 0 \n 2 0 0 1 (16.7%) \n 3 2 (25.0%) 0 0 \n 4 (n) 2 4 3 \n Not Low 2 (100%) 4 (100%) 1 (33.3%) \n 1 0 0 1 (33.3%) \n 3 0 0 1 (33.3%) \n WEEK 5 DAY 36 \n Not Low (n) 115 112 111 \n Not Low 102 (88.7%) 94 (83.9%) 96 (86.5%) \n 1 2 (1.7%) 4 (3.6%) 6 (5.4%) \n 2 5 (4.3%) 7 (6.2%) 2 (1.8%) \n 3 3 (2.6%) 5 (4.5%) 5 (4.5%) \n 4 3 (2.6%) 2 (1.8%) 2 (1.8%) \n 1 (n) 5 7 6 \n Not Low 5 (100%) 4 (57.1%) 5 (83.3%) \n 1 0 1 (14.3%) 1 (16.7%) \n 2 0 2 (28.6%) 0 \n 2 (n) 5 11 6 \n Not Low 5 (100%) 11 (100%) 6 (100%) \n 3 (n) 8 2 7 \n Not Low 6 (75.0%) 2 (100%) 4 (57.1%) \n 1 1 (12.5%) 0 1 (14.3%) \n 3 1 (12.5%) 0 2 (28.6%) \n 4 (n) 1 2 2 \n Not Low 1 (100%) 2 (100%) 1 (50.0%) \n 1 0 0 1 (50.0%) \n\n\n\n\nNote that the worst laboratory flag (below WGRHIVFL) must be selected appropriately to match the direction of abnormality (here High). New grouping variables ATOXGR_GP and BTOXGR_GP are created to display the correct output.\n\nCodeadlb_f <- adlb %>% filter(WGRHIVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRHIVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = TRUE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not High (n) 111 110 112 \n Not High 93 (83.8%) 92 (83.6%) 98 (87.5%) \n 1 8 (7.2%) 7 (6.4%) 5 (4.5%) \n 2 2 (1.8%) 6 (5.5%) 7 (6.2%) \n 3 6 (5.4%) 3 (2.7%) 2 (1.8%) \n 4 2 (1.8%) 2 (1.8%) 0 \n 1 (n) 8 11 6 \n Not High 7 (87.5%) 11 (100%) 5 (83.3%) \n 3 1 (12.5%) 0 1 (16.7%) \n 2 (n) 6 4 5 \n Not High 6 (100%) 1 (25.0%) 4 (80.0%) \n 1 0 3 (75.0%) 1 (20.0%) \n 3 (n) 8 3 4 \n Not High 7 (87.5%) 3 (100%) 4 (100%) \n 4 1 (12.5%) 0 0 \n 4 (n) 1 6 5 \n Not High 1 (100%) 5 (83.3%) 4 (80.0%) \n 1 0 0 1 (20.0%) \n 3 0 1 (16.7%) 0 \n WEEK 2 DAY 15 \n Not High (n) 117 113 113 \n Not High 99 (84.6%) 95 (84.1%) 100 (88.5%) \n 1 7 (6.0%) 6 (5.3%) 4 (3.5%) \n 2 2 (1.7%) 6 (5.3%) 6 (5.3%) \n 3 6 (5.1%) 4 (3.5%) 3 (2.7%) \n 4 3 (2.6%) 2 (1.8%) 0 \n 1 (n) 6 9 7 \n Not High 5 (83.3%) 8 (88.9%) 6 (85.7%) \n 1 0 1 (11.1%) 0 \n 2 0 0 1 (14.3%) \n 3 1 (16.7%) 0 0 \n 2 (n) 4 4 6 \n Not High 4 (100%) 4 (100%) 3 (50.0%) \n 1 0 0 3 (50.0%) \n 3 (n) 5 3 5 \n Not High 4 (80.0%) 2 (66.7%) 5 (100%) \n 1 1 (20.0%) 1 (33.3%) 0 \n 4 (n) 2 5 1 \n Not High 2 (100%) 3 (60.0%) 1 (100%) \n 1 0 2 (40.0%) 0 \n WEEK 3 DAY 22 \n Not High (n) 110 111 114 \n Not High 92 (83.6%) 94 (84.7%) 98 (86.0%) \n 1 8 (7.3%) 9 (8.1%) 7 (6.1%) \n 2 2 (1.8%) 5 (4.5%) 6 (5.3%) \n 3 5 (4.5%) 2 (1.8%) 3 (2.6%) \n 4 3 (2.7%) 1 (0.9%) 0 \n 1 (n) 7 8 7 \n Not High 7 (100%) 5 (62.5%) 6 (85.7%) \n 1 0 1 (12.5%) 0 \n 2 0 1 (12.5%) 1 (14.3%) \n 3 0 1 (12.5%) 0 \n 2 (n) 9 7 5 \n Not High 9 (100%) 6 (85.7%) 5 (100%) \n 3 0 1 (14.3%) 0 \n 3 (n) 6 3 4 \n Not High 5 (83.3%) 2 (66.7%) 4 (100%) \n 3 1 (16.7%) 0 0 \n 4 0 1 (33.3%) 0 \n 4 (n) 2 5 2 \n Not High 1 (50.0%) 5 (100%) 2 (100%) \n 3 1 (50.0%) 0 0 \n WEEK 4 DAY 29 \n Not High (n) 115 117 113 \n Not High 97 (84.3%) 101 (86.3%) 99 (87.6%) \n 1 8 (7.0%) 7 (6.0%) 6 (5.3%) \n 2 2 (1.7%) 6 (5.1%) 5 (4.4%) \n 3 7 (6.1%) 3 (2.6%) 3 (2.7%) \n 4 1 (0.9%) 0 0 \n 1 (n) 4 3 11 \n Not High 4 (100%) 2 (66.7%) 10 (90.9%) \n 2 0 0 1 (9.1%) \n 4 0 1 (33.3%) 0 \n 2 (n) 6 4 2 \n Not High 6 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n 3 (n) 6 7 4 \n Not High 5 (83.3%) 4 (57.1%) 4 (100%) \n 1 0 1 (14.3%) 0 \n 3 0 1 (14.3%) 0 \n 4 1 (16.7%) 1 (14.3%) 0 \n 4 (n) 3 3 2 \n Not High 2 (66.7%) 2 (66.7%) 0 \n 1 0 1 (33.3%) 1 (50.0%) \n 2 0 0 1 (50.0%) \n 4 1 (33.3%) 0 0 \n WEEK 5 DAY 36 \n Not High (n) 111 111 119 \n Not High 95 (85.6%) 95 (85.6%) 104 (87.4%) \n 1 6 (5.4%) 8 (7.2%) 6 (5.0%) \n 2 1 (0.9%) 5 (4.5%) 6 (5.0%) \n 3 6 (5.4%) 2 (1.8%) 3 (2.5%) \n 4 3 (2.7%) 1 (0.9%) 0 \n 1 (n) 8 11 5 \n Not High 7 (87.5%) 9 (81.8%) 4 (80.0%) \n 1 0 1 (9.1%) 0 \n 2 0 0 1 (20.0%) \n 3 1 (12.5%) 1 (9.1%) 0 \n 2 (n) 7 6 3 \n Not High 5 (71.4%) 3 (50.0%) 2 (66.7%) \n 1 1 (14.3%) 1 (16.7%) 1 (33.3%) \n 2 1 (14.3%) 1 (16.7%) 0 \n 4 0 1 (16.7%) 0 \n 3 (n) 3 3 4 \n Not High 3 (100%) 3 (100%) 4 (100%) \n 4 (n) 5 3 1 \n Not High 4 (80.0%) 2 (66.7%) 1 (100%) \n 1 1 (20.0%) 0 0 \n 3 0 1 (33.3%) 0 \n\n\n\n\nNote that missing baseline values are filtered out in the pre-processing step.\n\nCodeadlb_f <- adlb %>% filter(WGRLOVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRLOVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n filter(BTOXGR != \"<Missing>\") %>% # filter out missing baseline grade\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n ATOXGR == -1 ~ \"1\",\n ATOXGR == -2 ~ \"2\",\n ATOXGR == -3 ~ \"3\",\n ATOXGR == -4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, 1, 2, 3, 4) ~ \"Not Low\",\n BTOXGR == -1 ~ \"1\",\n BTOXGR == -2 ~ \"2\",\n BTOXGR == -3 ~ \"3\",\n BTOXGR == -4 ~ \"4\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not Low\", \"1\", \"2\", \"3\", \"4\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = TRUE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not Low (n) 116 110 101 \n Not Low 103 (88.8%) 91 (82.7%) 88 (87.1%) \n 1 3 (2.6%) 5 (4.5%) 6 (5.9%) \n 2 4 (3.4%) 9 (8.2%) 2 (2.0%) \n 3 3 (2.6%) 4 (3.6%) 4 (4.0%) \n 4 3 (2.6%) 1 (0.9%) 1 (1.0%) \n 1 (n) 4 7 5 \n Not Low 3 (75.0%) 7 (100%) 4 (80.0%) \n 3 1 (25.0%) 0 1 (20.0%) \n 2 (n) 5 6 11 \n Not Low 5 (100%) 5 (83.3%) 8 (72.7%) \n 1 0 0 1 (9.1%) \n 3 0 0 2 (18.2%) \n 4 0 1 (16.7%) 0 \n 3 (n) 6 8 5 \n Not Low 6 (100%) 7 (87.5%) 5 (100%) \n 3 0 1 (12.5%) 0 \n 4 (n) 3 3 10 \n Not Low 2 (66.7%) 3 (100%) 7 (70.0%) \n 1 0 0 2 (20.0%) \n 2 1 (33.3%) 0 0 \n 4 0 0 1 (10.0%) \n WEEK 2 DAY 15 \n Not Low (n) 106 111 116 \n Not Low 93 (87.7%) 93 (83.8%) 100 (86.2%) \n 1 3 (2.8%) 4 (3.6%) 8 (6.9%) \n 2 5 (4.7%) 7 (6.3%) 2 (1.7%) \n 3 2 (1.9%) 5 (4.5%) 6 (5.2%) \n 4 3 (2.8%) 2 (1.8%) 0 \n 1 (n) 15 9 2 \n Not Low 13 (86.7%) 8 (88.9%) 1 (50.0%) \n 2 0 1 (11.1%) 0 \n 3 2 (13.3%) 0 0 \n 4 0 0 1 (50.0%) \n 2 (n) 3 3 6 \n Not Low 3 (100%) 3 (100%) 4 (66.7%) \n 1 0 0 1 (16.7%) \n 3 0 0 1 (16.7%) \n 3 (n) 7 7 6 \n Not Low 7 (100%) 6 (85.7%) 5 (83.3%) \n 2 0 1 (14.3%) 0 \n 4 0 0 1 (16.7%) \n 4 (n) 3 4 2 \n Not Low 3 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n WEEK 3 DAY 22 \n Not Low (n) 119 110 114 \n Not Low 104 (87.4%) 92 (83.6%) 94 (82.5%) \n 1 3 (2.5%) 4 (3.6%) 9 (7.9%) \n 2 5 (4.2%) 7 (6.4%) 2 (1.8%) \n 3 4 (3.4%) 5 (4.5%) 7 (6.1%) \n 4 3 (2.5%) 2 (1.8%) 2 (1.8%) \n 1 (n) 9 9 6 \n Not Low 9 (100%) 7 (77.8%) 6 (100%) \n 2 0 2 (22.2%) 0 \n 2 (n) 1 7 3 \n Not Low 1 (100%) 6 (85.7%) 3 (100%) \n 1 0 1 (14.3%) 0 \n 3 (n) 4 5 4 \n Not Low 4 (100%) 5 (100%) 4 (100%) \n 4 (n) 1 3 5 \n Not Low 1 (100%) 3 (100%) 5 (100%) \n WEEK 4 DAY 29 \n Not Low (n) 101 119 111 \n Not Low 89 (88.1%) 100 (84.0%) 96 (86.5%) \n 1 3 (3.0%) 4 (3.4%) 6 (5.4%) \n 2 4 (4.0%) 8 (6.7%) 1 (0.9%) \n 3 2 (2.0%) 5 (4.2%) 6 (5.4%) \n 4 3 (3.0%) 2 (1.7%) 2 (1.8%) \n 1 (n) 10 5 6 \n Not Low 9 (90.0%) 5 (100%) 5 (83.3%) \n 1 0 0 1 (16.7%) \n 2 1 (10.0%) 0 0 \n 2 (n) 13 4 6 \n Not Low 13 (100%) 3 (75.0%) 5 (83.3%) \n 1 0 0 1 (16.7%) \n 2 0 1 (25.0%) 0 \n 3 (n) 8 2 6 \n Not Low 6 (75.0%) 1 (50.0%) 5 (83.3%) \n 1 0 1 (50.0%) 0 \n 2 0 0 1 (16.7%) \n 3 2 (25.0%) 0 0 \n 4 (n) 2 4 3 \n Not Low 2 (100%) 4 (100%) 1 (33.3%) \n 1 0 0 1 (33.3%) \n 3 0 0 1 (33.3%) \n WEEK 5 DAY 36 \n Not Low (n) 115 112 111 \n Not Low 102 (88.7%) 94 (83.9%) 96 (86.5%) \n 1 2 (1.7%) 4 (3.6%) 6 (5.4%) \n 2 5 (4.3%) 7 (6.2%) 2 (1.8%) \n 3 3 (2.6%) 5 (4.5%) 5 (4.5%) \n 4 3 (2.6%) 2 (1.8%) 2 (1.8%) \n 1 (n) 5 7 6 \n Not Low 5 (100%) 4 (57.1%) 5 (83.3%) \n 1 0 1 (14.3%) 1 (16.7%) \n 2 0 2 (28.6%) 0 \n 2 (n) 5 11 6 \n Not Low 5 (100%) 11 (100%) 6 (100%) \n 3 (n) 8 2 7 \n Not Low 6 (75.0%) 2 (100%) 4 (57.1%) \n 1 1 (12.5%) 0 1 (14.3%) \n 3 1 (12.5%) 0 2 (28.6%) \n 4 (n) 1 2 2 \n Not Low 1 (100%) 2 (100%) 1 (50.0%) \n 1 0 0 1 (50.0%) \n\n\n\n\nNote that when BTOXGR is missing, the grouping variable BTOXGR_GP is now \"Not High\" instead of \"Missing\" compared to Standard Table (High).\n\nCodeadlb_f <- adlb %>% filter(WGRHIVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRHIVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4, \"<Missing>\") ~ \"Not High\", # Missing BTOXGR now grouped to \"Not High\"\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = TRUE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not High (n) 111 110 112 \n Not High 93 (83.8%) 92 (83.6%) 98 (87.5%) \n 1 8 (7.2%) 7 (6.4%) 5 (4.5%) \n 2 2 (1.8%) 6 (5.5%) 7 (6.2%) \n 3 6 (5.4%) 3 (2.7%) 2 (1.8%) \n 4 2 (1.8%) 2 (1.8%) 0 \n 1 (n) 8 11 6 \n Not High 7 (87.5%) 11 (100%) 5 (83.3%) \n 3 1 (12.5%) 0 1 (16.7%) \n 2 (n) 6 4 5 \n Not High 6 (100%) 1 (25.0%) 4 (80.0%) \n 1 0 3 (75.0%) 1 (20.0%) \n 3 (n) 8 3 4 \n Not High 7 (87.5%) 3 (100%) 4 (100%) \n 4 1 (12.5%) 0 0 \n 4 (n) 1 6 5 \n Not High 1 (100%) 5 (83.3%) 4 (80.0%) \n 1 0 0 1 (20.0%) \n 3 0 1 (16.7%) 0 \n WEEK 2 DAY 15 \n Not High (n) 117 113 113 \n Not High 99 (84.6%) 95 (84.1%) 100 (88.5%) \n 1 7 (6.0%) 6 (5.3%) 4 (3.5%) \n 2 2 (1.7%) 6 (5.3%) 6 (5.3%) \n 3 6 (5.1%) 4 (3.5%) 3 (2.7%) \n 4 3 (2.6%) 2 (1.8%) 0 \n 1 (n) 6 9 7 \n Not High 5 (83.3%) 8 (88.9%) 6 (85.7%) \n 1 0 1 (11.1%) 0 \n 2 0 0 1 (14.3%) \n 3 1 (16.7%) 0 0 \n 2 (n) 4 4 6 \n Not High 4 (100%) 4 (100%) 3 (50.0%) \n 1 0 0 3 (50.0%) \n 3 (n) 5 3 5 \n Not High 4 (80.0%) 2 (66.7%) 5 (100%) \n 1 1 (20.0%) 1 (33.3%) 0 \n 4 (n) 2 5 1 \n Not High 2 (100%) 3 (60.0%) 1 (100%) \n 1 0 2 (40.0%) 0 \n WEEK 3 DAY 22 \n Not High (n) 110 111 114 \n Not High 92 (83.6%) 94 (84.7%) 98 (86.0%) \n 1 8 (7.3%) 9 (8.1%) 7 (6.1%) \n 2 2 (1.8%) 5 (4.5%) 6 (5.3%) \n 3 5 (4.5%) 2 (1.8%) 3 (2.6%) \n 4 3 (2.7%) 1 (0.9%) 0 \n 1 (n) 7 8 7 \n Not High 7 (100%) 5 (62.5%) 6 (85.7%) \n 1 0 1 (12.5%) 0 \n 2 0 1 (12.5%) 1 (14.3%) \n 3 0 1 (12.5%) 0 \n 2 (n) 9 7 5 \n Not High 9 (100%) 6 (85.7%) 5 (100%) \n 3 0 1 (14.3%) 0 \n 3 (n) 6 3 4 \n Not High 5 (83.3%) 2 (66.7%) 4 (100%) \n 3 1 (16.7%) 0 0 \n 4 0 1 (33.3%) 0 \n 4 (n) 2 5 2 \n Not High 1 (50.0%) 5 (100%) 2 (100%) \n 3 1 (50.0%) 0 0 \n WEEK 4 DAY 29 \n Not High (n) 115 117 113 \n Not High 97 (84.3%) 101 (86.3%) 99 (87.6%) \n 1 8 (7.0%) 7 (6.0%) 6 (5.3%) \n 2 2 (1.7%) 6 (5.1%) 5 (4.4%) \n 3 7 (6.1%) 3 (2.6%) 3 (2.7%) \n 4 1 (0.9%) 0 0 \n 1 (n) 4 3 11 \n Not High 4 (100%) 2 (66.7%) 10 (90.9%) \n 2 0 0 1 (9.1%) \n 4 0 1 (33.3%) 0 \n 2 (n) 6 4 2 \n Not High 6 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n 3 (n) 6 7 4 \n Not High 5 (83.3%) 4 (57.1%) 4 (100%) \n 1 0 1 (14.3%) 0 \n 3 0 1 (14.3%) 0 \n 4 1 (16.7%) 1 (14.3%) 0 \n 4 (n) 3 3 2 \n Not High 2 (66.7%) 2 (66.7%) 0 \n 1 0 1 (33.3%) 1 (50.0%) \n 2 0 0 1 (50.0%) \n 4 1 (33.3%) 0 0 \n WEEK 5 DAY 36 \n Not High (n) 111 111 119 \n Not High 95 (85.6%) 95 (85.6%) 104 (87.4%) \n 1 6 (5.4%) 8 (7.2%) 6 (5.0%) \n 2 1 (0.9%) 5 (4.5%) 6 (5.0%) \n 3 6 (5.4%) 2 (1.8%) 3 (2.5%) \n 4 3 (2.7%) 1 (0.9%) 0 \n 1 (n) 8 11 5 \n Not High 7 (87.5%) 9 (81.8%) 4 (80.0%) \n 1 0 1 (9.1%) 0 \n 2 0 0 1 (20.0%) \n 3 1 (12.5%) 1 (9.1%) 0 \n 2 (n) 7 6 3 \n Not High 5 (71.4%) 3 (50.0%) 2 (66.7%) \n 1 1 (14.3%) 1 (16.7%) 1 (33.3%) \n 2 1 (14.3%) 1 (16.7%) 0 \n 4 0 1 (16.7%) 0 \n 3 (n) 3 3 4 \n Not High 3 (100%) 3 (100%) 4 (100%) \n 4 (n) 5 3 1 \n Not High 4 (80.0%) 2 (66.7%) 1 (100%) \n 1 1 (20.0%) 0 0 \n 3 0 1 (33.3%) 0 \n\n\n\n\nPre-processing is the same as for Standard Table (High), but in order to keep all levels, the drop argument in count_occurrences is set to FALSE.\n\nCodeadlb_f <- adlb %>% filter(WGRHIVFL == \"Y\")\n\n# Please note the step below can be skipped if you are using DTYPE PHANTOM\nadlb_out <- adsl_f %>%\n h_adsl_adlb_merge_using_worst_flag(\n adlb_f,\n worst_flag = c(\"WGRHIVFL\" = \"Y\"),\n by_visit = TRUE,\n no_fillin_visits = c(\"SCREENING\", \"BASELINE\", \"UNSCHEDULED\")\n )\n\n# Create new grouping variables ATOXGR_GP, BTOXGR_GP\nadlb_out <- adlb_out %>%\n mutate(\n ATOXGR_GP = case_when(\n ATOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n ATOXGR == 1 ~ \"1\",\n ATOXGR == 2 ~ \"2\",\n ATOXGR == 3 ~ \"3\",\n ATOXGR == 4 ~ \"4\",\n ATOXGR == \"<Missing>\" ~ \"Missing\"\n )\n ) %>%\n mutate(\n BTOXGR_GP = case_when(\n BTOXGR %in% c(0, -1, -2, -3, -4) ~ \"Not High\",\n BTOXGR == 1 ~ \"1\",\n BTOXGR == 2 ~ \"2\",\n BTOXGR == 3 ~ \"3\",\n BTOXGR == 4 ~ \"4\",\n BTOXGR == \"<Missing>\" ~ \"Missing\"\n )\n )\n\nadlb_out <- adlb_out %>% mutate(\n AVISIT = forcats::fct_reorder(AVISIT, AVISITN),\n ATOXGR_GP = factor(ATOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n BTOXGR_GP = factor(BTOXGR_GP, levels = c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\"))\n)\n\nadlb_out <- adlb_out %>%\n var_relabel(\n PARAMCD = \"Parameter Code\",\n AVISIT = \"Visit\",\n ATOXGR_GP = \"NCI CTCAE Grade at Visit\",\n BTOXGR_GP = \"Baseline NCI CTCAE Grade\"\n )\n\nresult <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\n \"PARAMCD\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$PARAMCD)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = drop_split_levels, label_pos = \"topleft\", split_label = obj_label(adlb_out$AVISIT)\n ) %>%\n split_rows_by(\n \"ATOXGR_GP\",\n split_fun = keep_split_levels(c(\"Not High\", \"1\", \"2\", \"3\", \"4\", \"Missing\")),\n label_pos = \"topleft\",\n split_label = obj_label(adlb_out$ATOXGR_GP)\n ) %>%\n summarize_num_patients(var = \"USUBJID\", .stats = c(\"unique_count\")) %>%\n count_occurrences(\"BTOXGR_GP\", denom = \"n\", drop = FALSE) %>%\n append_varlabels(adlb_out, \"BTOXGR_GP\", indent = 3L) %>%\n build_table(df = adlb_out, alt_counts_df = adsl_f)\n\nresult\n\nParameter Code \n Visit \n NCI CTCAE Grade at Visit A: Drug X B: Placebo C: Combination\n Baseline NCI CTCAE Grade (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————\nCRP \n WEEK 1 DAY 8 \n Not High (n) 111 110 112 \n Not High 93 (83.8%) 92 (83.6%) 98 (87.5%) \n 1 8 (7.2%) 7 (6.4%) 5 (4.5%) \n 2 2 (1.8%) 6 (5.5%) 7 (6.2%) \n 3 6 (5.4%) 3 (2.7%) 2 (1.8%) \n 4 2 (1.8%) 2 (1.8%) 0 \n Missing 0 0 0 \n 1 (n) 8 11 6 \n Not High 7 (87.5%) 11 (100%) 5 (83.3%) \n 1 0 0 0 \n 2 0 0 0 \n 3 1 (12.5%) 0 1 (16.7%) \n 4 0 0 0 \n Missing 0 0 0 \n 2 (n) 6 4 5 \n Not High 6 (100%) 1 (25.0%) 4 (80.0%) \n 1 0 3 (75.0%) 1 (20.0%) \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 (n) 8 3 4 \n Not High 7 (87.5%) 3 (100%) 4 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 1 (12.5%) 0 0 \n Missing 0 0 0 \n 4 (n) 1 6 5 \n Not High 1 (100%) 5 (83.3%) 4 (80.0%) \n 1 0 0 1 (20.0%) \n 2 0 0 0 \n 3 0 1 (16.7%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n WEEK 2 DAY 15 \n Not High (n) 117 113 113 \n Not High 99 (84.6%) 95 (84.1%) 100 (88.5%) \n 1 7 (6.0%) 6 (5.3%) 4 (3.5%) \n 2 2 (1.7%) 6 (5.3%) 6 (5.3%) \n 3 6 (5.1%) 4 (3.5%) 3 (2.7%) \n 4 3 (2.6%) 2 (1.8%) 0 \n Missing 0 0 0 \n 1 (n) 6 9 7 \n Not High 5 (83.3%) 8 (88.9%) 6 (85.7%) \n 1 0 1 (11.1%) 0 \n 2 0 0 1 (14.3%) \n 3 1 (16.7%) 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 (n) 4 4 6 \n Not High 4 (100%) 4 (100%) 3 (50.0%) \n 1 0 0 3 (50.0%) \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 (n) 5 3 5 \n Not High 4 (80.0%) 2 (66.7%) 5 (100%) \n 1 1 (20.0%) 1 (33.3%) 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 4 (n) 2 5 1 \n Not High 2 (100%) 3 (60.0%) 1 (100%) \n 1 0 2 (40.0%) 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n WEEK 3 DAY 22 \n Not High (n) 110 111 114 \n Not High 92 (83.6%) 94 (84.7%) 98 (86.0%) \n 1 8 (7.3%) 9 (8.1%) 7 (6.1%) \n 2 2 (1.8%) 5 (4.5%) 6 (5.3%) \n 3 5 (4.5%) 2 (1.8%) 3 (2.6%) \n 4 3 (2.7%) 1 (0.9%) 0 \n Missing 0 0 0 \n 1 (n) 7 8 7 \n Not High 7 (100%) 5 (62.5%) 6 (85.7%) \n 1 0 1 (12.5%) 0 \n 2 0 1 (12.5%) 1 (14.3%) \n 3 0 1 (12.5%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 (n) 9 7 5 \n Not High 9 (100%) 6 (85.7%) 5 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 0 1 (14.3%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 (n) 6 3 4 \n Not High 5 (83.3%) 2 (66.7%) 4 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 1 (16.7%) 0 0 \n 4 0 1 (33.3%) 0 \n Missing 0 0 0 \n 4 (n) 2 5 2 \n Not High 1 (50.0%) 5 (100%) 2 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 1 (50.0%) 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n WEEK 4 DAY 29 \n Not High (n) 115 117 113 \n Not High 97 (84.3%) 101 (86.3%) 99 (87.6%) \n 1 8 (7.0%) 7 (6.0%) 6 (5.3%) \n 2 2 (1.7%) 6 (5.1%) 5 (4.4%) \n 3 7 (6.1%) 3 (2.6%) 3 (2.7%) \n 4 1 (0.9%) 0 0 \n Missing 0 0 0 \n 1 (n) 4 3 11 \n Not High 4 (100%) 2 (66.7%) 10 (90.9%) \n 1 0 0 0 \n 2 0 0 1 (9.1%) \n 3 0 0 0 \n 4 0 1 (33.3%) 0 \n Missing 0 0 0 \n 2 (n) 6 4 2 \n Not High 6 (100%) 3 (75.0%) 2 (100%) \n 1 0 1 (25.0%) 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 3 (n) 6 7 4 \n Not High 5 (83.3%) 4 (57.1%) 4 (100%) \n 1 0 1 (14.3%) 0 \n 2 0 0 0 \n 3 0 1 (14.3%) 0 \n 4 1 (16.7%) 1 (14.3%) 0 \n Missing 0 0 0 \n 4 (n) 3 3 2 \n Not High 2 (66.7%) 2 (66.7%) 0 \n 1 0 1 (33.3%) 1 (50.0%) \n 2 0 0 1 (50.0%) \n 3 0 0 0 \n 4 1 (33.3%) 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n WEEK 5 DAY 36 \n Not High (n) 111 111 119 \n Not High 95 (85.6%) 95 (85.6%) 104 (87.4%) \n 1 6 (5.4%) 8 (7.2%) 6 (5.0%) \n 2 1 (0.9%) 5 (4.5%) 6 (5.0%) \n 3 6 (5.4%) 2 (1.8%) 3 (2.5%) \n 4 3 (2.7%) 1 (0.9%) 0 \n Missing 0 0 0 \n 1 (n) 8 11 5 \n Not High 7 (87.5%) 9 (81.8%) 4 (80.0%) \n 1 0 1 (9.1%) 0 \n 2 0 0 1 (20.0%) \n 3 1 (12.5%) 1 (9.1%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n 2 (n) 7 6 3 \n Not High 5 (71.4%) 3 (50.0%) 2 (66.7%) \n 1 1 (14.3%) 1 (16.7%) 1 (33.3%) \n 2 1 (14.3%) 1 (16.7%) 0 \n 3 0 0 0 \n 4 0 1 (16.7%) 0 \n Missing 0 0 0 \n 3 (n) 3 3 4 \n Not High 3 (100%) 3 (100%) 4 (100%) \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n 4 (n) 5 3 1 \n Not High 4 (80.0%) 2 (66.7%) 1 (100%) \n 1 1 (20.0%) 0 0 \n 2 0 0 0 \n 3 0 1 (33.3%) 0 \n 4 0 0 0 \n Missing 0 0 0 \n Missing (n) 0 0 0 \n Not High 0 0 0 \n 1 0 0 0 \n 2 0 0 0 \n 3 0 0 0 \n 4 0 0 0 \n Missing 0 0 0 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", adlb,\n code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_shift_by_grade(\n label = \"Grade Laboratory Abnormality Table\",\n dataname = \"ADLB\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adlb, \"PARAMCD\", \"PARAM\"),\n selected = \"ALT\"\n ),\n worst_flag_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"WGRLOVFL\", \"WGRLOFL\", \"WGRHIVFL\", \"WGRHIFL\")),\n selected = c(\"WGRLOVFL\")\n ),\n worst_flag_indicator = choices_selected(\n value_choices(adlb, \"WGRLOVFL\"),\n selected = \"Y\", fixed = TRUE\n ),\n anl_toxgrade_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"ATOXGR\")),\n selected = c(\"ATOXGR\"),\n fixed = TRUE\n ),\n base_toxgrade_var = choices_selected(\n choices = variable_choices(adlb, subset = c(\"BTOXGR\")),\n selected = c(\"BTOXGR\"),\n fixed = TRUE\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-09 17:46:59.0772 pid:2893 token:[] teal.modules.clinical Initializing tm_t_shift_by_grade\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/eudrat02.html",
@@ -578,14 +578,14 @@
"href": "tables/safety/cmt01.html",
"title": "CMT01",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Showing Medications Prior to the Start of the Study\nTable Sorted by Total Column Showing Additional “All Patients” Column\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\n# The following tables require ADCM data structure that follows the legacy concomitant medication coding. WHO coding is not used.\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\n# Below step is to set up example data based on legacy standard.\nadcm <- adcm %>%\n select(-starts_with(\"ATC\")) %>%\n unique()\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm_con <- adcm %>%\n filter(ATIREL == \"CONCOMITANT\")\n\nadcm_prior <- adcm %>%\n filter(ATIREL == \"PRIOR\")\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\"CMCLAS\",\n split_fun = split_fun,\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = 1L,\n label_pos = \"topleft\",\n split_label = obj_label(adcm_con$CMCLAS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm_con, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm_con,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"CMCLAS\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedication Class A: Drug X B: Placebo C: Combination\n Standardized Medication Name (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \n medcl A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \n medcl B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \n medcl C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\"CMCLAS\",\n split_fun = split_fun,\n child_labels = \"visible\",\n nested = FALSE,\n label_pos = \"topleft\",\n split_label = obj_label(adcm_con$CMCLAS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm_prior, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm_prior,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"CMCLAS\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedication Class A: Drug X B: Placebo C: Combination\n Standardized Medication Name (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 89 (66.4%) 95 (70.9%) 106 (80.3%) \nTotal number of treatments 194 208 243 \nmedcl A \n Total number of patients with at least one treatment 54 (40.3%) 49 (36.6%) 69 (52.3%) \n Total number of treatments 71 70 99 \n medname A_1/3 54 (40.3%) 49 (36.6%) 69 (52.3%) \nmedcl B \n Total number of patients with at least one treatment 76 (56.7%) 80 (59.7%) 81 (61.4%) \n Total number of treatments 123 138 144 \n medname B_2/4 52 (38.8%) 55 (41.0%) 56 (42.4%) \n medname B_3/4 47 (35.1%) 47 (35.1%) 52 (39.4%) \n\n\nTable with Subtotal Per Medication Class Suppressed\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\"CMCLAS\",\n split_fun = split_fun, child_labels = \"visible\",\n nested = FALSE,\n label_pos = \"topleft\",\n split_label = obj_label(adcm_con$CMCLAS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .labels = c(unique = \"Total number of patients with at least one treatment\"),\n .stats = \"unique\"\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm_con, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm_con,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"CMCLAS\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedication Class A: Drug X B: Placebo C: Combination\n Standardized Medication Name (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nmedcl A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nmedcl B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nmedcl C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n add_overall_col(\"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n \"Total number of patients with at least one treatment (%)\",\n \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"CMCLAS\",\n split_fun = split_fun,\n child_labels = \"visible\",\n nested = FALSE,\n label_pos = \"topleft\",\n split_label = obj_label(adcm_con$CMCLAS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n \"Total number of patients with at least one treatment (%)\",\n \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm_con, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm_con,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"CMCLAS\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"CMCLAS\"),\n scorefun = cont_n_allcols,\n decreasing = TRUE\n )\n\nresult\n\nMedication Class A: Drug X B: Placebo C: Combination All Patients\n Standardized Medication Name (N=134) (N=134) (N=132) (N=400) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment (%) 117 (87.3%) 116 (86.6%) 116 (87.9%) 349 (87.2%) \nTotal number of treatments 415 414 460 1289 \nmedcl C \n Total number of patients with at least one treatment (%) 82 (61.2%) 84 (62.7%) 89 (67.4%) 255 (63.7%) \n Total number of treatments 140 140 155 435 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%) \nmedcl B \n Total number of patients with at least one treatment (%) 83 (61.9%) 74 (55.2%) 88 (66.7%) 245 (61.3%) \n Total number of treatments 141 137 162 440 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%) \nmedcl A \n Total number of patients with at least one treatment (%) 75 (56.0%) 79 (59.0%) 81 (61.4%) 235 (58.8%) \n Total number of treatments 134 137 143 414 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%) \n\n\n\n\nHere, adcm is processed to keep only one path per treatment.\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm <- adcm %>%\n group_by(STUDYID, USUBJID, CMDECOD) %>%\n slice(1) %>%\n ungroup()\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\n \"ADCM\",\n adcm,\n code = 'ADCM <- df_explicit_na(\n synthetic_cdisc_dataset(\"latest\", \"adcm\")\n ) %>%\n group_by(STUDYID, USUBJID, CMDECOD) %>%\n slice(1) %>%\n ungroup',\n keys = c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"CMSEQ\", \"CMDECOD\")\n )\n ),\n modules = modules(\n tm_t_events(\n label = \"Concomitant Medication Table\",\n dataname = \"ADCM\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adcm, \"CMDECOD\"),\n selected = \"CMDECOD\"\n ),\n hlt = choices_selected(\n choices = variable_choices(adcm, \"CMCLAS\"),\n selected = c(\"CMCLAS\")\n ),\n add_total = TRUE,\n event_type = \"treatment\"\n )\n )\n)\n\n[INFO] 2023-09-08 19:32:23.3814 pid:3233 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Showing Medications Prior to the Start of the Study\nTable Sorted by Total Column Showing Additional “All Patients” Column\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\n# The following tables require ADCM data structure that follows the legacy concomitant medication coding. WHO coding is not used.\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\n# Below step is to set up example data based on legacy standard.\nadcm <- adcm %>%\n select(-starts_with(\"ATC\")) %>%\n unique()\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm_con <- adcm %>%\n filter(ATIREL == \"CONCOMITANT\")\n\nadcm_prior <- adcm %>%\n filter(ATIREL == \"PRIOR\")\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\"CMCLAS\",\n split_fun = split_fun,\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = 1L,\n label_pos = \"topleft\",\n split_label = obj_label(adcm_con$CMCLAS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm_con, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm_con,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"CMCLAS\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedication Class A: Drug X B: Placebo C: Combination\n Standardized Medication Name (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \n medcl A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n Total number of treatments 134 137 143 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \n medcl B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n Total number of treatments 141 137 162 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \n medcl C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n Total number of treatments 140 140 155 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\"CMCLAS\",\n split_fun = split_fun,\n child_labels = \"visible\",\n nested = FALSE,\n label_pos = \"topleft\",\n split_label = obj_label(adcm_con$CMCLAS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm_prior, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm_prior,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"CMCLAS\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedication Class A: Drug X B: Placebo C: Combination\n Standardized Medication Name (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 89 (66.4%) 95 (70.9%) 106 (80.3%) \nTotal number of treatments 194 208 243 \nmedcl A \n Total number of patients with at least one treatment 54 (40.3%) 49 (36.6%) 69 (52.3%) \n Total number of treatments 71 70 99 \n medname A_1/3 54 (40.3%) 49 (36.6%) 69 (52.3%) \nmedcl B \n Total number of patients with at least one treatment 76 (56.7%) 80 (59.7%) 81 (61.4%) \n Total number of treatments 123 138 144 \n medname B_2/4 52 (38.8%) 55 (41.0%) 56 (42.4%) \n medname B_3/4 47 (35.1%) 47 (35.1%) 52 (39.4%) \n\n\nTable with Subtotal Per Medication Class Suppressed\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\"CMCLAS\",\n split_fun = split_fun, child_labels = \"visible\",\n nested = FALSE,\n label_pos = \"topleft\",\n split_label = obj_label(adcm_con$CMCLAS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .labels = c(unique = \"Total number of patients with at least one treatment\"),\n .stats = \"unique\"\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm_con, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm_con,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"CMCLAS\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedication Class A: Drug X B: Placebo C: Combination\n Standardized Medication Name (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) \nTotal number of treatments 415 414 460 \nmedcl A \n Total number of patients with at least one treatment 75 (56.0%) 79 (59.0%) 81 (61.4%) \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) \nmedcl B \n Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) \nmedcl C \n Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n add_overall_col(\"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n \"Total number of patients with at least one treatment (%)\",\n \"Total number of treatments\"\n )\n ) %>%\n split_rows_by(\n \"CMCLAS\",\n split_fun = split_fun,\n child_labels = \"visible\",\n nested = FALSE,\n label_pos = \"topleft\",\n split_label = obj_label(adcm_con$CMCLAS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n \"Total number of patients with at least one treatment (%)\",\n \"Total number of treatments\"\n )\n ) %>%\n count_occurrences(vars = \"CMDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adcm_con, \"CMDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adcm_con,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"CMCLAS\", \"*\", \"CMDECOD\"),\n scorefun = score_occurrences,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"CMCLAS\"),\n scorefun = cont_n_allcols,\n decreasing = TRUE\n )\n\nresult\n\nMedication Class A: Drug X B: Placebo C: Combination All Patients\n Standardized Medication Name (N=134) (N=134) (N=132) (N=400) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment (%) 117 (87.3%) 116 (86.6%) 116 (87.9%) 349 (87.2%) \nTotal number of treatments 415 414 460 1289 \nmedcl C \n Total number of patients with at least one treatment (%) 82 (61.2%) 84 (62.7%) 89 (67.4%) 255 (63.7%) \n Total number of treatments 140 140 155 435 \n medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%) \n medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%) \nmedcl B \n Total number of patients with at least one treatment (%) 83 (61.9%) 74 (55.2%) 88 (66.7%) 245 (61.3%) \n Total number of treatments 141 137 162 440 \n medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%) \n medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%) \nmedcl A \n Total number of patients with at least one treatment (%) 75 (56.0%) 79 (59.0%) 81 (61.4%) 235 (58.8%) \n Total number of treatments 134 137 143 414 \n medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%) \n medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%) \n\n\n\n\nHere, adcm is processed to keep only one path per treatment.\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm <- adcm %>%\n group_by(STUDYID, USUBJID, CMDECOD) %>%\n slice(1) %>%\n ungroup()\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\n \"ADCM\",\n adcm,\n code = 'ADCM <- df_explicit_na(\n synthetic_cdisc_dataset(\"latest\", \"adcm\")\n ) %>%\n group_by(STUDYID, USUBJID, CMDECOD) %>%\n slice(1) %>%\n ungroup',\n keys = c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"CMSEQ\", \"CMDECOD\")\n )\n ),\n modules = modules(\n tm_t_events(\n label = \"Concomitant Medication Table\",\n dataname = \"ADCM\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adcm, \"CMDECOD\"),\n selected = \"CMDECOD\"\n ),\n hlt = choices_selected(\n choices = variable_choices(adcm, \"CMCLAS\"),\n selected = c(\"CMCLAS\")\n ),\n add_total = TRUE,\n event_type = \"treatment\"\n )\n )\n)\n\n[INFO] 2023-09-09 17:49:04.5887 pid:3238 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/pdt01.html",
"href": "tables/safety/pdt01.html",
"title": "PDT01",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\naddv <- synthetic_cdisc_dataset(\"latest\", \"addv\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\naddv <- df_explicit_na(addv)\n\naddv <- addv %>%\n var_relabel(\n DVDECOD = \"Category\",\n DVTERM = \"Description\"\n )\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one major protocol deviation\",\n nonunique = \"Total number of major protocol deviations\"\n )\n ) %>%\n split_rows_by(\n \"DVDECOD\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(addv$DVDECOD)\n ) %>%\n count_occurrences(vars = \"DVTERM\") %>%\n append_varlabels(addv, \"DVTERM\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = addv, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(path = c(\"DVDECOD\", \"*\", \"DVTERM\"), scorefun = score_occurrences)\n\nresult\n\nCategory A: Drug X B: Placebo C: Combination\n Description (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one major protocol deviation 28 (20.9%) 22 (16.4%) 18 (13.6%) \nTotal number of major protocol deviations 49 35 35 \nEXCLUSION CRITERIA \n Active or untreated or other excluded cns metastases 2 (1.5%) 4 (3.0%) 1 (0.8%) \n Pregnancy criteria 3 (2.2%) 3 (2.2%) 1 (0.8%) \n History of other malignancies within the last 5 years 3 (2.2%) 1 (0.7%) 1 (0.8%) \n Uncontrolled concurrent condition 2 (1.5%) 0 3 (2.3%) \n Other exclusion criteria 1 (0.7%) 0 2 (1.5%) \n Received prior prohibited therapy or medication 2 (1.5%) 1 (0.7%) 0 \nINCLUSION CRITERIA \n No signed ICF at study entry 5 (3.7%) 0 6 (4.5%) \n Ineligible cancer type or current cancer stage 3 (2.2%) 2 (1.5%) 4 (3.0%) \n Inclusion lab values outside allowed limits 4 (3.0%) 1 (0.7%) 0 \n Does not meet prior therapy requirements 2 (1.5%) 1 (0.7%) 1 (0.8%) \n Inclusion-related test not done/out of window 1 (0.7%) 1 (0.7%) 0 \nMEDICATION \n Discontinued study drug for unspecified reason 3 (2.2%) 2 (1.5%) 1 (0.8%) \n Significant deviation from planned dose 3 (2.2%) 1 (0.7%) 2 (1.5%) \n Received incorrect study medication 0 3 (2.2%) 1 (0.8%) \n Received prohibited concomitant medication 1 (0.7%) 2 (1.5%) 1 (0.8%) \n Dose missed or significantly out of window 2 (1.5%) 0 1 (0.8%) \nPROCEDURAL \n Eligibility-related test not done/out of window 2 (1.5%) 4 (3.0%) 3 (2.3%) \n Omission of screening tumor assessment 4 (3.0%) 1 (0.7%) 3 (2.3%) \n Missed assessment affecting safety/study outcomes 2 (1.5%) 3 (2.2%) 1 (0.8%) \n Failure to sign updated ICF within two visits 2 (1.5%) 1 (0.7%) 1 (0.8%) \n Missed 2 or more efficacy assessments 1 (0.7%) 2 (1.5%) 0 \n Omission of complete lab panel required by protocol 0 0 1 (0.8%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\naddv <- synthetic_cdisc_dataset(\"latest\", \"addv\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\naddv <- df_explicit_na(addv)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADDV\", addv, code = 'ADDV <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"addv\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Major Protocol Deviations Table\",\n dataname = \"ADDV\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(addv, c(\"DVTERM\")),\n selected = c(\"DVTERM\")\n ),\n hlt = choices_selected(\n choices = variable_choices(addv, c(\"DVDECOD\")),\n selected = \"DVDECOD\"\n ),\n add_total = TRUE,\n event_type = \"major protocol deviation\"\n )\n )\n)\n\n[INFO] 2023-09-08 19:32:50.2711 pid:3382 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\naddv <- synthetic_cdisc_dataset(\"latest\", \"addv\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\naddv <- df_explicit_na(addv)\n\naddv <- addv %>%\n var_relabel(\n DVDECOD = \"Category\",\n DVTERM = \"Description\"\n )\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one major protocol deviation\",\n nonunique = \"Total number of major protocol deviations\"\n )\n ) %>%\n split_rows_by(\n \"DVDECOD\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(addv$DVDECOD)\n ) %>%\n count_occurrences(vars = \"DVTERM\") %>%\n append_varlabels(addv, \"DVTERM\", indent = 1L)\n\nresult <- build_table(lyt = lyt, df = addv, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(path = c(\"DVDECOD\", \"*\", \"DVTERM\"), scorefun = score_occurrences)\n\nresult\n\nCategory A: Drug X B: Placebo C: Combination\n Description (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one major protocol deviation 28 (20.9%) 22 (16.4%) 18 (13.6%) \nTotal number of major protocol deviations 49 35 35 \nEXCLUSION CRITERIA \n Active or untreated or other excluded cns metastases 2 (1.5%) 4 (3.0%) 1 (0.8%) \n Pregnancy criteria 3 (2.2%) 3 (2.2%) 1 (0.8%) \n History of other malignancies within the last 5 years 3 (2.2%) 1 (0.7%) 1 (0.8%) \n Uncontrolled concurrent condition 2 (1.5%) 0 3 (2.3%) \n Other exclusion criteria 1 (0.7%) 0 2 (1.5%) \n Received prior prohibited therapy or medication 2 (1.5%) 1 (0.7%) 0 \nINCLUSION CRITERIA \n No signed ICF at study entry 5 (3.7%) 0 6 (4.5%) \n Ineligible cancer type or current cancer stage 3 (2.2%) 2 (1.5%) 4 (3.0%) \n Inclusion lab values outside allowed limits 4 (3.0%) 1 (0.7%) 0 \n Does not meet prior therapy requirements 2 (1.5%) 1 (0.7%) 1 (0.8%) \n Inclusion-related test not done/out of window 1 (0.7%) 1 (0.7%) 0 \nMEDICATION \n Discontinued study drug for unspecified reason 3 (2.2%) 2 (1.5%) 1 (0.8%) \n Significant deviation from planned dose 3 (2.2%) 1 (0.7%) 2 (1.5%) \n Received incorrect study medication 0 3 (2.2%) 1 (0.8%) \n Received prohibited concomitant medication 1 (0.7%) 2 (1.5%) 1 (0.8%) \n Dose missed or significantly out of window 2 (1.5%) 0 1 (0.8%) \nPROCEDURAL \n Eligibility-related test not done/out of window 2 (1.5%) 4 (3.0%) 3 (2.3%) \n Omission of screening tumor assessment 4 (3.0%) 1 (0.7%) 3 (2.3%) \n Missed assessment affecting safety/study outcomes 2 (1.5%) 3 (2.2%) 1 (0.8%) \n Failure to sign updated ICF within two visits 2 (1.5%) 1 (0.7%) 1 (0.8%) \n Missed 2 or more efficacy assessments 1 (0.7%) 2 (1.5%) 0 \n Omission of complete lab panel required by protocol 0 0 1 (0.8%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\naddv <- synthetic_cdisc_dataset(\"latest\", \"addv\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\naddv <- df_explicit_na(addv)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADDV\", addv, code = 'ADDV <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"addv\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Major Protocol Deviations Table\",\n dataname = \"ADDV\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(addv, c(\"DVTERM\")),\n selected = c(\"DVTERM\")\n ),\n hlt = choices_selected(\n choices = variable_choices(addv, c(\"DVDECOD\")),\n selected = \"DVDECOD\"\n ),\n add_total = TRUE,\n event_type = \"major protocol deviation\"\n )\n )\n)\n\n[INFO] 2023-09-09 17:49:40.4804 pid:3387 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/dtht01.html",
@@ -599,7 +599,7 @@
"href": "tables/safety/egt05_qtcat.html",
"title": "EGT05_QTCAT",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\n\nadeg_labels <- var_labels(adeg)\nadeg_f <- adeg %>%\n filter(\n PARAMCD == \"QT\",\n ANL01FL == \"Y\"\n ) %>%\n mutate(\n AVALCAT1 = case_when(\n AVAL <= 450 ~ \"<=450 msec\",\n AVAL <= 480 ~ \">450 to <=480 msec\",\n AVAL <= 500 ~ \">480 to <= 500 msec\",\n AVAL > 500 ~ \">500 msec\",\n is.na(AVAL) ~ \"<Missing>\"\n ),\n CHGCAT1 = case_when(\n CHG <= 30 ~ \"<=30 msec\",\n CHG <= 60 ~ \">30 to <=60 msec\",\n CHG > 60 ~ \">60 msec\",\n is.na(CHG) ~ \"<Missing>\"\n )\n ) %>%\n mutate(\n AVALCAT1 = factor(\n AVALCAT1,\n levels = c(\n \"<=450 msec\",\n \">450 to <=480 msec\",\n \">480 to <= 500 msec\",\n \">500 msec\",\n \"<Missing>\"\n )\n ),\n CHGCAT1 = factor(\n CHGCAT1,\n levels = c(\n \"<=30 msec\",\n \">30 to <=60 msec\",\n \">60 msec\",\n \"<Missing>\"\n )\n )\n ) %>%\n var_relabel(\n AVALCAT1 = \"Value at Visit\",\n CHGCAT1 = \"Change from Baseline\"\n )\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_label = obj_label(adeg_f$PARAM),\n split_fun = split_fun,\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_label = obj_label(adeg_f$AVISIT),\n split_fun = split_fun,\n label_pos = \"topleft\"\n ) %>%\n analyze_vars(\n vars = c(\"AVALCAT1\", \"CHGCAT1\"),\n var_labels = c(\"Value at Visit\", \"Change from Baseline\")\n ) %>%\n append_topleft(\" Category\")\n\nresult <- build_table(lyt = lyt, df = adeg_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\nParameter \n Analysis Visit A: Drug X B: Placebo C: Combination\n Category (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————\nQT Duration \n BASELINE \n Value at Visit \n n 134 134 132 \n <=450 msec 115 (85.8%) 117 (87.3%) 104 (78.8%) \n >450 to <=480 msec 6 (4.5%) 10 (7.5%) 9 (6.8%) \n >480 to <= 500 msec 4 (3%) 3 (2.2%) 6 (4.5%) \n >500 msec 9 (6.7%) 4 (3%) 13 (9.8%) \n WEEK 1 DAY 8 \n Value at Visit \n n 134 134 132 \n <=450 msec 113 (84.3%) 106 (79.1%) 106 (80.3%) \n >450 to <=480 msec 10 (7.5%) 10 (7.5%) 11 (8.3%) \n >480 to <= 500 msec 4 (3%) 4 (3%) 3 (2.3%) \n >500 msec 7 (5.2%) 14 (10.4%) 12 (9.1%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 76 (56.7%) 75 (56%) 75 (56.8%) \n >30 to <=60 msec 7 (5.2%) 13 (9.7%) 11 (8.3%) \n >60 msec 51 (38.1%) 46 (34.3%) 46 (34.8%) \n WEEK 2 DAY 15 \n Value at Visit \n n 134 134 132 \n <=450 msec 111 (82.8%) 114 (85.1%) 112 (84.8%) \n >450 to <=480 msec 10 (7.5%) 9 (6.7%) 9 (6.8%) \n >480 to <= 500 msec 7 (5.2%) 2 (1.5%) 5 (3.8%) \n >500 msec 6 (4.5%) 9 (6.7%) 6 (4.5%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 71 (53%) 87 (64.9%) 89 (67.4%) \n >30 to <=60 msec 11 (8.2%) 9 (6.7%) 9 (6.8%) \n >60 msec 52 (38.8%) 38 (28.4%) 34 (25.8%) \n WEEK 3 DAY 22 \n Value at Visit \n n 134 134 132 \n <=450 msec 106 (79.1%) 112 (83.6%) 118 (89.4%) \n >450 to <=480 msec 13 (9.7%) 7 (5.2%) 3 (2.3%) \n >480 to <= 500 msec 4 (3%) 5 (3.7%) 2 (1.5%) \n >500 msec 11 (8.2%) 10 (7.5%) 9 (6.8%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 63 (47%) 80 (59.7%) 81 (61.4%) \n >30 to <=60 msec 14 (10.4%) 8 (6%) 11 (8.3%) \n >60 msec 57 (42.5%) 46 (34.3%) 40 (30.3%) \n WEEK 4 DAY 29 \n Value at Visit \n n 134 134 132 \n <=450 msec 117 (87.3%) 103 (76.9%) 114 (86.4%) \n >450 to <=480 msec 7 (5.2%) 14 (10.4%) 6 (4.5%) \n >480 to <= 500 msec 4 (3%) 7 (5.2%) 3 (2.3%) \n >500 msec 6 (4.5%) 10 (7.5%) 9 (6.8%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 79 (59%) 80 (59.7%) 79 (59.8%) \n >30 to <=60 msec 11 (8.2%) 7 (5.2%) 10 (7.6%) \n >60 msec 44 (32.8%) 47 (35.1%) 43 (32.6%) \n WEEK 5 DAY 36 \n Value at Visit \n n 134 134 132 \n <=450 msec 107 (79.9%) 117 (87.3%) 112 (84.8%) \n >450 to <=480 msec 16 (11.9%) 5 (3.7%) 13 (9.8%) \n >480 to <= 500 msec 5 (3.7%) 9 (6.7%) 3 (2.3%) \n >500 msec 6 (4.5%) 3 (2.2%) 4 (3%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 72 (53.7%) 82 (61.2%) 73 (55.3%) \n >30 to <=60 msec 10 (7.5%) 11 (8.2%) 11 (8.3%) \n >60 msec 52 (38.8%) 41 (30.6%) 48 (36.4%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\nadeg_labels <- var_labels(adeg)\n\nadeg_f <- adeg %>%\n filter(\n ANL01FL == \"Y\" # no need to filter for PARAMCD here\n ) %>%\n mutate(\n AVALCAT1 = case_when(\n AVAL <= 450 ~ \"<=450 msec\",\n AVAL <= 480 ~ \">450 to <=480 msec\",\n AVAL <= 500 ~ \">480 to <= 500 msec\",\n AVAL > 500 ~ \">500 msec\",\n is.na(AVAL) ~ \"<Missing>\"\n ),\n CHGCAT1 = case_when(\n CHG <= 30 ~ \"<=30 msec\",\n CHG <= 60 ~ \">30 to <=60 msec\",\n CHG > 60 ~ \">60 msec\",\n is.na(CHG) ~ \"<Missing>\"\n )\n ) %>%\n mutate(\n AVALCAT1 = factor(\n AVALCAT1,\n levels = c(\n \"<=450 msec\",\n \">450 to <=480 msec\",\n \">480 to <= 500 msec\",\n \">500 msec\",\n \"<Missing>\"\n )\n ),\n CHGCAT1 = factor(\n CHGCAT1,\n levels = c(\n \"<=30 msec\",\n \">30 to <=60 msec\",\n \">60 msec\",\n \"<Missing>\"\n )\n )\n )\nvar_labels(adeg_f) <- c(\n adeg_labels,\n \"AVALCAT1\" = \"Value at Visit\",\n \"CHGCAT1\" = \"Change from Baseline\"\n)\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)'\n ),\n cdisc_dataset(\"ADEG\",\n adeg_f,\n code = 'ADEG <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n ADEG <- df_explicit_na(ADEG)\n ADEG_labels <- var_labels(ADEG)\n\n ADEG <- ADEG %>%\n filter(\n ANL01FL == \"Y\"\n ) %>%\n mutate(\n AVALCAT1 = case_when(\n AVAL <= 450 ~ \"<=450 msec\",\n AVAL <= 480 ~ \">450 to <=480 msec\",\n AVAL <= 500 ~ \">480 to <= 500 msec\",\n AVAL > 500 ~ \">500 msec\",\n is.na(AVAL) ~ \"<Missing>\"),\n CHGCAT1 = case_when(\n CHG <= 30 ~ \"<=30 msec\",\n CHG <= 60 ~ \">30 to <=60 msec\",\n CHG > 60 ~ \">60 msec\",\n is.na(CHG) ~ \"<Missing>\")\n ) %>% mutate(\n AVALCAT1 = factor(\n AVALCAT1,\n levels = c(\n \"<=450 msec\",\n \">450 to <=480 msec\",\n \">480 to <= 500 msec\",\n \">500 msec\",\n \"<Missing>\"\n )\n ),\n CHGCAT1 = factor(\n CHGCAT1,\n levels = c(\n \"<=30 msec\",\n \">30 to <=60 msec\",\n \">60 msec\",\n \"<Missing>\"\n )\n )\n )\n var_labels(ADEG) <- c(\n ADEG_labels,\n \"AVALCAT1\" = \"Value at Visit\",\n \"CHGCAT1\" = \"Change from Baseline\"\n )'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"ECG Actual Values and Changes from Baseline by Visit\",\n dataname = \"ADEG\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adeg_f, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adeg_f, c(\"AVALCAT1\", \"CHGCAT1\")),\n selected = c(\"AVALCAT1\", \"CHGCAT1\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adeg_f, \"PARAMCD\", \"PARAM\"),\n selected = \"QT\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:34:34.0910 pid:3728 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\n\nadeg_labels <- var_labels(adeg)\nadeg_f <- adeg %>%\n filter(\n PARAMCD == \"QT\",\n ANL01FL == \"Y\"\n ) %>%\n mutate(\n AVALCAT1 = case_when(\n AVAL <= 450 ~ \"<=450 msec\",\n AVAL <= 480 ~ \">450 to <=480 msec\",\n AVAL <= 500 ~ \">480 to <= 500 msec\",\n AVAL > 500 ~ \">500 msec\",\n is.na(AVAL) ~ \"<Missing>\"\n ),\n CHGCAT1 = case_when(\n CHG <= 30 ~ \"<=30 msec\",\n CHG <= 60 ~ \">30 to <=60 msec\",\n CHG > 60 ~ \">60 msec\",\n is.na(CHG) ~ \"<Missing>\"\n )\n ) %>%\n mutate(\n AVALCAT1 = factor(\n AVALCAT1,\n levels = c(\n \"<=450 msec\",\n \">450 to <=480 msec\",\n \">480 to <= 500 msec\",\n \">500 msec\",\n \"<Missing>\"\n )\n ),\n CHGCAT1 = factor(\n CHGCAT1,\n levels = c(\n \"<=30 msec\",\n \">30 to <=60 msec\",\n \">60 msec\",\n \"<Missing>\"\n )\n )\n ) %>%\n var_relabel(\n AVALCAT1 = \"Value at Visit\",\n CHGCAT1 = \"Change from Baseline\"\n )\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_label = obj_label(adeg_f$PARAM),\n split_fun = split_fun,\n label_pos = \"topleft\"\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_label = obj_label(adeg_f$AVISIT),\n split_fun = split_fun,\n label_pos = \"topleft\"\n ) %>%\n analyze_vars(\n vars = c(\"AVALCAT1\", \"CHGCAT1\"),\n var_labels = c(\"Value at Visit\", \"Change from Baseline\")\n ) %>%\n append_topleft(\" Category\")\n\nresult <- build_table(lyt = lyt, df = adeg_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\nParameter \n Analysis Visit A: Drug X B: Placebo C: Combination\n Category (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————\nQT Duration \n BASELINE \n Value at Visit \n n 134 134 132 \n <=450 msec 115 (85.8%) 117 (87.3%) 104 (78.8%) \n >450 to <=480 msec 6 (4.5%) 10 (7.5%) 9 (6.8%) \n >480 to <= 500 msec 4 (3%) 3 (2.2%) 6 (4.5%) \n >500 msec 9 (6.7%) 4 (3%) 13 (9.8%) \n WEEK 1 DAY 8 \n Value at Visit \n n 134 134 132 \n <=450 msec 113 (84.3%) 106 (79.1%) 106 (80.3%) \n >450 to <=480 msec 10 (7.5%) 10 (7.5%) 11 (8.3%) \n >480 to <= 500 msec 4 (3%) 4 (3%) 3 (2.3%) \n >500 msec 7 (5.2%) 14 (10.4%) 12 (9.1%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 76 (56.7%) 75 (56%) 75 (56.8%) \n >30 to <=60 msec 7 (5.2%) 13 (9.7%) 11 (8.3%) \n >60 msec 51 (38.1%) 46 (34.3%) 46 (34.8%) \n WEEK 2 DAY 15 \n Value at Visit \n n 134 134 132 \n <=450 msec 111 (82.8%) 114 (85.1%) 112 (84.8%) \n >450 to <=480 msec 10 (7.5%) 9 (6.7%) 9 (6.8%) \n >480 to <= 500 msec 7 (5.2%) 2 (1.5%) 5 (3.8%) \n >500 msec 6 (4.5%) 9 (6.7%) 6 (4.5%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 71 (53%) 87 (64.9%) 89 (67.4%) \n >30 to <=60 msec 11 (8.2%) 9 (6.7%) 9 (6.8%) \n >60 msec 52 (38.8%) 38 (28.4%) 34 (25.8%) \n WEEK 3 DAY 22 \n Value at Visit \n n 134 134 132 \n <=450 msec 106 (79.1%) 112 (83.6%) 118 (89.4%) \n >450 to <=480 msec 13 (9.7%) 7 (5.2%) 3 (2.3%) \n >480 to <= 500 msec 4 (3%) 5 (3.7%) 2 (1.5%) \n >500 msec 11 (8.2%) 10 (7.5%) 9 (6.8%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 63 (47%) 80 (59.7%) 81 (61.4%) \n >30 to <=60 msec 14 (10.4%) 8 (6%) 11 (8.3%) \n >60 msec 57 (42.5%) 46 (34.3%) 40 (30.3%) \n WEEK 4 DAY 29 \n Value at Visit \n n 134 134 132 \n <=450 msec 117 (87.3%) 103 (76.9%) 114 (86.4%) \n >450 to <=480 msec 7 (5.2%) 14 (10.4%) 6 (4.5%) \n >480 to <= 500 msec 4 (3%) 7 (5.2%) 3 (2.3%) \n >500 msec 6 (4.5%) 10 (7.5%) 9 (6.8%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 79 (59%) 80 (59.7%) 79 (59.8%) \n >30 to <=60 msec 11 (8.2%) 7 (5.2%) 10 (7.6%) \n >60 msec 44 (32.8%) 47 (35.1%) 43 (32.6%) \n WEEK 5 DAY 36 \n Value at Visit \n n 134 134 132 \n <=450 msec 107 (79.9%) 117 (87.3%) 112 (84.8%) \n >450 to <=480 msec 16 (11.9%) 5 (3.7%) 13 (9.8%) \n >480 to <= 500 msec 5 (3.7%) 9 (6.7%) 3 (2.3%) \n >500 msec 6 (4.5%) 3 (2.2%) 4 (3%) \n Change from Baseline \n n 134 134 132 \n <=30 msec 72 (53.7%) 82 (61.2%) 73 (55.3%) \n >30 to <=60 msec 10 (7.5%) 11 (8.2%) 11 (8.3%) \n >60 msec 52 (38.8%) 41 (30.6%) 48 (36.4%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\nadeg_labels <- var_labels(adeg)\n\nadeg_f <- adeg %>%\n filter(\n ANL01FL == \"Y\" # no need to filter for PARAMCD here\n ) %>%\n mutate(\n AVALCAT1 = case_when(\n AVAL <= 450 ~ \"<=450 msec\",\n AVAL <= 480 ~ \">450 to <=480 msec\",\n AVAL <= 500 ~ \">480 to <= 500 msec\",\n AVAL > 500 ~ \">500 msec\",\n is.na(AVAL) ~ \"<Missing>\"\n ),\n CHGCAT1 = case_when(\n CHG <= 30 ~ \"<=30 msec\",\n CHG <= 60 ~ \">30 to <=60 msec\",\n CHG > 60 ~ \">60 msec\",\n is.na(CHG) ~ \"<Missing>\"\n )\n ) %>%\n mutate(\n AVALCAT1 = factor(\n AVALCAT1,\n levels = c(\n \"<=450 msec\",\n \">450 to <=480 msec\",\n \">480 to <= 500 msec\",\n \">500 msec\",\n \"<Missing>\"\n )\n ),\n CHGCAT1 = factor(\n CHGCAT1,\n levels = c(\n \"<=30 msec\",\n \">30 to <=60 msec\",\n \">60 msec\",\n \"<Missing>\"\n )\n )\n )\nvar_labels(adeg_f) <- c(\n adeg_labels,\n \"AVALCAT1\" = \"Value at Visit\",\n \"CHGCAT1\" = \"Change from Baseline\"\n)\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)'\n ),\n cdisc_dataset(\"ADEG\",\n adeg_f,\n code = 'ADEG <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n ADEG <- df_explicit_na(ADEG)\n ADEG_labels <- var_labels(ADEG)\n\n ADEG <- ADEG %>%\n filter(\n ANL01FL == \"Y\"\n ) %>%\n mutate(\n AVALCAT1 = case_when(\n AVAL <= 450 ~ \"<=450 msec\",\n AVAL <= 480 ~ \">450 to <=480 msec\",\n AVAL <= 500 ~ \">480 to <= 500 msec\",\n AVAL > 500 ~ \">500 msec\",\n is.na(AVAL) ~ \"<Missing>\"),\n CHGCAT1 = case_when(\n CHG <= 30 ~ \"<=30 msec\",\n CHG <= 60 ~ \">30 to <=60 msec\",\n CHG > 60 ~ \">60 msec\",\n is.na(CHG) ~ \"<Missing>\")\n ) %>% mutate(\n AVALCAT1 = factor(\n AVALCAT1,\n levels = c(\n \"<=450 msec\",\n \">450 to <=480 msec\",\n \">480 to <= 500 msec\",\n \">500 msec\",\n \"<Missing>\"\n )\n ),\n CHGCAT1 = factor(\n CHGCAT1,\n levels = c(\n \"<=30 msec\",\n \">30 to <=60 msec\",\n \">60 msec\",\n \"<Missing>\"\n )\n )\n )\n var_labels(ADEG) <- c(\n ADEG_labels,\n \"AVALCAT1\" = \"Value at Visit\",\n \"CHGCAT1\" = \"Change from Baseline\"\n )'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"ECG Actual Values and Changes from Baseline by Visit\",\n dataname = \"ADEG\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adeg_f, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adeg_f, c(\"AVALCAT1\", \"CHGCAT1\")),\n selected = c(\"AVALCAT1\", \"CHGCAT1\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adeg_f, \"PARAMCD\", \"PARAM\"),\n selected = \"QT\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 17:52:01.2519 pid:3732 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/egt04.html",
@@ -613,84 +613,84 @@
"href": "tables/safety/egt03.html",
"title": "EGT03",
"section": "",
- "text": "Data Setup\nTable of Baseline Versus Minimum Post-Baseline\nTable of Baseline Versus Maximum Post-Baseline\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadeg <- df_explicit_na(adeg)\n\nadeg_labels <- var_labels(adeg)\n\nadeg_f_pbmin <- subset(\n adeg,\n PARAMCD == \"HR\" & # Heart Rate\n SAFFL == \"Y\" & # \"Safety Population Flag\"\n ONTRTFL == \"Y\" & # \"On Treatment Record Flag\"\n AVISIT == \"POST-BASELINE MINIMUM\" # \"Analysis Visit\"\n)\n\nadeg_f_pbmax <- subset(\n adeg,\n PARAMCD == \"HR\" & # Heart Rate\n SAFFL == \"Y\" & # \"Safety Population Flag\"\n ONTRTFL == \"Y\" & # \"On Treatment Record Flag\"\n AVISIT == \"POST-BASELINE MAXIMUM\" # \"Analysis Visit\"\n)\n\nvar_labels(adeg_f_pbmin) <- adeg_labels\nvar_labels(adeg_f_pbmax) <- adeg_labels\n\n\n\n\nFor the EGT03 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.\n\nCodeset.seed(123, kind = \"Mersenne-Twister\")\n\nadeg_f_pbmin$BNRIND <- factor(\n adeg_f_pbmin$BNRIND,\n levels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\"),\n labels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\")\n)\nadeg_f_pbmin$ANRIND <- factor(\n adeg_f_pbmin$ANRIND,\n levels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\"),\n labels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\")\n)\n\nadeg_f_pbmin$BNRIND[sample(1:nrow(adeg_f_pbmin), size = 5)] <- \"Missing\"\nadeg_f_pbmin$ANRIND[sample(1:nrow(adeg_f_pbmin), size = 5)] <- \"Missing\"\n\nattr(adeg_f_pbmin$ANRIND, \"label\") <- \"Analysis Reference Range Indicator\"\nattr(adeg_f_pbmin$BNRIND, \"label\") <- \"Baseline Reference Range Indicator\"\n\n# Temporary solution for overarching column\nadeg_f_pbmin <- adeg_f_pbmin %>% mutate(min_label = \"Minimum Post-Baseline Assessment\")\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table() %>%\n split_cols_by(\"min_label\") %>%\n split_cols_by(\"ANRIND\") %>%\n split_rows_by(\"ARMCD\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adeg_f_pbmin$ARMCD)) %>%\n add_rowcounts() %>%\n analyze_vars(\"BNRIND\", denom = \"N_row\", .stats = \"count_fraction\") %>%\n append_varlabels(adeg_f_pbmin, c(\"BNRIND\"), indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adeg_f_pbmin\n)\n\nresult\n\nPlanned Arm Code Minimum Post-Baseline Assessment \n Baseline Reference Range Indicator LOW NORMAL HIGH Missing \n————————————————————————————————————————————————————————————————————————————————\nARM A (N=134) \n LOW 1 (0.7%) 5 (3.7%) 0 0 \n NORMAL 36 (26.9%) 83 (61.9%) 0 1 (0.7%)\n HIGH 2 (1.5%) 4 (3%) 0 0 \n Missing 1 (0.7%) 0 0 1 (0.7%)\nARM B (N=134) \n LOW 1 (0.7%) 9 (6.7%) 0 0 \n NORMAL 40 (29.9%) 75 (56%) 0 2 (1.5%)\n HIGH 1 (0.7%) 4 (3%) 0 0 \n Missing 1 (0.7%) 1 (0.7%) 0 0 \nARM C (N=132) \n LOW 4 (3%) 11 (8.3%) 0 0 \n NORMAL 31 (23.5%) 75 (56.8%) 0 0 \n HIGH 1 (0.8%) 8 (6.1%) 0 1 (0.8%)\n Missing 1 (0.8%) 0 0 0 \n\n\n\n\nFor the EGT03 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 purpose, missing data are added to the example dataset.\n\nCodeset.seed(123, kind = \"Mersenne-Twister\")\n\nadeg_f_pbmax$BNRIND <- factor(\n adeg_f_pbmax$BNRIND,\n levels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\"),\n labels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\")\n)\nadeg_f_pbmax$ANRIND <- factor(\n adeg_f_pbmax$ANRIND,\n levels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\"),\n labels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\")\n)\n\nadeg_f_pbmax$BNRIND[sample(1:nrow(adeg_f_pbmax), size = 5)] <- \"Missing\"\nadeg_f_pbmax$ANRIND[sample(1:nrow(adeg_f_pbmax), size = 5)] <- \"Missing\"\n\nattr(adeg_f_pbmax$ANRIND, \"label\") <- \"Analysis Reference Range Indicator\"\nattr(adeg_f_pbmax$BNRIND, \"label\") <- \"Baseline Reference Range Indicator\"\n\n# Temporary solution for overarching column\nadeg_f_pbmax <- adeg_f_pbmax %>% mutate(max_label = \"Maximum Post-Baseline Assessment\")\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table() %>%\n split_cols_by(\"max_label\") %>%\n split_cols_by(\"ANRIND\") %>%\n split_rows_by(\"ARMCD\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adeg_f_pbmax$ARMCD)) %>%\n add_rowcounts() %>%\n analyze_vars(\"BNRIND\", denom = \"N_row\", .stats = \"count_fraction\") %>%\n append_varlabels(adeg_f_pbmax, c(\"BNRIND\"), indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adeg_f_pbmax\n)\n\nresult\n\nPlanned Arm Code Maximum Post-Baseline Assessment \n Baseline Reference Range Indicator LOW NORMAL HIGH Missing \n————————————————————————————————————————————————————————————————————————————————\nARM A (N=134) \n LOW 0 2 (1.5%) 4 (3%) 0 \n NORMAL 0 88 (65.7%) 31 (23.1%) 1 (0.7%)\n HIGH 0 5 (3.7%) 1 (0.7%) 0 \n Missing 0 0 1 (0.7%) 1 (0.7%)\nARM B (N=134) \n LOW 0 8 (6%) 2 (1.5%) 0 \n NORMAL 0 76 (56.7%) 39 (29.1%) 2 (1.5%)\n HIGH 0 3 (2.2%) 2 (1.5%) 0 \n Missing 0 1 (0.7%) 1 (0.7%) 0 \nARM C (N=132) \n LOW 0 12 (9.1%) 3 (2.3%) 0 \n NORMAL 0 79 (59.8%) 27 (20.5%) 0 \n HIGH 0 5 (3.8%) 4 (3%) 1 (0.8%)\n Missing 0 0 1 (0.8%) 0 \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEG\", adeg, code = 'ADEG <- synthetic_cdisc_dataset(\"latest\", \"adeg\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_shift_by_arm(\n label = \"Shift by Arm Table\",\n dataname = \"ADEG\",\n arm_var = choices_selected(\n variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n paramcd = choices_selected(\n value_choices(adeg, \"PARAMCD\"),\n selected = \"HR\"\n ),\n visit_var = choices_selected(\n value_choices(adeg, \"AVISIT\"),\n selected = \"POST-BASELINE MINIMUM\"\n ),\n aval_var = choices_selected(\n variable_choices(adeg, subset = \"ANRIND\"),\n selected = \"ANRIND\", fixed = TRUE\n ),\n base_var = choices_selected(\n variable_choices(adeg, subset = \"BNRIND\"),\n selected = \"BNRIND\", fixed = TRUE\n ),\n treatment_flag_var = choices_selected(\n variable_choices(adeg, subset = \"ONTRTFL\"),\n selected = \"ONTRTFL\", fixed = TRUE\n ),\n treatment_flag = choices_selected(\n value_choices(adeg, \"ONTRTFL\"),\n selected = \"Y\", fixed = TRUE\n )\n )\n ),\n filter = list(ADSL = list(SAFFL = \"Y\"))\n)\n\n[INFO] 2023-09-08 19:36:36.8383 pid:4073 token:[] teal.modules.clinical Initializing tm_t_shift_by_arm\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nTable of Baseline Versus Minimum Post-Baseline\nTable of Baseline Versus Maximum Post-Baseline\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadeg <- df_explicit_na(adeg)\n\nadeg_labels <- var_labels(adeg)\n\nadeg_f_pbmin <- subset(\n adeg,\n PARAMCD == \"HR\" & # Heart Rate\n SAFFL == \"Y\" & # \"Safety Population Flag\"\n ONTRTFL == \"Y\" & # \"On Treatment Record Flag\"\n AVISIT == \"POST-BASELINE MINIMUM\" # \"Analysis Visit\"\n)\n\nadeg_f_pbmax <- subset(\n adeg,\n PARAMCD == \"HR\" & # Heart Rate\n SAFFL == \"Y\" & # \"Safety Population Flag\"\n ONTRTFL == \"Y\" & # \"On Treatment Record Flag\"\n AVISIT == \"POST-BASELINE MAXIMUM\" # \"Analysis Visit\"\n)\n\nvar_labels(adeg_f_pbmin) <- adeg_labels\nvar_labels(adeg_f_pbmax) <- adeg_labels\n\n\n\n\nFor the EGT03 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.\n\nCodeset.seed(123, kind = \"Mersenne-Twister\")\n\nadeg_f_pbmin$BNRIND <- factor(\n adeg_f_pbmin$BNRIND,\n levels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\"),\n labels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\")\n)\nadeg_f_pbmin$ANRIND <- factor(\n adeg_f_pbmin$ANRIND,\n levels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\"),\n labels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\")\n)\n\nadeg_f_pbmin$BNRIND[sample(1:nrow(adeg_f_pbmin), size = 5)] <- \"Missing\"\nadeg_f_pbmin$ANRIND[sample(1:nrow(adeg_f_pbmin), size = 5)] <- \"Missing\"\n\nattr(adeg_f_pbmin$ANRIND, \"label\") <- \"Analysis Reference Range Indicator\"\nattr(adeg_f_pbmin$BNRIND, \"label\") <- \"Baseline Reference Range Indicator\"\n\n# Temporary solution for overarching column\nadeg_f_pbmin <- adeg_f_pbmin %>% mutate(min_label = \"Minimum Post-Baseline Assessment\")\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table() %>%\n split_cols_by(\"min_label\") %>%\n split_cols_by(\"ANRIND\") %>%\n split_rows_by(\"ARMCD\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adeg_f_pbmin$ARMCD)) %>%\n add_rowcounts() %>%\n analyze_vars(\"BNRIND\", denom = \"N_row\", .stats = \"count_fraction\") %>%\n append_varlabels(adeg_f_pbmin, c(\"BNRIND\"), indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adeg_f_pbmin\n)\n\nresult\n\nPlanned Arm Code Minimum Post-Baseline Assessment \n Baseline Reference Range Indicator LOW NORMAL HIGH Missing \n————————————————————————————————————————————————————————————————————————————————\nARM A (N=134) \n LOW 1 (0.7%) 5 (3.7%) 0 0 \n NORMAL 36 (26.9%) 83 (61.9%) 0 1 (0.7%)\n HIGH 2 (1.5%) 4 (3%) 0 0 \n Missing 1 (0.7%) 0 0 1 (0.7%)\nARM B (N=134) \n LOW 1 (0.7%) 9 (6.7%) 0 0 \n NORMAL 40 (29.9%) 75 (56%) 0 2 (1.5%)\n HIGH 1 (0.7%) 4 (3%) 0 0 \n Missing 1 (0.7%) 1 (0.7%) 0 0 \nARM C (N=132) \n LOW 4 (3%) 11 (8.3%) 0 0 \n NORMAL 31 (23.5%) 75 (56.8%) 0 0 \n HIGH 1 (0.8%) 8 (6.1%) 0 1 (0.8%)\n Missing 1 (0.8%) 0 0 0 \n\n\n\n\nFor the EGT03 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 purpose, missing data are added to the example dataset.\n\nCodeset.seed(123, kind = \"Mersenne-Twister\")\n\nadeg_f_pbmax$BNRIND <- factor(\n adeg_f_pbmax$BNRIND,\n levels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\"),\n labels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\")\n)\nadeg_f_pbmax$ANRIND <- factor(\n adeg_f_pbmax$ANRIND,\n levels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\"),\n labels = c(\"LOW\", \"NORMAL\", \"HIGH\", \"Missing\")\n)\n\nadeg_f_pbmax$BNRIND[sample(1:nrow(adeg_f_pbmax), size = 5)] <- \"Missing\"\nadeg_f_pbmax$ANRIND[sample(1:nrow(adeg_f_pbmax), size = 5)] <- \"Missing\"\n\nattr(adeg_f_pbmax$ANRIND, \"label\") <- \"Analysis Reference Range Indicator\"\nattr(adeg_f_pbmax$BNRIND, \"label\") <- \"Baseline Reference Range Indicator\"\n\n# Temporary solution for overarching column\nadeg_f_pbmax <- adeg_f_pbmax %>% mutate(max_label = \"Maximum Post-Baseline Assessment\")\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table() %>%\n split_cols_by(\"max_label\") %>%\n split_cols_by(\"ANRIND\") %>%\n split_rows_by(\"ARMCD\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adeg_f_pbmax$ARMCD)) %>%\n add_rowcounts() %>%\n analyze_vars(\"BNRIND\", denom = \"N_row\", .stats = \"count_fraction\") %>%\n append_varlabels(adeg_f_pbmax, c(\"BNRIND\"), indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adeg_f_pbmax\n)\n\nresult\n\nPlanned Arm Code Maximum Post-Baseline Assessment \n Baseline Reference Range Indicator LOW NORMAL HIGH Missing \n————————————————————————————————————————————————————————————————————————————————\nARM A (N=134) \n LOW 0 2 (1.5%) 4 (3%) 0 \n NORMAL 0 88 (65.7%) 31 (23.1%) 1 (0.7%)\n HIGH 0 5 (3.7%) 1 (0.7%) 0 \n Missing 0 0 1 (0.7%) 1 (0.7%)\nARM B (N=134) \n LOW 0 8 (6%) 2 (1.5%) 0 \n NORMAL 0 76 (56.7%) 39 (29.1%) 2 (1.5%)\n HIGH 0 3 (2.2%) 2 (1.5%) 0 \n Missing 0 1 (0.7%) 1 (0.7%) 0 \nARM C (N=132) \n LOW 0 12 (9.1%) 3 (2.3%) 0 \n NORMAL 0 79 (59.8%) 27 (20.5%) 0 \n HIGH 0 5 (3.8%) 4 (3%) 1 (0.8%)\n Missing 0 0 1 (0.8%) 0 \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEG\", adeg, code = 'ADEG <- synthetic_cdisc_dataset(\"latest\", \"adeg\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_shift_by_arm(\n label = \"Shift by Arm Table\",\n dataname = \"ADEG\",\n arm_var = choices_selected(\n variable_choices(adsl, subset = c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n paramcd = choices_selected(\n value_choices(adeg, \"PARAMCD\"),\n selected = \"HR\"\n ),\n visit_var = choices_selected(\n value_choices(adeg, \"AVISIT\"),\n selected = \"POST-BASELINE MINIMUM\"\n ),\n aval_var = choices_selected(\n variable_choices(adeg, subset = \"ANRIND\"),\n selected = \"ANRIND\", fixed = TRUE\n ),\n base_var = choices_selected(\n variable_choices(adeg, subset = \"BNRIND\"),\n selected = \"BNRIND\", fixed = TRUE\n ),\n treatment_flag_var = choices_selected(\n variable_choices(adeg, subset = \"ONTRTFL\"),\n selected = \"ONTRTFL\", fixed = TRUE\n ),\n treatment_flag = choices_selected(\n value_choices(adeg, \"ONTRTFL\"),\n selected = \"Y\", fixed = TRUE\n )\n )\n ),\n filter = list(ADSL = list(SAFFL = \"Y\"))\n)\n\n[INFO] 2023-09-09 17:54:31.4319 pid:4078 token:[] teal.modules.clinical Initializing tm_t_shift_by_arm\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/egt01.html",
"href": "tables/safety/egt01.html",
"title": "EGT01",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\n# Data should be filtered for the studied Parameter (`PARAM`) and the\n# Analysis Visit (`AVISIT`). According to the GDSR template, the values for\n# the `AVISIT` reported in the EGT01 standard may be:\n# 'POST-BASELINE MAXIMUM', 'POST-BASELINE MINIMUM', 'POST-BASELINE LAST'.\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\n\nadeg_f <- adeg %>%\n filter(ANL01FL == \"Y\") %>%\n filter(PARAM %in% c(\"Heart Rate\", \"QT Duration\", \"RR Duration\"))\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nafun <- function(x, .var, .spl_context, ...) {\n n_fun <- sum(!is.na(x), na.rm = TRUE)\n if (n_fun == 0) {\n mean_sd_fun <- c(NA, NA)\n median_fun <- NA\n min_max_fun <- c(NA, NA)\n } else {\n mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))\n median_fun <- median(x, na.rm = TRUE)\n min_max_fun <- c(min(x), max(x))\n }\n is_chg <- .var == \"CHG\"\n is_baseline <- .spl_context$value[which(.spl_context$split == \"AVISIT\")] == \"BASELINE\"\n if (is_baseline && is_chg) n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL\n\n in_rows(\n \"n\" = n_fun,\n \"Mean (SD)\" = mean_sd_fun,\n \"Median\" = median_fun,\n \"Min - Max\" = min_max_fun,\n .formats = list(\"n\" = \"xx\", \"Mean (SD)\" = \"xx.xx (xx.xx)\", \"Median\" = \"xx.xx\", \"Min - Max\" = \"xx.xx - xx.xx\"),\n .format_na_strs = list(\"n\" = \"NE\", \"Mean (SD)\" = \"NE (NE)\", \"Median\" = \"NE\", \"Min - Max\" = \"NE - NE\")\n )\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adeg_f$PARAM)) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adeg_f$AVISIT)) %>%\n split_cols_by_multivar(\n vars = c(\"AVAL\", \"CHG\"),\n varlabels = c(\"Value at Visit\", \"Change from\\nBaseline\")\n ) %>%\n analyze_colvars(afun = afun)\n\nresult <- build_table(lyt, adeg_f, alt_counts_df = adsl)\nresult\n\nParameter A: Drug X B: Placebo C: Combination \n Analysis Visit Change from Change from Change from \n Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline \n (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nHeart Rate \n BASELINE \n n 134 134 132 \n Mean (SD) 71.45 (17.93) 69.83 (20.72) 69.34 (20.95) \n Median 72.70 73.35 71.96 \n Min - Max 9.09 - 106.91 13.49 - 115.52 11.63 - 115.49 \n WEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 70.19 (20.27) -1.26 (25.97) 69.43 (20.80) -0.40 (29.73) 68.65 (18.06) -0.69 (27.81) \n Median 70.70 -2.20 70.46 -0.52 68.57 -0.76 \n Min - Max 8.53 - 127.50 -50.97 - 89.16 16.85 - 129.14 -68.18 - 88.38 16.87 - 115.60 -68.25 - 67.20 \n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 70.32 (19.56) -1.13 (26.26) 71.11 (20.56) 1.28 (31.35) 69.19 (18.06) -0.15 (28.61) \n Median 70.88 -1.10 72.52 -0.31 69.30 -1.55 \n Min - Max 17.14 - 116.32 -85.03 - 67.52 9.22 - 120.54 -73.07 - 81.44 29.62 - 120.50 -67.75 - 66.29 \n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 68.25 (20.17) -3.20 (28.66) 68.95 (20.56) -0.88 (30.14) 70.88 (20.28) 1.54 (27.28) \n Median 68.79 -2.17 67.80 1.19 70.12 0.14 \n Min - Max 13.33 - 131.73 -81.20 - 72.57 23.98 - 130.41 -73.03 - 103.31 20.91 - 116.79 -64.51 - 72.52 \n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 70.06 (18.41) -1.38 (26.59) 71.60 (20.34) 1.77 (30.26) 71.02 (20.59) 1.68 (29.60) \n Median 69.33 -4.54 72.21 -0.88 70.52 3.81 \n Min - Max 22.30 - 116.51 -58.07 - 77.32 17.53 - 129.06 -64.32 - 85.34 10.35 - 117.30 -65.91 - 105.67 \n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 66.41 (19.74) -5.04 (27.11) 71.25 (18.92) 1.42 (27.08) 71.26 (18.56) 1.92 (29.59) \n Median 65.40 -6.83 70.86 0.64 73.29 1.74 \n Min - Max 23.89 - 110.38 -73.26 - 57.24 25.86 - 125.73 -71.15 - 67.37 23.89 - 117.19 -58.23 - 68.86 \nQT Duration \n BASELINE \n n 134 134 132 \n Mean (SD) 336.83 (117.96) 351.00 (98.44) 352.60 (105.11) \n Median 344.41 351.48 347.96 \n Min - Max 86.98 - 665.40 98.90 - 641.92 105.68 - 628.14 \n WEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 342.57 (101.09) 5.74 (159.94) 363.95 (102.34) 12.94 (140.73) 359.42 (105.16) 6.83 (147.13) \n Median 347.26 -1.78 356.54 13.73 363.84 8.69 \n Min - Max 91.63 - 591.42 -346.44 - 452.75 114.92 - 656.45 -317.53 - 416.35 51.91 - 611.88 -473.19 - 358.00 \n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 353.24 (93.93) 16.41 (162.10) 345.93 (96.78) -5.08 (152.51) 335.69 (98.61) -16.91 (138.45) \n Median 351.10 16.72 346.83 -9.68 320.96 -22.27 \n Min - Max 138.01 - 587.30 -414.07 - 389.16 146.42 - 556.07 -440.28 - 364.76 104.91 - 562.34 -326.55 - 325.27 \n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 370.12 (101.57) 33.28 (152.78) 343.41 (102.58) -7.59 (138.80) 346.95 (94.96) -5.65 (144.65) \n Median 378.21 39.59 335.12 -15.89 352.15 9.11 \n Min - Max 118.14 - 615.18 -391.72 - 520.09 63.37 - 566.51 -311.28 - 293.76 126.09 - 580.81 -412.11 - 410.01 \n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 345.77 (95.97) 8.94 (145.65) 354.38 (108.29) 3.37 (142.39) 341.36 (106.75) -11.24 (145.65) \n Median 340.13 5.58 346.70 -17.13 352.30 -11.87 \n Min - Max 110.12 - 616.58 -393.34 - 456.04 80.82 - 687.69 -439.90 - 364.80 4.95 - 570.61 -480.94 - 330.67 \n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 358.90 (97.69) 22.07 (155.68) 338.65 (99.26) -12.36 (130.46) 349.30 (95.77) -3.30 (136.00) \n Median 351.96 5.89 344.17 0.40 350.32 12.68 \n Min - Max 88.38 - 661.12 -353.30 - 539.84 31.25 - 563.90 -338.85 - 352.75 119.02 - 581.83 -311.45 - 295.53 \nRR Duration \n BASELINE \n n 134 134 132 \n Mean (SD) 1028.42 (286.38) 1027.48 (324.00) 1074.62 (277.33) \n Median 1041.86 1047.27 1080.87 \n Min - Max 34.33 - 1783.71 5.29 - 1877.19 289.60 - 1617.06 \n WEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 990.15 (318.74) -38.26 (446.40) 1061.59 (269.14) 34.10 (401.76) 1039.64 (284.39) -34.98 (406.04) \n Median 963.88 -86.50 1061.50 66.91 1014.78 -97.83 \n Min - Max 110.82 - 2014.56 -1014.82 - 1389.40 276.83 - 1711.99 -942.16 - 993.82 498.21 - 1937.47 -958.61 - 908.90 \n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 1013.37 (304.13) -15.05 (425.81) 1109.40 (318.23) 81.92 (453.11) 1045.21 (277.51) -29.41 (380.84) \n Median 1040.69 40.49 1117.76 69.27 1034.64 -15.33 \n Min - Max 164.19 - 1677.10 -1216.10 - 1053.15 160.73 - 2048.73 -1127.10 - 1148.61 252.84 - 1722.33 -859.27 - 871.54 \n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 1013.99 (304.99) -14.43 (406.53) 1118.35 (296.53) 90.86 (409.57) 1036.59 (268.52) -38.03 (421.48) \n Median 1027.23 -50.54 1134.60 52.03 1030.72 -60.72 \n Min - Max 357.04 - 1798.65 -882.94 - 1080.26 97.14 - 1825.43 -887.06 - 1166.15 446.02 - 1713.38 -984.79 - 902.37 \n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 1033.31 (313.92) 4.89 (483.15) 1079.76 (298.94) 52.28 (429.25) 1027.55 (295.86) -47.07 (378.23) \n Median 1050.40 5.60 1051.61 69.55 1023.36 -49.52 \n Min - Max 54.33 - 1979.43 -1345.93 - 1195.41 347.94 - 1762.04 -826.43 - 1191.83 341.62 - 2144.86 -1002.03 - 1048.66\n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 1072.33 (282.90) 43.92 (379.05) 1058.45 (271.01) 30.97 (436.03) 1029.04 (271.21) -45.58 (405.53) \n Median 1067.33 55.87 1068.95 33.61 1065.26 -34.40 \n Min - Max 352.97 - 2000.56 -1028.79 - 1418.57 208.83 - 1794.73 -978.97 - 1365.13 436.28 - 1794.07 -962.18 - 1329.88 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\"ADEG\",\n adeg,\n code = 'ADEG <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adeg\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"ECG Results and Change from Baseline by Visit\",\n dataname = \"ADEG\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adeg, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adeg, c(\"AVAL\", \"CHG\")),\n selected = c(\"AVAL\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adeg, \"PARAMCD\", \"PARAM\"),\n selected = \"HR\"\n ),\n parallel_vars = TRUE\n )\n ),\n filter = list(ADEG = list(AVAL = list()))\n)\n\n[INFO] 2023-09-08 19:37:41.5364 pid:4269 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\n# Data should be filtered for the studied Parameter (`PARAM`) and the\n# Analysis Visit (`AVISIT`). According to the GDSR template, the values for\n# the `AVISIT` reported in the EGT01 standard may be:\n# 'POST-BASELINE MAXIMUM', 'POST-BASELINE MINIMUM', 'POST-BASELINE LAST'.\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\n\nadeg_f <- adeg %>%\n filter(ANL01FL == \"Y\") %>%\n filter(PARAM %in% c(\"Heart Rate\", \"QT Duration\", \"RR Duration\"))\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nafun <- function(x, .var, .spl_context, ...) {\n n_fun <- sum(!is.na(x), na.rm = TRUE)\n if (n_fun == 0) {\n mean_sd_fun <- c(NA, NA)\n median_fun <- NA\n min_max_fun <- c(NA, NA)\n } else {\n mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))\n median_fun <- median(x, na.rm = TRUE)\n min_max_fun <- c(min(x), max(x))\n }\n is_chg <- .var == \"CHG\"\n is_baseline <- .spl_context$value[which(.spl_context$split == \"AVISIT\")] == \"BASELINE\"\n if (is_baseline && is_chg) n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL\n\n in_rows(\n \"n\" = n_fun,\n \"Mean (SD)\" = mean_sd_fun,\n \"Median\" = median_fun,\n \"Min - Max\" = min_max_fun,\n .formats = list(\"n\" = \"xx\", \"Mean (SD)\" = \"xx.xx (xx.xx)\", \"Median\" = \"xx.xx\", \"Min - Max\" = \"xx.xx - xx.xx\"),\n .format_na_strs = list(\"n\" = \"NE\", \"Mean (SD)\" = \"NE (NE)\", \"Median\" = \"NE\", \"Min - Max\" = \"NE - NE\")\n )\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adeg_f$PARAM)) %>%\n split_rows_by(\"AVISIT\", split_fun = split_fun, label_pos = \"topleft\", split_label = obj_label(adeg_f$AVISIT)) %>%\n split_cols_by_multivar(\n vars = c(\"AVAL\", \"CHG\"),\n varlabels = c(\"Value at Visit\", \"Change from\\nBaseline\")\n ) %>%\n analyze_colvars(afun = afun)\n\nresult <- build_table(lyt, adeg_f, alt_counts_df = adsl)\nresult\n\nParameter A: Drug X B: Placebo C: Combination \n Analysis Visit Change from Change from Change from \n Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline \n (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nHeart Rate \n BASELINE \n n 134 134 132 \n Mean (SD) 71.45 (17.93) 69.83 (20.72) 69.34 (20.95) \n Median 72.70 73.35 71.96 \n Min - Max 9.09 - 106.91 13.49 - 115.52 11.63 - 115.49 \n WEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 70.19 (20.27) -1.26 (25.97) 69.43 (20.80) -0.40 (29.73) 68.65 (18.06) -0.69 (27.81) \n Median 70.70 -2.20 70.46 -0.52 68.57 -0.76 \n Min - Max 8.53 - 127.50 -50.97 - 89.16 16.85 - 129.14 -68.18 - 88.38 16.87 - 115.60 -68.25 - 67.20 \n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 70.32 (19.56) -1.13 (26.26) 71.11 (20.56) 1.28 (31.35) 69.19 (18.06) -0.15 (28.61) \n Median 70.88 -1.10 72.52 -0.31 69.30 -1.55 \n Min - Max 17.14 - 116.32 -85.03 - 67.52 9.22 - 120.54 -73.07 - 81.44 29.62 - 120.50 -67.75 - 66.29 \n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 68.25 (20.17) -3.20 (28.66) 68.95 (20.56) -0.88 (30.14) 70.88 (20.28) 1.54 (27.28) \n Median 68.79 -2.17 67.80 1.19 70.12 0.14 \n Min - Max 13.33 - 131.73 -81.20 - 72.57 23.98 - 130.41 -73.03 - 103.31 20.91 - 116.79 -64.51 - 72.52 \n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 70.06 (18.41) -1.38 (26.59) 71.60 (20.34) 1.77 (30.26) 71.02 (20.59) 1.68 (29.60) \n Median 69.33 -4.54 72.21 -0.88 70.52 3.81 \n Min - Max 22.30 - 116.51 -58.07 - 77.32 17.53 - 129.06 -64.32 - 85.34 10.35 - 117.30 -65.91 - 105.67 \n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 66.41 (19.74) -5.04 (27.11) 71.25 (18.92) 1.42 (27.08) 71.26 (18.56) 1.92 (29.59) \n Median 65.40 -6.83 70.86 0.64 73.29 1.74 \n Min - Max 23.89 - 110.38 -73.26 - 57.24 25.86 - 125.73 -71.15 - 67.37 23.89 - 117.19 -58.23 - 68.86 \nQT Duration \n BASELINE \n n 134 134 132 \n Mean (SD) 336.83 (117.96) 351.00 (98.44) 352.60 (105.11) \n Median 344.41 351.48 347.96 \n Min - Max 86.98 - 665.40 98.90 - 641.92 105.68 - 628.14 \n WEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 342.57 (101.09) 5.74 (159.94) 363.95 (102.34) 12.94 (140.73) 359.42 (105.16) 6.83 (147.13) \n Median 347.26 -1.78 356.54 13.73 363.84 8.69 \n Min - Max 91.63 - 591.42 -346.44 - 452.75 114.92 - 656.45 -317.53 - 416.35 51.91 - 611.88 -473.19 - 358.00 \n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 353.24 (93.93) 16.41 (162.10) 345.93 (96.78) -5.08 (152.51) 335.69 (98.61) -16.91 (138.45) \n Median 351.10 16.72 346.83 -9.68 320.96 -22.27 \n Min - Max 138.01 - 587.30 -414.07 - 389.16 146.42 - 556.07 -440.28 - 364.76 104.91 - 562.34 -326.55 - 325.27 \n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 370.12 (101.57) 33.28 (152.78) 343.41 (102.58) -7.59 (138.80) 346.95 (94.96) -5.65 (144.65) \n Median 378.21 39.59 335.12 -15.89 352.15 9.11 \n Min - Max 118.14 - 615.18 -391.72 - 520.09 63.37 - 566.51 -311.28 - 293.76 126.09 - 580.81 -412.11 - 410.01 \n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 345.77 (95.97) 8.94 (145.65) 354.38 (108.29) 3.37 (142.39) 341.36 (106.75) -11.24 (145.65) \n Median 340.13 5.58 346.70 -17.13 352.30 -11.87 \n Min - Max 110.12 - 616.58 -393.34 - 456.04 80.82 - 687.69 -439.90 - 364.80 4.95 - 570.61 -480.94 - 330.67 \n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 358.90 (97.69) 22.07 (155.68) 338.65 (99.26) -12.36 (130.46) 349.30 (95.77) -3.30 (136.00) \n Median 351.96 5.89 344.17 0.40 350.32 12.68 \n Min - Max 88.38 - 661.12 -353.30 - 539.84 31.25 - 563.90 -338.85 - 352.75 119.02 - 581.83 -311.45 - 295.53 \nRR Duration \n BASELINE \n n 134 134 132 \n Mean (SD) 1028.42 (286.38) 1027.48 (324.00) 1074.62 (277.33) \n Median 1041.86 1047.27 1080.87 \n Min - Max 34.33 - 1783.71 5.29 - 1877.19 289.60 - 1617.06 \n WEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 990.15 (318.74) -38.26 (446.40) 1061.59 (269.14) 34.10 (401.76) 1039.64 (284.39) -34.98 (406.04) \n Median 963.88 -86.50 1061.50 66.91 1014.78 -97.83 \n Min - Max 110.82 - 2014.56 -1014.82 - 1389.40 276.83 - 1711.99 -942.16 - 993.82 498.21 - 1937.47 -958.61 - 908.90 \n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 1013.37 (304.13) -15.05 (425.81) 1109.40 (318.23) 81.92 (453.11) 1045.21 (277.51) -29.41 (380.84) \n Median 1040.69 40.49 1117.76 69.27 1034.64 -15.33 \n Min - Max 164.19 - 1677.10 -1216.10 - 1053.15 160.73 - 2048.73 -1127.10 - 1148.61 252.84 - 1722.33 -859.27 - 871.54 \n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 1013.99 (304.99) -14.43 (406.53) 1118.35 (296.53) 90.86 (409.57) 1036.59 (268.52) -38.03 (421.48) \n Median 1027.23 -50.54 1134.60 52.03 1030.72 -60.72 \n Min - Max 357.04 - 1798.65 -882.94 - 1080.26 97.14 - 1825.43 -887.06 - 1166.15 446.02 - 1713.38 -984.79 - 902.37 \n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 1033.31 (313.92) 4.89 (483.15) 1079.76 (298.94) 52.28 (429.25) 1027.55 (295.86) -47.07 (378.23) \n Median 1050.40 5.60 1051.61 69.55 1023.36 -49.52 \n Min - Max 54.33 - 1979.43 -1345.93 - 1195.41 347.94 - 1762.04 -826.43 - 1191.83 341.62 - 2144.86 -1002.03 - 1048.66\n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 1072.33 (282.90) 43.92 (379.05) 1058.45 (271.01) 30.97 (436.03) 1029.04 (271.21) -45.58 (405.53) \n Median 1067.33 55.87 1068.95 33.61 1065.26 -34.40 \n Min - Max 352.97 - 2000.56 -1028.79 - 1418.57 208.83 - 1794.73 -978.97 - 1365.13 436.28 - 1794.07 -962.18 - 1329.88 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadeg <- synthetic_cdisc_dataset(\"latest\", \"adeg\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadeg <- df_explicit_na(adeg)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\"ADEG\",\n adeg,\n code = 'ADEG <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adeg\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"ECG Results and Change from Baseline by Visit\",\n dataname = \"ADEG\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adeg, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adeg, c(\"AVAL\", \"CHG\")),\n selected = c(\"AVAL\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adeg, \"PARAMCD\", \"PARAM\"),\n selected = \"HR\"\n ),\n parallel_vars = TRUE\n )\n ),\n filter = list(ADEG = list(AVAL = list()))\n)\n\n[INFO] 2023-09-09 17:55:50.2122 pid:4274 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/cmt02_pt.html",
"href": "tables/safety/cmt02_pt.html",
"title": "CMT02_PT",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.factor(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\nadsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\nadcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\n\n# Keep only safety-evaluable patients and concomitant medications\nadsl <- adsl %>%\n filter(SAFFL == \"Y\")\n\n# Keep only concomitant medications\nadcm <- adcm %>% filter(ATIREL == \"CONCOMITANT\")\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"CMDECOD\") %>%\n append_topleft(paste(\"\\nOther Treatment\"))\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n sort_at_path(\n path = c(\"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\n A: Drug X B: Placebo C: Combination All Patients\nOther Treatment (N=134) (N=134) (N=132) (N=400) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) 349 (87.2%) \nTotal number of treatments 415 414 460 1289 \nmedname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%) \nmedname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%) \nmedname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%) \nmedname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%) \nmedname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%) \nmedname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.integer(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm_keys <- c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"CMSEQ\", \"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)\n '),\n cdisc_dataset(\"ADCM\", adcm,\n code = '\n ADCM <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n ADCM$CMID <- as.factor(ADCM$CMSEQ)\n ADCM <- df_explicit_na(ADCM)\n ',\n keys = adcm_keys\n )\n ),\n modules = modules(\n tm_t_mult_events(\n label = \"Concomitant Medications by Medication Class and Preferred Name\",\n dataname = \"ADCM\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n seq_var = choices_selected(\"CMSEQ\", selected = \"CMSEQ\", fixed = TRUE),\n hlt = choices_selected(\n choices = variable_choices(adcm, c(\"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")),\n selected = c(\"ATC1\")\n ),\n llt = choices_selected(\n choices = variable_choices(adcm, c(\"CMDECOD\")),\n selected = c(\"CMDECOD\")\n ),\n add_total = TRUE,\n event_type = \"treatment\"\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\"),\n ADCM = list(ATIREL = \"CONCOMITANT\")\n )\n)\n\n[INFO] 2023-09-08 19:38:17.6368 pid:4418 token:[] teal.modules.clinical Initializing tm_t_mult_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.factor(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\nadsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\nadcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\n\n# Keep only safety-evaluable patients and concomitant medications\nadsl <- adsl %>%\n filter(SAFFL == \"Y\")\n\n# Keep only concomitant medications\nadcm <- adcm %>% filter(ATIREL == \"CONCOMITANT\")\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n count_by = \"CMSEQ\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one treatment\",\n nonunique = \"Total number of treatments\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"CMDECOD\") %>%\n append_topleft(paste(\"\\nOther Treatment\"))\n\nresult <- build_table(lyt = lyt, df = adcm, alt_counts_df = adsl) %>%\n sort_at_path(\n path = c(\"CMDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\n A: Drug X B: Placebo C: Combination All Patients\nOther Treatment (N=134) (N=134) (N=132) (N=400) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) 349 (87.2%) \nTotal number of treatments 415 414 460 1289 \nmedname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%) \nmedname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%) \nmedname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%) \nmedname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%) \nmedname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%) \nmedname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadcm <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n\nadcm$CMSEQ <- as.integer(adcm$CMSEQ)\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\n# If you want your missing levels to show as \"No Coding Available\", please use\n# adsl <- df_explicit_na(adsl, na_level = \"No Coding Available\")\n# adcm <- df_explicit_na(adcm, na_level = \"No Coding Available\")\nadsl <- df_explicit_na(adsl)\nadcm <- df_explicit_na(adcm)\n\nadcm_keys <- c(\"STUDYID\", \"USUBJID\", \"ASTDTM\", \"CMSEQ\", \"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- df_explicit_na(ADSL)\n '),\n cdisc_dataset(\"ADCM\", adcm,\n code = '\n ADCM <- synthetic_cdisc_dataset(\"latest\", \"adcm\")\n ADCM$CMID <- as.factor(ADCM$CMSEQ)\n ADCM <- df_explicit_na(ADCM)\n ',\n keys = adcm_keys\n )\n ),\n modules = modules(\n tm_t_mult_events(\n label = \"Concomitant Medications by Medication Class and Preferred Name\",\n dataname = \"ADCM\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n seq_var = choices_selected(\"CMSEQ\", selected = \"CMSEQ\", fixed = TRUE),\n hlt = choices_selected(\n choices = variable_choices(adcm, c(\"ATC1\", \"ATC2\", \"ATC3\", \"ATC4\")),\n selected = c(\"ATC1\")\n ),\n llt = choices_selected(\n choices = variable_choices(adcm, c(\"CMDECOD\")),\n selected = c(\"CMDECOD\")\n ),\n add_total = TRUE,\n event_type = \"treatment\"\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\"),\n ADCM = list(ATIREL = \"CONCOMITANT\")\n )\n)\n\n[INFO] 2023-09-09 17:56:36.6978 pid:4423 token:[] teal.modules.clinical Initializing tm_t_mult_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/mht01.html",
"href": "tables/safety/mht01.html",
"title": "MHT01",
"section": "",
- "text": "Data Setup\nStandard Table\nTable of History Prior to Study\nTable with Total Number of Conditions Suppressed\nTable with Total Number of Conditions Per Body System After The Summary of Patients\nTable Showing Additional “All Patients” Column\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadmh <- synthetic_cdisc_dataset(\"latest\", \"admh\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadmh <- df_explicit_na(admh)\n\nadsl_f <- adsl %>%\n filter(SAFFL == \"Y\") %>%\n select(USUBJID, ACTARM)\n\nadmh_f <- admh %>%\n filter(SAFFL == \"Y\" & MHBODSYS != \"\" & MHDECOD != \"\") %>%\n var_relabel(\n MHBODSYS = \"MedDRA System Organ Class\",\n MHDECOD = \"MedDRA Preferred Term\"\n )\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\"Total number of patients with at least one condition\", \"Total number of conditions\")\n ) %>%\n split_rows_by(\n var = \"MHBODSYS\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(admh_f$MHBODSYS)\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\"Total number of patients with at least one condition\", \"Total number of conditions\"),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"MHDECOD\") %>%\n append_varlabels(admh_f, \"MHDECOD\", indent = 1L)\n\nresult <- build_table(lyt, admh_f, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one condition 122 (91.0%) 123 (91.8%) 120 (90.9%) \nTotal number of conditions 609 622 703 \ncl A \n Total number of patients with at least one condition 78 (58.2%) 75 (56.0%) 89 (67.4%) \n Total number of conditions 132 130 160 \n trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) \n trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) \ncl B \n Total number of patients with at least one condition 96 (71.6%) 89 (66.4%) 97 (73.5%) \n Total number of conditions 185 198 205 \n trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) \n trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) \n trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) \ncl C \n Total number of patients with at least one condition 67 (50.0%) 75 (56.0%) 79 (59.8%) \n Total number of conditions 103 116 129 \n trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) \n trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) \ncl D \n Total number of patients with at least one condition 96 (71.6%) 90 (67.2%) 98 (74.2%) \n Total number of conditions 189 178 209 \n trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) \n trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) \n trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) \n\n\n\n\n\nCodeadmh_f_prior <- admh_f %>%\n filter(ASTDY <= 0)\n\nresult <- build_table(lyt, admh_f_prior, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one condition 0 0 1 (0.8%) \nTotal number of conditions 0 0 1 \ncl D \n Total number of patients with at least one condition 0 0 1 (0.8%) \n Total number of conditions 0 0 1 \n trm D_2/3 0 0 1 (0.8%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\"Total number of patients with at least one condition\")\n ) %>%\n split_rows_by(\n var = \"MHBODSYS\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(admh_f$MHBODSYS)\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\"Total number of patients with at least one condition\"),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"MHDECOD\") %>%\n append_varlabels(admh_f, \"MHDECOD\", indent = 1L)\n\nresult <- build_table(lyt, admh_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one condition 122 (91.0%) 123 (91.8%) 120 (90.9%) \ncl A \n Total number of patients with at least one condition 78 (58.2%) 75 (56.0%) 89 (67.4%) \n trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) \n trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) \ncl B \n Total number of patients with at least one condition 96 (71.6%) 89 (66.4%) 97 (73.5%) \n trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) \n trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) \n trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) \ncl C \n Total number of patients with at least one condition 67 (50.0%) 75 (56.0%) 79 (59.8%) \n trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) \n trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) \ncl D \n Total number of patients with at least one condition 96 (71.6%) 90 (67.2%) 98 (74.2%) \n trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) \n trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) \n trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) \n\n\n\n\nNot currently supported by rtables. Users, please notify us if this variation is important to you.\n\n\nConditions are further sorted by decreasing high level terms and low level terms.\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n analyze_num_patients(\n \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(unique = \"Total number of patients with at least one event\", nonunique = \"Total number of conditions\")\n ) %>%\n split_rows_by(\n var = \"MHBODSYS\",\n split_fun = split_fun,\n child_labels = \"visible\",\n label_pos = \"topleft\",\n split_label = obj_label(admh_f$MHBODSYS)\n ) %>%\n summarize_num_patients(\n \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(unique = \"Total number of patients with at least one event\", nonunique = \"Total number of conditions\")\n ) %>%\n count_occurrences(vars = \"MHDECOD\", .indent_mods = -1L) %>%\n append_varlabels(admh_f, \"MHDECOD\", indent = 1L)\n\nscorefun_hlt <- cont_n_allcols\nscorefun_llt <- score_occurrences_cols(col_indices = nlevels(adsl_f$ACTARM) + 1)\n\nresult <- build_table(lyt, admh_f, alt_counts_df = adsl_f) %>%\n prune_table() %>%\n sort_at_path(path = c(\"MHBODSYS\"), scorefun = scorefun_hlt) %>%\n sort_at_path(path = c(\"MHBODSYS\", \"*\", \"MHDECOD\"), scorefun = scorefun_llt)\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients\n MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one event 122 (91.0%) 123 (91.8%) 120 (90.9%) 365 (91.2%) \nTotal number of conditions 609 622 703 1934 \ncl D \n Total number of patients with at least one event 96 (71.6%) 90 (67.2%) 98 (74.2%) 284 (71.0%) \n Total number of conditions 189 178 209 576 \n trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \n trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \n trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) \ncl B \n Total number of patients with at least one event 96 (71.6%) 89 (66.4%) 97 (73.5%) 282 (70.5%) \n Total number of conditions 185 198 205 588 \n trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) \n trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) \n trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \ncl A \n Total number of patients with at least one event 78 (58.2%) 75 (56.0%) 89 (67.4%) 242 (60.5%) \n Total number of conditions 132 130 160 422 \n trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) \n trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) \ncl C \n Total number of patients with at least one event 67 (50.0%) 75 (56.0%) 79 (59.8%) 221 (55.2%) \n Total number of conditions 103 116 129 348 \n trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \n trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl_f <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n filter(SAFFL == \"Y\")\nadmh_f <- synthetic_cdisc_dataset(\"latest\", \"admh\") %>%\n filter(SAFFL == \"Y\" & MHBODSYS != \"\" & MHDECOD != \"\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl_f, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n filter(SAFFL == \"Y\")'),\n cdisc_dataset(\"ADMH\", admh_f, code = 'ADMH <- synthetic_cdisc_dataset(\"latest\", \"admh\") %>%\n filter(SAFFL == \"Y\" & MHBODSYS != \"\" & MHDECOD != \"\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Medical History Table\",\n dataname = \"ADMH\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(admh_f, c(\"MHTERM\", \"MHDECOD\")),\n selected = c(\"MHDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(admh_f, c(\"MHBODSYS\", \"MHSOC\")),\n selected = \"MHBODSYS\"\n ),\n add_total = TRUE,\n event_type = \"condition\"\n )\n )\n)\n\n[INFO] 2023-09-08 19:39:23.3143 pid:4614 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable of History Prior to Study\nTable with Total Number of Conditions Suppressed\nTable with Total Number of Conditions Per Body System After The Summary of Patients\nTable Showing Additional “All Patients” Column\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadmh <- synthetic_cdisc_dataset(\"latest\", \"admh\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadmh <- df_explicit_na(admh)\n\nadsl_f <- adsl %>%\n filter(SAFFL == \"Y\") %>%\n select(USUBJID, ACTARM)\n\nadmh_f <- admh %>%\n filter(SAFFL == \"Y\" & MHBODSYS != \"\" & MHDECOD != \"\") %>%\n var_relabel(\n MHBODSYS = \"MedDRA System Organ Class\",\n MHDECOD = \"MedDRA Preferred Term\"\n )\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\"Total number of patients with at least one condition\", \"Total number of conditions\")\n ) %>%\n split_rows_by(\n var = \"MHBODSYS\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(admh_f$MHBODSYS)\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\"Total number of patients with at least one condition\", \"Total number of conditions\"),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"MHDECOD\") %>%\n append_varlabels(admh_f, \"MHDECOD\", indent = 1L)\n\nresult <- build_table(lyt, admh_f, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one condition 122 (91.0%) 123 (91.8%) 120 (90.9%) \nTotal number of conditions 609 622 703 \ncl A \n Total number of patients with at least one condition 78 (58.2%) 75 (56.0%) 89 (67.4%) \n Total number of conditions 132 130 160 \n trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) \n trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) \ncl B \n Total number of patients with at least one condition 96 (71.6%) 89 (66.4%) 97 (73.5%) \n Total number of conditions 185 198 205 \n trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) \n trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) \n trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) \ncl C \n Total number of patients with at least one condition 67 (50.0%) 75 (56.0%) 79 (59.8%) \n Total number of conditions 103 116 129 \n trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) \n trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) \ncl D \n Total number of patients with at least one condition 96 (71.6%) 90 (67.2%) 98 (74.2%) \n Total number of conditions 189 178 209 \n trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) \n trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) \n trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) \n\n\n\n\n\nCodeadmh_f_prior <- admh_f %>%\n filter(ASTDY <= 0)\n\nresult <- build_table(lyt, admh_f_prior, alt_counts_df = adsl_f) %>%\n prune_table()\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one condition 0 0 1 (0.8%) \nTotal number of conditions 0 0 1 \ncl D \n Total number of patients with at least one condition 0 0 1 (0.8%) \n Total number of conditions 0 0 1 \n trm D_2/3 0 0 1 (0.8%) \n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\"Total number of patients with at least one condition\")\n ) %>%\n split_rows_by(\n var = \"MHBODSYS\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(admh_f$MHBODSYS)\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\"Total number of patients with at least one condition\"),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"MHDECOD\") %>%\n append_varlabels(admh_f, \"MHDECOD\", indent = 1L)\n\nresult <- build_table(lyt, admh_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one condition 122 (91.0%) 123 (91.8%) 120 (90.9%) \ncl A \n Total number of patients with at least one condition 78 (58.2%) 75 (56.0%) 89 (67.4%) \n trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) \n trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) \ncl B \n Total number of patients with at least one condition 96 (71.6%) 89 (66.4%) 97 (73.5%) \n trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) \n trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) \n trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) \ncl C \n Total number of patients with at least one condition 67 (50.0%) 75 (56.0%) 79 (59.8%) \n trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) \n trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) \ncl D \n Total number of patients with at least one condition 96 (71.6%) 90 (67.2%) 98 (74.2%) \n trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) \n trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) \n trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) \n\n\n\n\nNot currently supported by rtables. Users, please notify us if this variation is important to you.\n\n\nConditions are further sorted by decreasing high level terms and low level terms.\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n add_overall_col(\"All Patients\") %>%\n analyze_num_patients(\n \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(unique = \"Total number of patients with at least one event\", nonunique = \"Total number of conditions\")\n ) %>%\n split_rows_by(\n var = \"MHBODSYS\",\n split_fun = split_fun,\n child_labels = \"visible\",\n label_pos = \"topleft\",\n split_label = obj_label(admh_f$MHBODSYS)\n ) %>%\n summarize_num_patients(\n \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(unique = \"Total number of patients with at least one event\", nonunique = \"Total number of conditions\")\n ) %>%\n count_occurrences(vars = \"MHDECOD\", .indent_mods = -1L) %>%\n append_varlabels(admh_f, \"MHDECOD\", indent = 1L)\n\nscorefun_hlt <- cont_n_allcols\nscorefun_llt <- score_occurrences_cols(col_indices = nlevels(adsl_f$ACTARM) + 1)\n\nresult <- build_table(lyt, admh_f, alt_counts_df = adsl_f) %>%\n prune_table() %>%\n sort_at_path(path = c(\"MHBODSYS\"), scorefun = scorefun_hlt) %>%\n sort_at_path(path = c(\"MHBODSYS\", \"*\", \"MHDECOD\"), scorefun = scorefun_llt)\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients\n MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one event 122 (91.0%) 123 (91.8%) 120 (90.9%) 365 (91.2%) \nTotal number of conditions 609 622 703 1934 \ncl D \n Total number of patients with at least one event 96 (71.6%) 90 (67.2%) 98 (74.2%) 284 (71.0%) \n Total number of conditions 189 178 209 576 \n trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \n trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \n trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) \ncl B \n Total number of patients with at least one event 96 (71.6%) 89 (66.4%) 97 (73.5%) 282 (70.5%) \n Total number of conditions 185 198 205 588 \n trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) \n trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) \n trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \ncl A \n Total number of patients with at least one event 78 (58.2%) 75 (56.0%) 89 (67.4%) 242 (60.5%) \n Total number of conditions 132 130 160 422 \n trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) \n trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) \ncl C \n Total number of patients with at least one event 67 (50.0%) 75 (56.0%) 79 (59.8%) 221 (55.2%) \n Total number of conditions 103 116 129 348 \n trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \n trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\n\nadsl_f <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n filter(SAFFL == \"Y\")\nadmh_f <- synthetic_cdisc_dataset(\"latest\", \"admh\") %>%\n filter(SAFFL == \"Y\" & MHBODSYS != \"\" & MHDECOD != \"\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl_f, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n filter(SAFFL == \"Y\")'),\n cdisc_dataset(\"ADMH\", admh_f, code = 'ADMH <- synthetic_cdisc_dataset(\"latest\", \"admh\") %>%\n filter(SAFFL == \"Y\" & MHBODSYS != \"\" & MHDECOD != \"\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Medical History Table\",\n dataname = \"ADMH\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(admh_f, c(\"MHTERM\", \"MHDECOD\")),\n selected = c(\"MHDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(admh_f, c(\"MHBODSYS\", \"MHSOC\")),\n selected = \"MHBODSYS\"\n ),\n add_total = TRUE,\n event_type = \"condition\"\n )\n )\n)\n\n[INFO] 2023-09-09 17:57:58.7994 pid:4619 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/safety/ext01.html",
"href": "tables/safety/ext01.html",
"title": "EXT01",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Optional Analyses\nTable with User-Specified Categories for Missed Doses\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\nlibrary(tidyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\nadex <- adex %>%\n filter(PARCAT1 == \"OVERALL\") %>%\n select(STUDYID, USUBJID, ACTARM, PARAMCD, PARAM, AVAL, PARCAT2) %>%\n mutate(\n PARAMCD = as.character(PARAMCD),\n AVALC = \"\"\n ) %>%\n droplevels()\n\n# Add new param tdurd for treatment duration.\nset.seed(99)\ntdurd_adsl <- adsl %>%\n select(STUDYID, USUBJID, ACTARM) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(1:150, size = nrow(adsl), replace = TRUE),\n AVALC = case_when(\n 0 <= AVAL & AVAL <= 30 ~ \"0 - 30\",\n 31 <= AVAL & AVAL <= 60 ~ \"31 - 60\",\n 61 <= AVAL & AVAL <= 90 ~ \"61 - 90\",\n TRUE ~ \">= 91\"\n )\n )\ntdurd <- adex %>%\n filter(PARAMCD == \"TNDOSE\") %>%\n select(STUDYID, USUBJID, PARCAT2) %>%\n left_join(tdurd_adsl, by = c(\"STUDYID\", \"USUBJID\"))\n\n# Add new param tndosmis for missed doses.\ntndosmis_adsl <- adsl %>%\n select(STUDYID, USUBJID, ACTARM) %>%\n mutate(\n PARAMCD = \"TNDOSMIS\",\n PARAM = \"Total number of missed doses during study\",\n AVAL = sample(0:20, size = nrow(adsl), replace = TRUE),\n AVALC = \"\"\n )\ntndosmis <- adex %>%\n filter(PARAMCD == \"TNDOSE\") %>%\n select(STUDYID, USUBJID, PARCAT2) %>%\n left_join(tndosmis_adsl, by = c(\"STUDYID\", \"USUBJID\"))\n\nadex <- dplyr::bind_rows(adex, tdurd, tndosmis) %>%\n mutate(PARAM = factor(\n PARAM,\n levels = c(\n \"Overall duration (days)\", \"Total dose administered\", \"Total number of doses administered\",\n \"Total number of missed doses during study\"\n )\n ))\n\n\n\n\n\nCode# When summary table contains only categorical or only numeric parameters\n\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARCAT2\", split_label = \"\\nParameter Category (Drug A/Drug B)\", label_pos = \"topleft\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun) %>%\n analyze_vars(vars = \"AVAL\")\n\nresult <- build_table(lyt = lyt, df = adex, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination \nParameter Category (Drug A/Drug B) (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nDrug A \n Overall duration (days) \n n 75 67 75 \n Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) \n Median 77.0 80.0 78.0 \n Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 \n Total dose administered \n n 75 67 75 \n Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)\n Median 6720.0 6480.0 7200.0 \n Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0\n Total number of doses administered \n n 75 67 75 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n Total number of missed doses during study \n n 75 67 75 \n Mean (SD) 10.5 (5.9) 10.0 (6.1) 9.5 (5.5) \n Median 10.0 11.0 9.0 \n Min - Max 0.0 - 20.0 0.0 - 19.0 0.0 - 20.0 \nDrug B \n Overall duration (days) \n n 59 67 57 \n Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2) \n Median 79.0 76.0 65.0 \n Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0 \n Total dose administered \n n 59 67 57 \n Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)\n Median 6720.0 6240.0 6480.0 \n Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0\n Total number of doses administered \n n 59 67 57 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n Total number of missed doses during study \n n 59 67 57 \n Mean (SD) 9.1 (6.5) 10.0 (6.3) 10.7 (5.8) \n Median 9.0 10.0 11.0 \n Min - Max 0.0 - 20.0 0.0 - 20.0 1.0 - 20.0 \n\n\n\n\n\nCode# When summary table contains both categorical and numeric parameters,\n# developer needs to do pre-processing to transform dataset to wide format.\nadex_avalc_wide <- adex %>%\n filter(PARAMCD == \"TDURD\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVALC, PARCAT2) %>%\n tidyr::pivot_wider(\n id_cols = c(STUDYID, USUBJID, PARCAT2),\n names_from = PARAMCD,\n values_from = AVALC\n ) %>%\n mutate(\n TDURDC = factor(TDURD, levels = c(\"0 - 30\", \"31 - 60\", \"61 - 90\", \">= 91\"))\n ) %>%\n select(-TDURD)\n\nanl <- adex %>%\n select(STUDYID, USUBJID, ACTARM, PARAMCD, AVAL, PARCAT2) %>%\n tidyr::pivot_wider(\n id_cols = c(STUDYID, USUBJID, ACTARM, PARCAT2),\n names_from = PARAMCD,\n values_from = AVAL\n ) %>%\n left_join(adex_avalc_wide, by = c(\"STUDYID\", \"USUBJID\", \"PARCAT2\")) %>%\n var_relabel(\n TDOSE = \"Total dose administered\",\n TNDOSE = \"Total number of doses administered\",\n TDURD = \"Overall duration (days)\",\n TNDOSMIS = \"Total number of missed doses during study\",\n TDURDC = \"Overall duration (days)\"\n )\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARCAT2\", split_label = \"\\nParameter Category (Drug A/Drug B)\", label_pos = \"topleft\") %>%\n analyze_vars(\n vars = c(\"TDURD\", \"TDURDC\", \"TDOSE\", \"TNDOSE\"),\n var_labels = var_labels(anl)[c(\"TDURD\", \"TDURDC\", \"TDOSE\", \"TNDOSE\")]\n )\n\nresult <- build_table(lyt = lyt, df = anl, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination \nParameter Category (Drug A/Drug B) (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————\nDrug A \n Overall duration (days) \n n 75 67 75 \n Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) \n Median 77.0 80.0 78.0 \n Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 \n Overall duration (days) \n n 75 67 75 \n 0 - 30 12 (16%) 12 (17.9%) 15 (20%) \n 31 - 60 18 (24%) 12 (17.9%) 14 (18.7%) \n 61 - 90 19 (25.3%) 15 (22.4%) 18 (24%) \n >= 91 26 (34.7%) 28 (41.8%) 28 (37.3%) \n Total dose administered \n n 75 67 75 \n Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)\n Median 6720.0 6480.0 7200.0 \n Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0\n Total number of doses administered \n n 75 67 75 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \nDrug B \n Overall duration (days) \n n 59 67 57 \n Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2) \n Median 79.0 76.0 65.0 \n Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0 \n Overall duration (days) \n n 59 67 57 \n 0 - 30 8 (13.6%) 10 (14.9%) 16 (28.1%) \n 31 - 60 14 (23.7%) 16 (23.9%) 12 (21.1%) \n 61 - 90 15 (25.4%) 17 (25.4%) 11 (19.3%) \n >= 91 22 (37.3%) 24 (35.8%) 18 (31.6%) \n Total dose administered \n n 59 67 57 \n Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)\n Median 6720.0 6240.0 6480.0 \n Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0\n Total number of doses administered \n n 59 67 57 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n\n\n\n\n\nCode# When summary table contains both categorical and numeric parameters,\n# developer needs to do pre-processing to transform dataset to wide format.\nadex_avalc_wide <- adex %>%\n filter(PARAMCD == \"TDURD\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVALC, PARCAT2) %>%\n tidyr::pivot_wider(\n id_cols = c(STUDYID, USUBJID, PARCAT2),\n names_from = PARAMCD,\n values_from = AVALC\n ) %>%\n mutate(\n TDURDC = factor(TDURD, levels = c(\"0 - 30\", \"31 - 60\", \"61 - 90\", \">= 91\"))\n ) %>%\n select(-TDURD)\n\nanl <- adex %>%\n select(STUDYID, USUBJID, ACTARM, PARAMCD, AVAL, PARCAT2) %>%\n tidyr::pivot_wider(\n id_cols = c(STUDYID, USUBJID, ACTARM, PARCAT2),\n names_from = PARAMCD,\n values_from = AVAL\n ) %>%\n left_join(adex_avalc_wide, by = c(\"STUDYID\", \"USUBJID\", \"PARCAT2\")) %>%\n var_relabel(\n TDOSE = \"Total dose administered\",\n TNDOSE = \"Total number of doses administered\",\n TDURD = \"Overall duration (days)\",\n TNDOSMIS = \"Total number of missed doses during study\",\n TDURDC = \"Overall duration (days)\"\n )\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARCAT2\", split_label = \"\\nParameter Category (Drug A/Drug B)\", label_pos = \"topleft\") %>%\n analyze_vars(\n vars = c(\"TDURD\", \"TDURDC\", \"TDOSE\", \"TNDOSE\"),\n var_labels = var_labels(anl)[c(\"TDURD\", \"TDURDC\", \"TDOSE\", \"TNDOSE\")]\n ) %>%\n count_missed_doses(\n \"TNDOSMIS\",\n thresholds = c(1, 5, 10, 15),\n var_labels = \"Missed Doses\"\n )\n\nresult <- build_table(lyt = lyt, df = anl, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination \nParameter Category (Drug A/Drug B) (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————\nDrug A \n Overall duration (days) \n n 75 67 75 \n Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) \n Median 77.0 80.0 78.0 \n Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 \n Overall duration (days) \n n 75 67 75 \n 0 - 30 12 (16%) 12 (17.9%) 15 (20%) \n 31 - 60 18 (24%) 12 (17.9%) 14 (18.7%) \n 61 - 90 19 (25.3%) 15 (22.4%) 18 (24%) \n >= 91 26 (34.7%) 28 (41.8%) 28 (37.3%) \n Total dose administered \n n 75 67 75 \n Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)\n Median 6720.0 6480.0 7200.0 \n Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0\n Total number of doses administered \n n 75 67 75 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n Missed Doses \n n 75 67 75 \n At least 1 missed dose 74 (55.2%) 63 (47%) 73 (55.3%) \n At least 5 missed doses 59 (44%) 49 (36.6%) 59 (44.7%) \n At least 10 missed doses 41 (30.6%) 38 (28.4%) 37 (28%) \n At least 15 missed doses 26 (19.4%) 21 (15.7%) 16 (12.1%) \nDrug B \n Overall duration (days) \n n 59 67 57 \n Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2) \n Median 79.0 76.0 65.0 \n Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0 \n Overall duration (days) \n n 59 67 57 \n 0 - 30 8 (13.6%) 10 (14.9%) 16 (28.1%) \n 31 - 60 14 (23.7%) 16 (23.9%) 12 (21.1%) \n 61 - 90 15 (25.4%) 17 (25.4%) 11 (19.3%) \n >= 91 22 (37.3%) 24 (35.8%) 18 (31.6%) \n Total dose administered \n n 59 67 57 \n Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)\n Median 6720.0 6240.0 6480.0 \n Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0\n Total number of doses administered \n n 59 67 57 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n Missed Doses \n n 59 67 57 \n At least 1 missed dose 56 (41.8%) 63 (47%) 57 (43.2%) \n At least 5 missed doses 41 (30.6%) 50 (37.3%) 47 (35.6%) \n At least 10 missed doses 27 (20.1%) 36 (26.9%) 31 (23.5%) \n At least 15 missed doses 17 (12.7%) 18 (13.4%) 20 (15.2%) \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\nadex_labels <- unname(var_labels(adex))\nadex <- adex %>%\n filter(PARCAT1 == \"OVERALL\") %>%\n mutate(\n AVALCAT1 = case_when(\n PARAMCD == \"TDOSE\" & AVAL < 5000 ~ \"LOW\",\n PARAMCD == \"TDOSE\" & AVAL >= 5000 ~ \"HIGH\",\n PARAMCD == \"TNDOSE\" & AVAL < 10 ~ \"< 10\",\n PARAMCD == \"TNDOSE\" & AVAL >= 10 ~ \">= 10\"\n )\n )\nvar_labels(adex) <- c(adex_labels, \"\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'\n ),\n cdisc_dataset(\n \"ADEX\",\n adex,\n code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n ADEX_labels <- unname(var_labels(ADEX))\n ADEX <- ADEX %>%\n filter(PARCAT1 == \"OVERALL\") %>%\n mutate(\n AVALCAT1 = case_when(\n PARAMCD == \"TDOSE\" & AVAL < 5000 ~ \"LOW\",\n PARAMCD == \"TDOSE\" & AVAL >= 5000 ~ \"HIGH\",\n PARAMCD == \"TNDOSE\" & AVAL < 10 ~ \"< 10\",\n PARAMCD == \"TNDOSE\" & AVAL >= 10 ~ \">= 10\")\n )\n var_labels(ADEX) <- c(ADEX_labels, \"\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Exposure Table\",\n dataname = \"ADEX\",\n arm_var = choices_selected(\n choices = variable_choices(adex, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adex, c(\"PARCAT2\", \"PARAM\")),\n selected = c(\"PARCAT2\", \"PARAM\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adex, c(\"AVAL\", \"AVALCAT1\")),\n selected = c(\"AVAL\", \"AVALCAT1\")\n ),\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = c(\"TDOSE\", \"TNDOSE\")\n ),\n denominator = choices_selected(\n choices = c(\"n\", \"N\", \"omit\"),\n selected = \"N\"\n )\n )\n ), # Set initial filter state as single study drug to produce smaller table\n filter = list(ADEX = list(PARCAT2 = \"Drug A\", AVAL = list()))\n)\n\n[INFO] 2023-09-08 19:40:21.7538 pid:4810 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tidyr_1.3.0 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Optional Analyses\nTable with User-Specified Categories for Missed Doses\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\nlibrary(tidyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\nadex <- adex %>%\n filter(PARCAT1 == \"OVERALL\") %>%\n select(STUDYID, USUBJID, ACTARM, PARAMCD, PARAM, AVAL, PARCAT2) %>%\n mutate(\n PARAMCD = as.character(PARAMCD),\n AVALC = \"\"\n ) %>%\n droplevels()\n\n# Add new param tdurd for treatment duration.\nset.seed(99)\ntdurd_adsl <- adsl %>%\n select(STUDYID, USUBJID, ACTARM) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(1:150, size = nrow(adsl), replace = TRUE),\n AVALC = case_when(\n 0 <= AVAL & AVAL <= 30 ~ \"0 - 30\",\n 31 <= AVAL & AVAL <= 60 ~ \"31 - 60\",\n 61 <= AVAL & AVAL <= 90 ~ \"61 - 90\",\n TRUE ~ \">= 91\"\n )\n )\ntdurd <- adex %>%\n filter(PARAMCD == \"TNDOSE\") %>%\n select(STUDYID, USUBJID, PARCAT2) %>%\n left_join(tdurd_adsl, by = c(\"STUDYID\", \"USUBJID\"))\n\n# Add new param tndosmis for missed doses.\ntndosmis_adsl <- adsl %>%\n select(STUDYID, USUBJID, ACTARM) %>%\n mutate(\n PARAMCD = \"TNDOSMIS\",\n PARAM = \"Total number of missed doses during study\",\n AVAL = sample(0:20, size = nrow(adsl), replace = TRUE),\n AVALC = \"\"\n )\ntndosmis <- adex %>%\n filter(PARAMCD == \"TNDOSE\") %>%\n select(STUDYID, USUBJID, PARCAT2) %>%\n left_join(tndosmis_adsl, by = c(\"STUDYID\", \"USUBJID\"))\n\nadex <- dplyr::bind_rows(adex, tdurd, tndosmis) %>%\n mutate(PARAM = factor(\n PARAM,\n levels = c(\n \"Overall duration (days)\", \"Total dose administered\", \"Total number of doses administered\",\n \"Total number of missed doses during study\"\n )\n ))\n\n\n\n\n\nCode# When summary table contains only categorical or only numeric parameters\n\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARCAT2\", split_label = \"\\nParameter Category (Drug A/Drug B)\", label_pos = \"topleft\") %>%\n split_rows_by(\"PARAM\", split_fun = split_fun) %>%\n analyze_vars(vars = \"AVAL\")\n\nresult <- build_table(lyt = lyt, df = adex, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination \nParameter Category (Drug A/Drug B) (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nDrug A \n Overall duration (days) \n n 75 67 75 \n Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) \n Median 77.0 80.0 78.0 \n Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 \n Total dose administered \n n 75 67 75 \n Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)\n Median 6720.0 6480.0 7200.0 \n Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0\n Total number of doses administered \n n 75 67 75 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n Total number of missed doses during study \n n 75 67 75 \n Mean (SD) 10.5 (5.9) 10.0 (6.1) 9.5 (5.5) \n Median 10.0 11.0 9.0 \n Min - Max 0.0 - 20.0 0.0 - 19.0 0.0 - 20.0 \nDrug B \n Overall duration (days) \n n 59 67 57 \n Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2) \n Median 79.0 76.0 65.0 \n Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0 \n Total dose administered \n n 59 67 57 \n Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)\n Median 6720.0 6240.0 6480.0 \n Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0\n Total number of doses administered \n n 59 67 57 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n Total number of missed doses during study \n n 59 67 57 \n Mean (SD) 9.1 (6.5) 10.0 (6.3) 10.7 (5.8) \n Median 9.0 10.0 11.0 \n Min - Max 0.0 - 20.0 0.0 - 20.0 1.0 - 20.0 \n\n\n\n\n\nCode# When summary table contains both categorical and numeric parameters,\n# developer needs to do pre-processing to transform dataset to wide format.\nadex_avalc_wide <- adex %>%\n filter(PARAMCD == \"TDURD\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVALC, PARCAT2) %>%\n tidyr::pivot_wider(\n id_cols = c(STUDYID, USUBJID, PARCAT2),\n names_from = PARAMCD,\n values_from = AVALC\n ) %>%\n mutate(\n TDURDC = factor(TDURD, levels = c(\"0 - 30\", \"31 - 60\", \"61 - 90\", \">= 91\"))\n ) %>%\n select(-TDURD)\n\nanl <- adex %>%\n select(STUDYID, USUBJID, ACTARM, PARAMCD, AVAL, PARCAT2) %>%\n tidyr::pivot_wider(\n id_cols = c(STUDYID, USUBJID, ACTARM, PARCAT2),\n names_from = PARAMCD,\n values_from = AVAL\n ) %>%\n left_join(adex_avalc_wide, by = c(\"STUDYID\", \"USUBJID\", \"PARCAT2\")) %>%\n var_relabel(\n TDOSE = \"Total dose administered\",\n TNDOSE = \"Total number of doses administered\",\n TDURD = \"Overall duration (days)\",\n TNDOSMIS = \"Total number of missed doses during study\",\n TDURDC = \"Overall duration (days)\"\n )\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARCAT2\", split_label = \"\\nParameter Category (Drug A/Drug B)\", label_pos = \"topleft\") %>%\n analyze_vars(\n vars = c(\"TDURD\", \"TDURDC\", \"TDOSE\", \"TNDOSE\"),\n var_labels = var_labels(anl)[c(\"TDURD\", \"TDURDC\", \"TDOSE\", \"TNDOSE\")]\n )\n\nresult <- build_table(lyt = lyt, df = anl, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination \nParameter Category (Drug A/Drug B) (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————\nDrug A \n Overall duration (days) \n n 75 67 75 \n Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) \n Median 77.0 80.0 78.0 \n Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 \n Overall duration (days) \n n 75 67 75 \n 0 - 30 12 (16%) 12 (17.9%) 15 (20%) \n 31 - 60 18 (24%) 12 (17.9%) 14 (18.7%) \n 61 - 90 19 (25.3%) 15 (22.4%) 18 (24%) \n >= 91 26 (34.7%) 28 (41.8%) 28 (37.3%) \n Total dose administered \n n 75 67 75 \n Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)\n Median 6720.0 6480.0 7200.0 \n Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0\n Total number of doses administered \n n 75 67 75 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \nDrug B \n Overall duration (days) \n n 59 67 57 \n Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2) \n Median 79.0 76.0 65.0 \n Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0 \n Overall duration (days) \n n 59 67 57 \n 0 - 30 8 (13.6%) 10 (14.9%) 16 (28.1%) \n 31 - 60 14 (23.7%) 16 (23.9%) 12 (21.1%) \n 61 - 90 15 (25.4%) 17 (25.4%) 11 (19.3%) \n >= 91 22 (37.3%) 24 (35.8%) 18 (31.6%) \n Total dose administered \n n 59 67 57 \n Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)\n Median 6720.0 6240.0 6480.0 \n Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0\n Total number of doses administered \n n 59 67 57 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n\n\n\n\n\nCode# When summary table contains both categorical and numeric parameters,\n# developer needs to do pre-processing to transform dataset to wide format.\nadex_avalc_wide <- adex %>%\n filter(PARAMCD == \"TDURD\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVALC, PARCAT2) %>%\n tidyr::pivot_wider(\n id_cols = c(STUDYID, USUBJID, PARCAT2),\n names_from = PARAMCD,\n values_from = AVALC\n ) %>%\n mutate(\n TDURDC = factor(TDURD, levels = c(\"0 - 30\", \"31 - 60\", \"61 - 90\", \">= 91\"))\n ) %>%\n select(-TDURD)\n\nanl <- adex %>%\n select(STUDYID, USUBJID, ACTARM, PARAMCD, AVAL, PARCAT2) %>%\n tidyr::pivot_wider(\n id_cols = c(STUDYID, USUBJID, ACTARM, PARCAT2),\n names_from = PARAMCD,\n values_from = AVAL\n ) %>%\n left_join(adex_avalc_wide, by = c(\"STUDYID\", \"USUBJID\", \"PARCAT2\")) %>%\n var_relabel(\n TDOSE = \"Total dose administered\",\n TNDOSE = \"Total number of doses administered\",\n TDURD = \"Overall duration (days)\",\n TNDOSMIS = \"Total number of missed doses during study\",\n TDURDC = \"Overall duration (days)\"\n )\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n split_rows_by(\"PARCAT2\", split_label = \"\\nParameter Category (Drug A/Drug B)\", label_pos = \"topleft\") %>%\n analyze_vars(\n vars = c(\"TDURD\", \"TDURDC\", \"TDOSE\", \"TNDOSE\"),\n var_labels = var_labels(anl)[c(\"TDURD\", \"TDURDC\", \"TDOSE\", \"TNDOSE\")]\n ) %>%\n count_missed_doses(\n \"TNDOSMIS\",\n thresholds = c(1, 5, 10, 15),\n var_labels = \"Missed Doses\"\n )\n\nresult <- build_table(lyt = lyt, df = anl, alt_counts_df = adsl)\n\nresult\n\n A: Drug X B: Placebo C: Combination \nParameter Category (Drug A/Drug B) (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————\nDrug A \n Overall duration (days) \n n 75 67 75 \n Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) \n Median 77.0 80.0 78.0 \n Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 \n Overall duration (days) \n n 75 67 75 \n 0 - 30 12 (16%) 12 (17.9%) 15 (20%) \n 31 - 60 18 (24%) 12 (17.9%) 14 (18.7%) \n 61 - 90 19 (25.3%) 15 (22.4%) 18 (24%) \n >= 91 26 (34.7%) 28 (41.8%) 28 (37.3%) \n Total dose administered \n n 75 67 75 \n Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5)\n Median 6720.0 6480.0 7200.0 \n Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0\n Total number of doses administered \n n 75 67 75 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n Missed Doses \n n 75 67 75 \n At least 1 missed dose 74 (55.2%) 63 (47%) 73 (55.3%) \n At least 5 missed doses 59 (44%) 49 (36.6%) 59 (44.7%) \n At least 10 missed doses 41 (30.6%) 38 (28.4%) 37 (28%) \n At least 15 missed doses 26 (19.4%) 21 (15.7%) 16 (12.1%) \nDrug B \n Overall duration (days) \n n 59 67 57 \n Mean (SD) 77.5 (40.5) 76.3 (41.0) 69.5 (46.2) \n Median 79.0 76.0 65.0 \n Min - Max 2.0 - 149.0 5.0 - 148.0 1.0 - 149.0 \n Overall duration (days) \n n 59 67 57 \n 0 - 30 8 (13.6%) 10 (14.9%) 16 (28.1%) \n 31 - 60 14 (23.7%) 16 (23.9%) 12 (21.1%) \n 61 - 90 15 (25.4%) 17 (25.4%) 11 (19.3%) \n >= 91 22 (37.3%) 24 (35.8%) 18 (31.6%) \n Total dose administered \n n 59 67 57 \n Mean (SD) 6630.5 (1334.0) 6297.3 (1291.1) 6505.3 (1080.7)\n Median 6720.0 6240.0 6480.0 \n Min - Max 4320.0 - 8880.0 4080.0 - 9120.0 4320.0 - 8640.0\n Total number of doses administered \n n 59 67 57 \n Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) \n Median 7.0 7.0 7.0 \n Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 \n Missed Doses \n n 59 67 57 \n At least 1 missed dose 56 (41.8%) 63 (47%) 57 (43.2%) \n At least 5 missed doses 41 (30.6%) 50 (37.3%) 47 (35.6%) \n At least 10 missed doses 27 (20.1%) 36 (26.9%) 31 (23.5%) \n At least 15 missed doses 17 (12.7%) 18 (13.4%) 20 (15.2%) \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\nadex_labels <- unname(var_labels(adex))\nadex <- adex %>%\n filter(PARCAT1 == \"OVERALL\") %>%\n mutate(\n AVALCAT1 = case_when(\n PARAMCD == \"TDOSE\" & AVAL < 5000 ~ \"LOW\",\n PARAMCD == \"TDOSE\" & AVAL >= 5000 ~ \"HIGH\",\n PARAMCD == \"TNDOSE\" & AVAL < 10 ~ \"< 10\",\n PARAMCD == \"TNDOSE\" & AVAL >= 10 ~ \">= 10\"\n )\n )\nvar_labels(adex) <- c(adex_labels, \"\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'\n ),\n cdisc_dataset(\n \"ADEX\",\n adex,\n code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n ADEX_labels <- unname(var_labels(ADEX))\n ADEX <- ADEX %>%\n filter(PARCAT1 == \"OVERALL\") %>%\n mutate(\n AVALCAT1 = case_when(\n PARAMCD == \"TDOSE\" & AVAL < 5000 ~ \"LOW\",\n PARAMCD == \"TDOSE\" & AVAL >= 5000 ~ \"HIGH\",\n PARAMCD == \"TNDOSE\" & AVAL < 10 ~ \"< 10\",\n PARAMCD == \"TNDOSE\" & AVAL >= 10 ~ \">= 10\")\n )\n var_labels(ADEX) <- c(ADEX_labels, \"\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Exposure Table\",\n dataname = \"ADEX\",\n arm_var = choices_selected(\n choices = variable_choices(adex, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adex, c(\"PARCAT2\", \"PARAM\")),\n selected = c(\"PARCAT2\", \"PARAM\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adex, c(\"AVAL\", \"AVALCAT1\")),\n selected = c(\"AVAL\", \"AVALCAT1\")\n ),\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = c(\"TDOSE\", \"TNDOSE\")\n ),\n denominator = choices_selected(\n choices = c(\"n\", \"N\", \"omit\"),\n selected = \"N\"\n )\n )\n ), # Set initial filter state as single study drug to produce smaller table\n filter = list(ADEX = list(PARCAT2 = \"Drug A\", AVAL = list()))\n)\n\n[INFO] 2023-09-09 17:59:10.5448 pid:4815 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tidyr_1.3.0 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet09_smq.html",
"href": "tables/adverse-events/aet09_smq.html",
"title": "AET09_SMQ",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Customized Queries\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(stringr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing\n# levels. For details, refer to Teal and Study Data article.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\n# AEs are filtered for relatedness to study drug.\nadae_rel <- adae %>% filter(AEREL == \"Y\")\n\n# Simulate a random AAG dataset.\naag <- data.frame(\n NAMVAR = c(\"SMQ01NAM\", \"SMQ01NAM\", \"SMQ02NAM\", \"CQ01NAM\", \"CQ01NAM\"),\n SRCVAR = rep(\"AEDECOD\", 5),\n GRPTYPE = c(\"SMQ\", \"SMQ\", \"SMQ\", \"CUSTOM\", \"CUSTOM\"),\n REFID = c(1, 1, 2, 3, 3),\n REFNAME = c(rep(\"C.1.1.1.3/B.2.2.3.1 AESI\", 2), \"non observed SMQ02NAM level\", rep(\"D.2.1.5.3/A.1.1.1.1 AESI\", 2)),\n SCOPE = c(\"BROAD\", \"BROAD\", \"BROAD\", \"\", \"\"),\n REFTERM = c(\"C.1.1.1.3\", \"B.2.2.3.1\", \"Z.9.9.9.9\", \"D.2.1.5.3\", \"A.1.1.1.1\"),\n stringsAsFactors = FALSE\n)\n\n# Create summary AAG dataset (used for labelling).\n# Note it's important to incorporate SCOPE into the basket names for SMQs so as to\n# match the flags present in ADAE.\naag_summary <- aag %>%\n select(NAMVAR, REFNAME, SCOPE) %>%\n unique() %>%\n mutate(\n REFNAME_SCOPE = ifelse(SCOPE == \"\", REFNAME, paste0(REFNAME, \"(\", SCOPE, \")\"))\n ) %>%\n rename(basket = NAMVAR, basket_name = REFNAME_SCOPE) %>%\n select(basket, basket_name)\n\n# Make a summary of the full ADAE based on AAG by using h_stack_by_baskets helper function\nadae_smq_all <- h_stack_by_baskets(df = adae_rel, aag_summary = aag_summary, keys = c(\"STUDYID\", \"USUBJID\", \"ACTARMCD\", \"AEDECOD\"))\n\n# Post-process adae_smq_all to keep only certain baskets of interest for variant 1\n# Not need to drop baskets for variant 2 as all baskets will be considered.\nbaskets_to_drop_variant <- aag_summary$basket_name[!aag_summary$basket %in% c(\"SMQ01NAM\")]\n\n# Adjust the analysis dataset based on basket subset for variant 1.\nadae_smq_1 <- adae_smq_all %>%\n filter(!adae_smq_all$SMQ %in% baskets_to_drop_variant) %>%\n mutate(\n SMQ = tern::fct_discard(SMQ, discard = baskets_to_drop_variant)\n )\n\n\n\n\n\nCodecriteria_fun <- function(tr) !is(tr, \"ContentRow\") && all_zero_or_na(tr)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = -1L,\n drop = FALSE\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt,\n df = adae_smq_1,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%)\n Total number of events 55 63 64 \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)\n\n\n\n\n\nCodecriteria_fun <- function(tr) {\n !is(tr, \"ContentRow\") && all_zero_or_na(tr) && !grepl(\"Total number of\", obj_label(tr))\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n drop = FALSE\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nscore_ae_pts <- function(tt) {\n count_vals <- cell_values(tree_children(tt)[[\"USUBJID\"]])[[1]]\n sum(matrix(unlist(count_vals), nrow = length(count_vals), byrow = TRUE)[, 1])\n}\n\nresult <- build_table(\n lyt,\n df = adae_smq_all,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = score_ae_pts) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 69 (51.5%) 78 (58.2%) 77 (58.3%)\nD.2.1.5.3/A.1.1.1.1 AESI \n Total number of patients with at least one adverse event 47 (35.1%) 58 (43.3%) 57 (43.2%)\n Total number of events 62 72 74 \n dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%)\n Total number of events 55 63 64 \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)\nnon observed SMQ02NAM level(BROAD) \n Total number of patients with at least one adverse event 0 0 0 \n Total number of events 0 0 0 \n\n\n\n\nNote that filtering AEs for relatedness to study drug is not a necessary data pre-processing step for the module. It can be achieved using the teal module filter panel. The example here pre-sets the filters using AEREL = \"Y\" in adae.\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nnames_baskets <- grep(\"^(SMQ|CQ).*NAM$\", names(adae), value = TRUE)\nnames_scopes <- grep(\"^SMQ.*SC$\", names(adae), value = TRUE)\n\ncs_baskets <- choices_selected(\n choices = variable_choices(adae, subset = names_baskets),\n selected = names_baskets\n)\ncs_scopes <- choices_selected(\n choices = variable_choices(adae, subset = names_scopes),\n selected = names_scopes,\n fixed = TRUE\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'\n ),\n cdisc_dataset(\"ADAE\", adae,\n code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_smq(\n label = \"Adverse Events by SMQ Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"SEX\")),\n selected = \"ARM\"\n ),\n add_total = FALSE,\n baskets = cs_baskets,\n scopes = cs_scopes,\n llt = choices_selected(\n choices = variable_choices(adae, subset = c(\"AEDECOD\")),\n selected = \"AEDECOD\"\n )\n )\n ),\n filter = list(ADAE = list(AEREL = \"Y\"))\n)\n\n[INFO] 2023-09-08 19:41:06.5431 pid:5006 token:[] teal.modules.clinical Initializing tm_t_smq\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] stringr_1.5.0 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] stringi_1.7.12 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Customized Queries\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(stringr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing\n# levels. For details, refer to Teal and Study Data article.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\n# AEs are filtered for relatedness to study drug.\nadae_rel <- adae %>% filter(AEREL == \"Y\")\n\n# Simulate a random AAG dataset.\naag <- data.frame(\n NAMVAR = c(\"SMQ01NAM\", \"SMQ01NAM\", \"SMQ02NAM\", \"CQ01NAM\", \"CQ01NAM\"),\n SRCVAR = rep(\"AEDECOD\", 5),\n GRPTYPE = c(\"SMQ\", \"SMQ\", \"SMQ\", \"CUSTOM\", \"CUSTOM\"),\n REFID = c(1, 1, 2, 3, 3),\n REFNAME = c(rep(\"C.1.1.1.3/B.2.2.3.1 AESI\", 2), \"non observed SMQ02NAM level\", rep(\"D.2.1.5.3/A.1.1.1.1 AESI\", 2)),\n SCOPE = c(\"BROAD\", \"BROAD\", \"BROAD\", \"\", \"\"),\n REFTERM = c(\"C.1.1.1.3\", \"B.2.2.3.1\", \"Z.9.9.9.9\", \"D.2.1.5.3\", \"A.1.1.1.1\"),\n stringsAsFactors = FALSE\n)\n\n# Create summary AAG dataset (used for labelling).\n# Note it's important to incorporate SCOPE into the basket names for SMQs so as to\n# match the flags present in ADAE.\naag_summary <- aag %>%\n select(NAMVAR, REFNAME, SCOPE) %>%\n unique() %>%\n mutate(\n REFNAME_SCOPE = ifelse(SCOPE == \"\", REFNAME, paste0(REFNAME, \"(\", SCOPE, \")\"))\n ) %>%\n rename(basket = NAMVAR, basket_name = REFNAME_SCOPE) %>%\n select(basket, basket_name)\n\n# Make a summary of the full ADAE based on AAG by using h_stack_by_baskets helper function\nadae_smq_all <- h_stack_by_baskets(df = adae_rel, aag_summary = aag_summary, keys = c(\"STUDYID\", \"USUBJID\", \"ACTARMCD\", \"AEDECOD\"))\n\n# Post-process adae_smq_all to keep only certain baskets of interest for variant 1\n# Not need to drop baskets for variant 2 as all baskets will be considered.\nbaskets_to_drop_variant <- aag_summary$basket_name[!aag_summary$basket %in% c(\"SMQ01NAM\")]\n\n# Adjust the analysis dataset based on basket subset for variant 1.\nadae_smq_1 <- adae_smq_all %>%\n filter(!adae_smq_all$SMQ %in% baskets_to_drop_variant) %>%\n mutate(\n SMQ = tern::fct_discard(SMQ, discard = baskets_to_drop_variant)\n )\n\n\n\n\n\nCodecriteria_fun <- function(tr) !is(tr, \"ContentRow\") && all_zero_or_na(tr)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = -1L,\n drop = FALSE\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt,\n df = adae_smq_1,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%)\n Total number of events 55 63 64 \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)\n\n\n\n\n\nCodecriteria_fun <- function(tr) {\n !is(tr, \"ContentRow\") && all_zero_or_na(tr) && !grepl(\"Total number of\", obj_label(tr))\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n drop = FALSE\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nscore_ae_pts <- function(tt) {\n count_vals <- cell_values(tree_children(tt)[[\"USUBJID\"]])[[1]]\n sum(matrix(unlist(count_vals), nrow = length(count_vals), byrow = TRUE)[, 1])\n}\n\nresult <- build_table(\n lyt,\n df = adae_smq_all,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = score_ae_pts) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 69 (51.5%) 78 (58.2%) 77 (58.3%)\nD.2.1.5.3/A.1.1.1.1 AESI \n Total number of patients with at least one adverse event 47 (35.1%) 58 (43.3%) 57 (43.2%)\n Total number of events 62 72 74 \n dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%)\n Total number of events 55 63 64 \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%)\nnon observed SMQ02NAM level(BROAD) \n Total number of patients with at least one adverse event 0 0 0 \n Total number of events 0 0 0 \n\n\n\n\nNote that filtering AEs for relatedness to study drug is not a necessary data pre-processing step for the module. It can be achieved using the teal module filter panel. The example here pre-sets the filters using AEREL = \"Y\" in adae.\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nnames_baskets <- grep(\"^(SMQ|CQ).*NAM$\", names(adae), value = TRUE)\nnames_scopes <- grep(\"^SMQ.*SC$\", names(adae), value = TRUE)\n\ncs_baskets <- choices_selected(\n choices = variable_choices(adae, subset = names_baskets),\n selected = names_baskets\n)\ncs_scopes <- choices_selected(\n choices = variable_choices(adae, subset = names_scopes),\n selected = names_scopes,\n fixed = TRUE\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'\n ),\n cdisc_dataset(\"ADAE\", adae,\n code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_smq(\n label = \"Adverse Events by SMQ Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"SEX\")),\n selected = \"ARM\"\n ),\n add_total = FALSE,\n baskets = cs_baskets,\n scopes = cs_scopes,\n llt = choices_selected(\n choices = variable_choices(adae, subset = c(\"AEDECOD\")),\n selected = \"AEDECOD\"\n )\n )\n ),\n filter = list(ADAE = list(AEREL = \"Y\"))\n)\n\n[INFO] 2023-09-09 18:00:08.0528 pid:5011 token:[] teal.modules.clinical Initializing tm_t_smq\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] stringr_1.5.0 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] stringi_1.7.12 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet02.html",
"href": "tables/adverse-events/aet02.html",
"title": "AET02",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Event Totals\nTable with High-Level Term\nTable with Preferred Terms Only\nTable with Fill-In of Treatment Groups\nTable of AEs with an Incidence Rate \\(\\geq\\) 5% in Any Treatment Group (subsetting preferred terms based on frequency)\nTable of AEs with an Incidence Rate \\(\\geq\\) 5% in Any Treatment Group (subsetting preferred terms based on frequency with high-level terms)\nTable of AEs with an Incidence Rate \\(\\geq\\) 10% in Any Treatment Group (subsetting preferred terms based on frequency)\nTable of AEs with an Incidence Rate \\(\\geq\\) 3 Patients in Any Treatment Group (subsetting preferred terms based on number of patients)\nTable of AEs with a Difference in Incidence Rate \\(\\geq\\) 5% Between Any Treatment (subsetting preferred terms based on difference in percentage between treatment groups)\nTable of AEs with an Incidence Rate \\(\\geq\\) 5% in B: Placebo (subsetting preferred terms based on frequency for a particular treatment group)\nTable of AEs with a Difference in Incidence Rate \\(\\geq\\) 5% Between Arm A and Arm B or Arm C (displaying preferred terms with a difference of at least x% between selected treatment groups)\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae) %>%\n var_relabel(\n AEBODSYS = \"MedDRA System Organ Class\",\n AEDECOD = \"MedDRA Preferred Term\"\n ) %>%\n filter(ANL01FL == \"Y\")\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = -1L\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl)\n\n\nThe variable result corresponds to the adverse events table. However, it includes many empty rows accounting for events which were not reported. The table can be post-processed to prune empty rows and to sort rows, for example by occurrence.\n\nCoderesult <- result %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients\n MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) 301 (75.2%) \nOverall total number of events 502 480 604 1586 \ncl A.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) 202 (50.5%) \n Total number of events 115 99 137 351 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) 128 (32.0%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) 122 (30.5%) \ncl B.2 \n Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) 192 (48.0%) \n Total number of events 102 106 127 335 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) 123 (30.8%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) 119 (29.8%) \ncl D.1 \n Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) 186 (46.5%) \n Total number of events 106 84 114 304 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) 120 (30.0%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) 112 (28.0%) \ncl D.2 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%) \n Total number of events 49 57 65 171 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%) \ncl C.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%) \n Total number of events 39 40 57 136 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%) \ncl B.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%) \n Total number of events 44 43 50 137 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%) \ncl C.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%) \n Total number of events 47 51 54 152 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L) %>%\n count_values(\n \"STUDYID\",\n values = as.character(unique(adae$STUDYID)),\n .stats = \"count\",\n .labels = c(count = \"Total number of events\"),\n .indent_mods = c(count = -1L)\n )\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>% # col_count = c(table(adsl$ACTARM), sum(table(adsl$ACTARM)))\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n )\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients\n MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) 301 (75.2%) \nOverall total number of events 502 480 604 1586 \ncl A.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) 202 (50.5%) \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) 128 (32.0%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) 122 (30.5%) \n Total number of events 115 99 137 351 \ncl B.2 \n Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) 192 (48.0%) \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) 123 (30.8%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) 119 (29.8%) \n Total number of events 102 106 127 335 \ncl D.1 \n Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) 186 (46.5%) \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) 120 (30.0%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) 112 (28.0%) \n Total number of events 106 84 114 304 \ncl D.2 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%) \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%) \n Total number of events 49 57 65 171 \ncl C.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%) \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%) \n Total number of events 39 40 57 136 \ncl B.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%) \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%) \n Total number of events 44 43 50 137 \ncl C.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%) \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%) \n Total number of events 47 51 54 152 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEHLT\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n indent_mod = -1L,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEHLT)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = c(count_fraction = -1L)) %>%\n append_varlabels(adae, c(\"AEDECOD\"), indent = 2L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedDRA System Organ Class \n High Level Term A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) \nOverall total number of events 502 480 604 \ncl A.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Total number of events 115 99 137 \n hlt A.1.1.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Total number of events 115 99 137 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Total number of events 102 106 127 \n hlt B.2.2.3 \n Total number of patients with at least one adverse event 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Total number of events 50 55 68 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n hlt B.2.1.2 \n Total number of patients with at least one adverse event 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Total number of events 52 51 59 \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Total number of events 106 84 114 \n hlt D.1.1.1 \n Total number of patients with at least one adverse event 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Total number of events 52 40 64 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n hlt D.1.1.4 \n Total number of patients with at least one adverse event 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Total number of events 54 44 50 \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Total number of events 49 57 65 \n hlt D.2.1.5 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Total number of events 49 57 65 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Total number of events 39 40 57 \n hlt C.2.1.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Total number of events 39 40 57 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Total number of events 44 43 50 \n hlt B.1.1.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Total number of events 44 43 50 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Total number of events 47 51 54 \n hlt C.1.1.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Total number of events 47 51 54 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"AEDECOD\") %>%\n append_varlabels(adae, \"AEDECOD\")\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n sort_at_path(\n path = c(\"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedDRA Preferred Term A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of events 502 480 604 \ndcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ndcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \ndcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \ndcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ndcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \ndcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ndcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ndcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ndcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ndcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodeadae_5 <- adae %>% dplyr::filter(ACTARM != \"C: Combination\")\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = c(count_fraction = -1L)) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae_5, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 0 \nOverall total number of events 502 480 0 \ncl A.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 0 \n Total number of events 115 99 0 \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 0 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 0 \ncl B.2 \n Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 0 \n Total number of events 102 106 0 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 0 \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 0 \ncl D.1 \n Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 0 \n Total number of events 106 84 0 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 0 \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 0 \ncl D.2 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 0 \n Total number of events 49 57 0 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 0 \ncl B.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 0 \n Total number of events 44 43 0 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 0 \ncl C.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 0 \n Total number of events 47 51 0 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 0 \ncl C.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 0 \n Total number of events 39 40 0 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 0 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fraction_in_any_col(\n atleast = 0.05,\n col_names = names(table(adsl$ACTARM))\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n split_rows_by(\n \"AEHLT\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEHLT)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(vars = \"AEDECOD\") %>%\n append_varlabels(adae, c(\"AEDECOD\"), indent = 2L)\n\nresult <- build_table(lyt, adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\"),\n scorefun = cont_n_allcols,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences,\n decreasing = TRUE\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fraction_in_any_col(\n atleast = 0.05,\n col_names = names(table(adsl$ACTARM))\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class \n High Level Term A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n hlt A.1.1.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n hlt B.2.2.3 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n hlt B.2.1.2 \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n hlt D.1.1.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n hlt D.1.1.4 \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n hlt D.2.1.5 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n hlt C.2.1.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n hlt B.1.1.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n hlt C.1.1.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fraction_in_any_col(\n atleast = 0.10,\n col_names = names(table(adsl$ACTARM))\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n split_label = obj_label(adae$AEBODSYS),\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_count_in_any_col(\n atleast = 3,\n col_names = names(table(adsl$ACTARM))\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fractions_difference(\n atleast = 0.05,\n col_names = levels(adsl$ACTARM)\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fraction_in_cols(\n atleast = 0.05,\n col_names = c(\"B: Placebo\")\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition1 <- has_fractions_difference(atleast = 0.05, col_names = c(\"A: Drug X\", \"B: Placebo\"))\nrow_condition2 <- has_fractions_difference(atleast = 0.05, col_names = c(\"A: Drug X\", \"C: Combination\"))\nrow_condition <- row_condition1 | row_condition2\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adae\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Event Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n add_total = TRUE,\n event_type = \"adverse event\"\n )\n )\n)\n\n[INFO] 2023-09-08 19:42:14.5627 pid:5202 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Event Totals\nTable with High-Level Term\nTable with Preferred Terms Only\nTable with Fill-In of Treatment Groups\nTable of AEs with an Incidence Rate \\(\\geq\\) 5% in Any Treatment Group (subsetting preferred terms based on frequency)\nTable of AEs with an Incidence Rate \\(\\geq\\) 5% in Any Treatment Group (subsetting preferred terms based on frequency with high-level terms)\nTable of AEs with an Incidence Rate \\(\\geq\\) 10% in Any Treatment Group (subsetting preferred terms based on frequency)\nTable of AEs with an Incidence Rate \\(\\geq\\) 3 Patients in Any Treatment Group (subsetting preferred terms based on number of patients)\nTable of AEs with a Difference in Incidence Rate \\(\\geq\\) 5% Between Any Treatment (subsetting preferred terms based on difference in percentage between treatment groups)\nTable of AEs with an Incidence Rate \\(\\geq\\) 5% in B: Placebo (subsetting preferred terms based on frequency for a particular treatment group)\nTable of AEs with a Difference in Incidence Rate \\(\\geq\\) 5% Between Arm A and Arm B or Arm C (displaying preferred terms with a difference of at least x% between selected treatment groups)\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae) %>%\n var_relabel(\n AEBODSYS = \"MedDRA System Organ Class\",\n AEDECOD = \"MedDRA Preferred Term\"\n ) %>%\n filter(ANL01FL == \"Y\")\n\n# Define the split function\nsplit_fun <- drop_split_levels\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = -1L\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl)\n\n\nThe variable result corresponds to the adverse events table. However, it includes many empty rows accounting for events which were not reported. The table can be post-processed to prune empty rows and to sort rows, for example by occurrence.\n\nCoderesult <- result %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients\n MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) 301 (75.2%) \nOverall total number of events 502 480 604 1586 \ncl A.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) 202 (50.5%) \n Total number of events 115 99 137 351 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) 128 (32.0%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) 122 (30.5%) \ncl B.2 \n Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) 192 (48.0%) \n Total number of events 102 106 127 335 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) 123 (30.8%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) 119 (29.8%) \ncl D.1 \n Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) 186 (46.5%) \n Total number of events 106 84 114 304 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) 120 (30.0%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) 112 (28.0%) \ncl D.2 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%) \n Total number of events 49 57 65 171 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%) \ncl C.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%) \n Total number of events 39 40 57 136 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%) \ncl B.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%) \n Total number of events 44 43 50 137 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%) \ncl C.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%) \n Total number of events 47 51 54 152 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L) %>%\n count_values(\n \"STUDYID\",\n values = as.character(unique(adae$STUDYID)),\n .stats = \"count\",\n .labels = c(count = \"Total number of events\"),\n .indent_mods = c(count = -1L)\n )\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>% # col_count = c(table(adsl$ACTARM), sum(table(adsl$ACTARM)))\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n )\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination All Patients\n MedDRA Preferred Term (N=134) (N=134) (N=132) (N=400) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) 301 (75.2%) \nOverall total number of events 502 480 604 1586 \ncl A.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) 202 (50.5%) \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) 128 (32.0%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) 122 (30.5%) \n Total number of events 115 99 137 351 \ncl B.2 \n Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) 192 (48.0%) \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) 123 (30.8%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) 119 (29.8%) \n Total number of events 102 106 127 335 \ncl D.1 \n Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) 186 (46.5%) \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) 120 (30.0%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) 112 (28.0%) \n Total number of events 106 84 114 304 \ncl D.2 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%) \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) 133 (33.2%) \n Total number of events 49 57 65 171 \ncl C.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%) \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) 112 (28.0%) \n Total number of events 39 40 57 136 \ncl B.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%) \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) 111 (27.8%) \n Total number of events 44 43 50 137 \ncl C.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%) \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) 106 (26.5%) \n Total number of events 47 51 54 152 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEHLT\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n indent_mod = -1L,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEHLT)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = c(count_fraction = -1L)) %>%\n append_varlabels(adae, c(\"AEDECOD\"), indent = 2L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedDRA System Organ Class \n High Level Term A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) \nOverall total number of events 502 480 604 \ncl A.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Total number of events 115 99 137 \n hlt A.1.1.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 76 (57.6%) \n Total number of events 115 99 137 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 74 (56.1%) \n Total number of events 102 106 127 \n hlt B.2.2.3 \n Total number of patients with at least one adverse event 38 (28.4%) 40 (29.9%) 45 (34.1%) \n Total number of events 50 55 68 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n hlt B.2.1.2 \n Total number of patients with at least one adverse event 39 (29.1%) 34 (25.4%) 46 (34.8%) \n Total number of events 52 51 59 \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 68 (51.5%) \n Total number of events 106 84 114 \n hlt D.1.1.1 \n Total number of patients with at least one adverse event 42 (31.3%) 32 (23.9%) 46 (34.8%) \n Total number of events 52 40 64 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n hlt D.1.1.4 \n Total number of patients with at least one adverse event 38 (28.4%) 34 (25.4%) 40 (30.3%) \n Total number of events 54 44 50 \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Total number of events 49 57 65 \n hlt D.2.1.5 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 50 (37.9%) \n Total number of events 49 57 65 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Total number of events 39 40 57 \n hlt C.2.1.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 48 (36.4%) \n Total number of events 39 40 57 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Total number of events 44 43 50 \n hlt B.1.1.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 36 (27.3%) \n Total number of events 44 43 50 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Total number of events 47 51 54 \n hlt C.1.1.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 36 (27.3%) \n Total number of events 47 51 54 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"AEDECOD\") %>%\n append_varlabels(adae, \"AEDECOD\")\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n sort_at_path(\n path = c(\"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedDRA Preferred Term A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of events 502 480 604 \ndcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ndcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \ndcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \ndcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ndcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \ndcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ndcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ndcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ndcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ndcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodeadae_5 <- adae %>% dplyr::filter(ACTARM != \"C: Combination\")\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = c(count_fraction = -1L)) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae_5, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 100 (74.6%) 98 (73.1%) 0 \nOverall total number of events 502 480 0 \ncl A.1 \n Total number of patients with at least one adverse event 68 (50.7%) 58 (43.3%) 0 \n Total number of events 115 99 0 \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 0 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 0 \ncl B.2 \n Total number of patients with at least one adverse event 62 (46.3%) 56 (41.8%) 0 \n Total number of events 102 106 0 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 0 \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 0 \ncl D.1 \n Total number of patients with at least one adverse event 64 (47.8%) 54 (40.3%) 0 \n Total number of events 106 84 0 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 0 \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 0 \ncl D.2 \n Total number of patients with at least one adverse event 37 (27.6%) 46 (34.3%) 0 \n Total number of events 49 57 0 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 0 \ncl B.1 \n Total number of patients with at least one adverse event 38 (28.4%) 37 (27.6%) 0 \n Total number of events 44 43 0 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 0 \ncl C.1 \n Total number of patients with at least one adverse event 36 (26.9%) 34 (25.4%) 0 \n Total number of events 47 51 0 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 0 \ncl C.2 \n Total number of patients with at least one adverse event 28 (20.9%) 36 (26.9%) 0 \n Total number of events 39 40 0 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 0 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fraction_in_any_col(\n atleast = 0.05,\n col_names = names(table(adsl$ACTARM))\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n split_rows_by(\n \"AEHLT\",\n child_labels = \"visible\",\n nested = TRUE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEHLT)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(vars = \"AEDECOD\") %>%\n append_varlabels(adae, c(\"AEDECOD\"), indent = 2L)\n\nresult <- build_table(lyt, adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\"),\n scorefun = cont_n_allcols,\n decreasing = TRUE\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences,\n decreasing = TRUE\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fraction_in_any_col(\n atleast = 0.05,\n col_names = names(table(adsl$ACTARM))\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class \n High Level Term A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n hlt A.1.1.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n hlt B.2.2.3 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n hlt B.2.1.2 \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n hlt D.1.1.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n hlt D.1.1.4 \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n hlt D.2.1.5 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n hlt C.2.1.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n hlt B.1.1.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n hlt C.1.1.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fraction_in_any_col(\n atleast = 0.10,\n col_names = names(table(adsl$ACTARM))\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n split_label = obj_label(adae$AEBODSYS),\n label_pos = \"topleft\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_count_in_any_col(\n atleast = 3,\n col_names = names(table(adsl$ACTARM))\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fractions_difference(\n atleast = 0.05,\n col_names = levels(adsl$ACTARM)\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition <- has_fraction_in_cols(\n atleast = 0.05,\n col_names = c(\"B: Placebo\")\n)\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \n dcd A.1.1.1.2 41 (30.6%) 39 (29.1%) 42 (31.8%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \n dcd D.1.1.4.2 38 (28.4%) 34 (25.4%) 40 (30.3%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \ncl B.1 \n dcd B.1.1.1.1 38 (28.4%) 37 (27.6%) 36 (27.3%) \ncl C.1 \n dcd C.1.1.1.3 36 (26.9%) 34 (25.4%) 36 (27.3%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ACTARM\") %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = \"Total number of patients with at least one adverse event\"\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = 1L)\n ) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(lyt, df = adae, alt_counts_df = adsl) %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\ncriteria_fun <- function(tr) is(tr, \"ContentRow\")\nresult <- trim_rows(result, criteria = criteria_fun)\n\nrow_condition1 <- has_fractions_difference(atleast = 0.05, col_names = c(\"A: Drug X\", \"B: Placebo\"))\nrow_condition2 <- has_fractions_difference(atleast = 0.05, col_names = c(\"A: Drug X\", \"C: Combination\"))\nrow_condition <- row_condition1 | row_condition2\nresult <- prune_table(result, keep_rows(row_condition))\n\nresult\n\nMedDRA System Organ Class A: Drug X B: Placebo C: Combination\n MedDRA Preferred Term (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————\ncl A.1 \n dcd A.1.1.1.1 45 (33.6%) 31 (23.1%) 52 (39.4%) \ncl B.2 \n dcd B.2.2.3.1 38 (28.4%) 40 (29.9%) 45 (34.1%) \n dcd B.2.1.2.1 39 (29.1%) 34 (25.4%) 46 (34.8%) \ncl D.1 \n dcd D.1.1.1.1 42 (31.3%) 32 (23.9%) 46 (34.8%) \ncl D.2 \n dcd D.2.1.5.3 37 (27.6%) 46 (34.3%) 50 (37.9%) \ncl C.2 \n dcd C.2.1.2.1 28 (20.9%) 36 (26.9%) 48 (36.4%) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adae\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Event Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n add_total = TRUE,\n event_type = \"adverse event\"\n )\n )\n)\n\n[INFO] 2023-09-09 18:01:35.9675 pid:5207 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet06.html",
"href": "tables/adverse-events/aet06.html",
"title": "AET06",
"section": "",
- "text": "Data Setup\nAdverse Events by Sex\nAdverse Events by Other Baseline Characteristics (e.g. Biomarker Group)\nAdverse Events by Baseline Characteristic from ADSUB (e.g. BMI Category)\nAdverse Events by Regrouped Baseline Characteristics (e.g. Race)\nAdverse Events by Baseline Characteristics (e.g. Sex) Including High-Level Terms\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\nadsub <- synthetic_cdisc_dataset(\"latest\", \"adsub\")\n\nadsub_bmi <- adsub %>%\n filter(PARAMCD == \"BBMISI\") %>%\n select(STUDYID, USUBJID, AVALCAT1) %>%\n mutate(\n AVALCAT1 = factor(AVALCAT1, levels = c(\"<18.5\", \"18.5 - 24.9\", \"25 - 29.9\", \">30\"))\n )\n\nadsl <- adsl %>%\n mutate(\n RACE1 = case_when(\n RACE == \"WHITE\" ~ \"WHITE\",\n TRUE ~ \"NON-WHITE\"\n ),\n RACE1 = factor(\n RACE1,\n levels = c(\"WHITE\", \"NON-WHITE\")\n )\n ) %>%\n left_join(\n y = adsub_bmi,\n by = c(\"STUDYID\", \"USUBJID\")\n )\n\nadae_labels <- var_labels(adae)\n\nadae <- adae %>%\n mutate(\n RACE1 = case_when(\n RACE == \"WHITE\" ~ \"WHITE\",\n TRUE ~ \"NON-WHITE\"\n ),\n RACE1 = factor(\n RACE1,\n levels = c(\"WHITE\", \"NON-WHITE\")\n )\n ) %>%\n left_join(\n y = adsub_bmi,\n by = c(\"STUDYID\", \"USUBJID\")\n )\n\nvar_labels(adae) <- c(adae_labels, \"RACE1\" = \"RACE WHITE/NON-WHITE\", \"AVALCAT1\" = \"Baseline BMI Category\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\nadsub_bmi <- df_explicit_na(adsub_bmi)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"SEX\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n Dictionary-Derived Term F M F M F M \n (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 72 (91.1%) 50 (90.9%) 77 (93.9%) 46 (88.5%) 65 (92.9%) 55 (88.7%)\nOverall total number of events 377 232 419 203 378 325 \ncl A.1 \n Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%)\n Total number of events 85 47 93 37 86 74 \n dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%)\n dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%)\ncl B.2 \n Total number of patients with at least one adverse event 46 (58.2%) 33 (60.0%) 45 (54.9%) 29 (55.8%) 44 (62.9%) 41 (66.1%)\n Total number of events 81 48 86 52 64 79 \n dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n dcd B.2.1.2.1 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%)\ncl D.1 \n Total number of patients with at least one adverse event 45 (57.0%) 34 (61.8%) 40 (48.8%) 27 (51.9%) 41 (58.6%) 39 (62.9%)\n Total number of events 72 55 64 42 73 62 \n dcd D.1.1.1.1 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%)\n dcd D.1.1.4.2 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%)\ncl D.2 \n Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\n Total number of events 35 27 49 23 43 31 \n dcd D.2.1.5.3 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\ncl B.1 \n Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\n Total number of events 33 23 36 24 35 27 \n dcd B.1.1.1.1 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\ncl C.2 \n Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\n Total number of events 32 16 39 14 33 32 \n dcd C.2.1.2.1 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\ncl C.1 \n Total number of patients with at least one adverse event 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n Total number of events 39 16 52 11 44 20 \n dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"BMRKR2\") %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n Dictionary-Derived Term LOW MEDIUM HIGH LOW MEDIUM HIGH LOW MEDIUM HIGH \n (N=50) (N=37) (N=47) (N=45) (N=56) (N=33) (N=40) (N=42) (N=50) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 46 (92.0%) 34 (91.9%) 42 (89.4%) 40 (88.9%) 53 (94.6%) 30 (90.9%) 36 (90.0%) 39 (92.9%) 45 (90.0%)\nOverall total number of events 248 166 195 196 261 165 220 258 225 \ncl A.1 \n Total number of patients with at least one adverse event 31 (62.0%) 19 (51.4%) 28 (59.6%) 25 (55.6%) 31 (55.4%) 19 (57.6%) 28 (70.0%) 30 (71.4%) 31 (62.0%)\n Total number of events 53 34 45 46 54 30 61 51 48 \n dcd A.1.1.1.1 22 (44.0%) 10 (27.0%) 18 (38.3%) 14 (31.1%) 20 (35.7%) 11 (33.3%) 21 (52.5%) 24 (57.1%) 18 (36.0%)\n dcd A.1.1.1.2 17 (34.0%) 13 (35.1%) 18 (38.3%) 18 (40.0%) 18 (32.1%) 12 (36.4%) 18 (45.0%) 14 (33.3%) 18 (36.0%)\ncl B.2 \n Total number of patients with at least one adverse event 34 (68.0%) 21 (56.8%) 24 (51.1%) 23 (51.1%) 33 (58.9%) 18 (54.5%) 24 (60.0%) 27 (64.3%) 34 (68.0%)\n Total number of events 53 37 39 40 61 37 40 47 56 \n dcd B.2.2.3.1 21 (42.0%) 13 (35.1%) 14 (29.8%) 18 (40.0%) 22 (39.3%) 14 (42.4%) 16 (40.0%) 15 (35.7%) 20 (40.0%)\n dcd B.2.1.2.1 21 (42.0%) 11 (29.7%) 17 (36.2%) 11 (24.4%) 21 (37.5%) 12 (36.4%) 13 (32.5%) 17 (40.5%) 22 (44.0%)\ncl D.1 \n Total number of patients with at least one adverse event 34 (68.0%) 21 (56.8%) 24 (51.1%) 18 (40.0%) 33 (58.9%) 16 (48.5%) 25 (62.5%) 31 (73.8%) 24 (48.0%)\n Total number of events 51 35 41 27 49 30 45 53 37 \n dcd D.1.1.1.1 19 (38.0%) 16 (43.2%) 15 (31.9%) 13 (28.9%) 19 (33.9%) 10 (30.3%) 14 (35.0%) 22 (52.4%) 15 (30.0%)\n dcd D.1.1.4.2 21 (42.0%) 9 (24.3%) 18 (38.3%) 9 (20.0%) 20 (35.7%) 13 (39.4%) 17 (42.5%) 18 (42.9%) 15 (30.0%)\ncl D.2 \n Total number of patients with at least one adverse event 20 (40.0%) 12 (32.4%) 15 (31.9%) 19 (42.2%) 22 (39.3%) 17 (51.5%) 13 (32.5%) 23 (54.8%) 21 (42.0%)\n Total number of events 27 13 22 23 26 23 17 33 24 \n dcd D.2.1.5.3 20 (40.0%) 12 (32.4%) 15 (31.9%) 19 (42.2%) 22 (39.3%) 17 (51.5%) 13 (32.5%) 23 (54.8%) 21 (42.0%)\ncl B.1 \n Total number of patients with at least one adverse event 14 (28.0%) 14 (37.8%) 19 (40.4%) 15 (33.3%) 24 (42.9%) 10 (30.3%) 14 (35.0%) 15 (35.7%) 14 (28.0%)\n Total number of events 16 19 21 18 25 17 19 25 18 \n dcd B.1.1.1.1 14 (28.0%) 14 (37.8%) 19 (40.4%) 15 (33.3%) 24 (42.9%) 10 (30.3%) 14 (35.0%) 15 (35.7%) 14 (28.0%)\ncl C.2 \n Total number of patients with at least one adverse event 18 (36.0%) 8 (21.6%) 9 (19.1%) 15 (33.3%) 22 (39.3%) 11 (33.3%) 18 (45.0%) 17 (40.5%) 20 (40.0%)\n Total number of events 27 9 12 18 23 12 20 20 25 \n dcd C.2.1.2.1 18 (36.0%) 8 (21.6%) 9 (19.1%) 15 (33.3%) 22 (39.3%) 11 (33.3%) 18 (45.0%) 17 (40.5%) 20 (40.0%)\ncl C.1 \n Total number of patients with at least one adverse event 17 (34.0%) 14 (37.8%) 12 (25.5%) 17 (37.8%) 17 (30.4%) 12 (36.4%) 12 (30.0%) 17 (40.5%) 14 (28.0%)\n Total number of events 21 19 15 24 23 16 18 29 17 \n dcd C.1.1.1.3 17 (34.0%) 14 (37.8%) 12 (25.5%) 17 (37.8%) 17 (30.4%) 12 (36.4%) 12 (30.0%) 17 (40.5%) 14 (28.0%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"AVALCAT1\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n Dictionary-Derived Term <18.5 18.5 - 24.9 25 - 29.9 >30 <18.5 18.5 - 24.9 25 - 29.9 >30 <18.5 18.5 - 24.9 25 - 29.9 >30 \n (N=44) (N=17) (N=11) (N=62) (N=37) (N=18) (N=10) (N=69) (N=28) (N=20) (N=18) (N=66) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 41 (93.2%) 14 (82.4%) 11 (100%) 56 (90.3%) 35 (94.6%) 16 (88.9%) 9 (90.0%) 63 (91.3%) 25 (89.3%) 19 (95.0%) 15 (83.3%) 61 (92.4%)\nOverall total number of events 186 80 66 277 174 89 47 312 137 129 100 337 \ncl A.1 \n Total number of patients with at least one adverse event 23 (52.3%) 12 (70.6%) 7 (63.6%) 36 (58.1%) 19 (51.4%) 10 (55.6%) 6 (60.0%) 40 (58.0%) 16 (57.1%) 13 (65.0%) 14 (77.8%) 46 (69.7%)\n Total number of events 38 22 13 59 35 22 6 67 30 23 30 77 \n dcd A.1.1.1.1 14 (31.8%) 7 (41.2%) 3 (27.3%) 26 (41.9%) 12 (32.4%) 6 (33.3%) 4 (40.0%) 23 (33.3%) 12 (42.9%) 7 (35.0%) 13 (72.2%) 31 (47.0%)\n dcd A.1.1.1.2 15 (34.1%) 8 (47.1%) 5 (45.5%) 20 (32.3%) 12 (32.4%) 8 (44.4%) 2 (20.0%) 26 (37.7%) 9 (32.1%) 7 (35.0%) 7 (38.9%) 27 (40.9%)\ncl B.2 \n Total number of patients with at least one adverse event 23 (52.3%) 10 (58.8%) 8 (72.7%) 38 (61.3%) 21 (56.8%) 8 (44.4%) 7 (70.0%) 38 (55.1%) 16 (57.1%) 16 (80.0%) 12 (66.7%) 41 (62.1%)\n Total number of events 37 19 12 61 41 18 12 67 28 28 18 69 \n dcd B.2.2.3.1 13 (29.5%) 7 (41.2%) 6 (54.5%) 22 (35.5%) 14 (37.8%) 7 (38.9%) 6 (60.0%) 27 (39.1%) 7 (25.0%) 13 (65.0%) 5 (27.8%) 26 (39.4%)\n dcd B.2.1.2.1 14 (31.8%) 8 (47.1%) 4 (36.4%) 23 (37.1%) 14 (37.8%) 6 (33.3%) 4 (40.0%) 20 (29.0%) 13 (46.4%) 8 (40.0%) 8 (44.4%) 23 (34.8%)\ncl D.1 \n Total number of patients with at least one adverse event 24 (54.5%) 9 (52.9%) 8 (72.7%) 38 (61.3%) 18 (48.6%) 5 (27.8%) 7 (70.0%) 37 (53.6%) 15 (53.6%) 12 (60.0%) 11 (61.1%) 42 (63.6%)\n Total number of events 38 11 17 61 30 11 14 51 30 23 16 66 \n dcd D.1.1.1.1 13 (29.5%) 7 (41.2%) 7 (63.6%) 23 (37.1%) 13 (35.1%) 3 (16.7%) 4 (40.0%) 22 (31.9%) 12 (42.9%) 6 (30.0%) 8 (44.4%) 25 (37.9%)\n dcd D.1.1.4.2 16 (36.4%) 4 (23.5%) 6 (54.5%) 22 (35.5%) 10 (27.0%) 4 (22.2%) 5 (50.0%) 23 (33.3%) 10 (35.7%) 9 (45.0%) 6 (33.3%) 25 (37.9%)\ncl D.2 \n Total number of patients with at least one adverse event 14 (31.8%) 7 (41.2%) 5 (45.5%) 21 (33.9%) 14 (37.8%) 10 (55.6%) 4 (40.0%) 30 (43.5%) 13 (46.4%) 10 (50.0%) 7 (38.9%) 27 (40.9%)\n Total number of events 20 7 10 25 17 14 5 36 18 15 10 31 \n dcd D.2.1.5.3 14 (31.8%) 7 (41.2%) 5 (45.5%) 21 (33.9%) 14 (37.8%) 10 (55.6%) 4 (40.0%) 30 (43.5%) 13 (46.4%) 10 (50.0%) 7 (38.9%) 27 (40.9%)\ncl B.1 \n Total number of patients with at least one adverse event 17 (38.6%) 5 (29.4%) 7 (63.6%) 18 (29.0%) 14 (37.8%) 8 (44.4%) 4 (40.0%) 23 (33.3%) 7 (25.0%) 10 (50.0%) 7 (38.9%) 19 (28.8%)\n Total number of events 22 5 7 22 16 11 4 29 11 12 8 31 \n dcd B.1.1.1.1 17 (38.6%) 5 (29.4%) 7 (63.6%) 18 (29.0%) 14 (37.8%) 8 (44.4%) 4 (40.0%) 23 (33.3%) 7 (25.0%) 10 (50.0%) 7 (38.9%) 19 (28.8%)\ncl C.2 \n Total number of patients with at least one adverse event 14 (31.8%) 4 (23.5%) 2 (18.2%) 15 (24.2%) 15 (40.5%) 5 (27.8%) 4 (40.0%) 24 (34.8%) 10 (35.7%) 13 (65.0%) 8 (44.4%) 24 (36.4%)\n Total number of events 17 9 3 19 15 6 5 27 12 16 9 28 \n dcd C.2.1.2.1 14 (31.8%) 4 (23.5%) 2 (18.2%) 15 (24.2%) 15 (40.5%) 5 (27.8%) 4 (40.0%) 24 (34.8%) 10 (35.7%) 13 (65.0%) 8 (44.4%) 24 (36.4%)\ncl C.1 \n Total number of patients with at least one adverse event 11 (25.0%) 4 (23.5%) 4 (36.4%) 24 (38.7%) 13 (35.1%) 6 (33.3%) 1 (10.0%) 26 (37.7%) 6 (21.4%) 7 (35.0%) 6 (33.3%) 24 (36.4%)\n Total number of events 14 7 4 30 20 7 1 35 8 12 9 35 \n dcd C.1.1.1.3 11 (25.0%) 4 (23.5%) 4 (36.4%) 24 (38.7%) 13 (35.1%) 6 (33.3%) 1 (10.0%) 26 (37.7%) 6 (21.4%) 7 (35.0%) 6 (33.3%) 24 (36.4%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"RACE1\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n Dictionary-Derived Term WHITE NON-WHITE WHITE NON-WHITE WHITE NON-WHITE \n (N=27) (N=107) (N=26) (N=108) (N=21) (N=111) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 26 (96.3%) 96 (89.7%) 25 (96.2%) 98 (90.7%) 21 (100%) 99 (89.2%)\nOverall total number of events 109 500 144 478 114 589 \ncl A.1 \n Total number of patients with at least one adverse event 16 (59.3%) 62 (57.9%) 21 (80.8%) 54 (50.0%) 15 (71.4%) 74 (66.7%)\n Total number of events 30 102 37 93 25 135 \n dcd A.1.1.1.1 9 (33.3%) 41 (38.3%) 14 (53.8%) 31 (28.7%) 10 (47.6%) 53 (47.7%)\n dcd A.1.1.1.2 11 (40.7%) 37 (34.6%) 13 (50.0%) 35 (32.4%) 9 (42.9%) 41 (36.9%)\ncl B.2 \n Total number of patients with at least one adverse event 15 (55.6%) 64 (59.8%) 16 (61.5%) 58 (53.7%) 12 (57.1%) 73 (65.8%)\n Total number of events 18 111 28 110 17 126 \n dcd B.2.2.3.1 4 (14.8%) 44 (41.1%) 10 (38.5%) 44 (40.7%) 5 (23.8%) 46 (41.4%)\n dcd B.2.1.2.1 12 (44.4%) 37 (34.6%) 9 (34.6%) 35 (32.4%) 7 (33.3%) 45 (40.5%)\ncl D.1 \n Total number of patients with at least one adverse event 18 (66.7%) 61 (57.0%) 15 (57.7%) 52 (48.1%) 14 (66.7%) 66 (59.5%)\n Total number of events 27 100 23 83 27 108 \n dcd D.1.1.1.1 11 (40.7%) 39 (36.4%) 14 (53.8%) 28 (25.9%) 12 (57.1%) 39 (35.1%)\n dcd D.1.1.4.2 11 (40.7%) 37 (34.6%) 7 (26.9%) 35 (32.4%) 9 (42.9%) 41 (36.9%)\ncl D.2 \n Total number of patients with at least one adverse event 6 (22.2%) 41 (38.3%) 15 (57.7%) 43 (39.8%) 9 (42.9%) 48 (43.2%)\n Total number of events 6 56 18 54 12 62 \n dcd D.2.1.5.3 6 (22.2%) 41 (38.3%) 15 (57.7%) 43 (39.8%) 9 (42.9%) 48 (43.2%)\ncl B.1 \n Total number of patients with at least one adverse event 12 (44.4%) 35 (32.7%) 7 (26.9%) 42 (38.9%) 6 (28.6%) 37 (33.3%)\n Total number of events 15 41 8 52 8 54 \n dcd B.1.1.1.1 12 (44.4%) 35 (32.7%) 7 (26.9%) 42 (38.9%) 6 (28.6%) 37 (33.3%)\ncl C.2 \n Total number of patients with at least one adverse event 5 (18.5%) 30 (28.0%) 11 (42.3%) 37 (34.3%) 11 (52.4%) 44 (39.6%)\n Total number of events 8 40 12 41 12 53 \n dcd C.2.1.2.1 5 (18.5%) 30 (28.0%) 11 (42.3%) 37 (34.3%) 11 (52.4%) 44 (39.6%)\ncl C.1 \n Total number of patients with at least one adverse event 5 (18.5%) 38 (35.5%) 13 (50.0%) 33 (30.6%) 8 (38.1%) 35 (31.5%)\n Total number of events 5 50 18 45 13 51 \n dcd C.1.1.1.3 5 (18.5%) 38 (35.5%) 13 (50.0%) 33 (30.6%) 8 (38.1%) 35 (31.5%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"SEX\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEHLT\",\n child_labels = \"visible\",\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEHLT)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(\"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 2L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class, High-Level Term and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n High Level Term F M F M F M \n Dictionary-Derived Term (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 72 (91.1%) 50 (90.9%) 77 (93.9%) 46 (88.5%) 65 (92.9%) 55 (88.7%)\nOverall total number of events 377 232 419 203 378 325 \ncl A.1 \n Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%)\n Total number of events 85 47 93 37 86 74 \n hlt A.1.1.1 \n Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%)\n Total number of events 85 47 93 37 86 74 \n dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%)\n dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%)\ncl B.2 \n Total number of patients with at least one adverse event 46 (58.2%) 33 (60.0%) 45 (54.9%) 29 (55.8%) 44 (62.9%) 41 (66.1%)\n Total number of events 81 48 86 52 64 79 \n hlt B.2.2.3 \n Total number of patients with at least one adverse event 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n Total number of events 40 24 43 33 37 40 \n dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n hlt B.2.1.2 \n Total number of patients with at least one adverse event 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%)\n Total number of events 41 24 43 19 27 39 \n dcd B.2.1.2.1 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%)\ncl D.1 \n Total number of patients with at least one adverse event 45 (57.0%) 34 (61.8%) 40 (48.8%) 27 (51.9%) 41 (58.6%) 39 (62.9%)\n Total number of events 72 55 64 42 73 62 \n hlt D.1.1.1 \n Total number of patients with at least one adverse event 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%)\n Total number of events 32 29 36 15 39 32 \n dcd D.1.1.1.1 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%)\n hlt D.1.1.4 \n Total number of patients with at least one adverse event 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%)\n Total number of events 40 26 28 27 34 30 \n dcd D.1.1.4.2 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%)\ncl D.2 \n Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\n Total number of events 35 27 49 23 43 31 \n hlt D.2.1.5 \n Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\n Total number of events 35 27 49 23 43 31 \n dcd D.2.1.5.3 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\ncl B.1 \n Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\n Total number of events 33 23 36 24 35 27 \n hlt B.1.1.1 \n Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\n Total number of events 33 23 36 24 35 27 \n dcd B.1.1.1.1 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\ncl C.2 \n Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\n Total number of events 32 16 39 14 33 32 \n hlt C.2.1.2 \n Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\n Total number of events 32 16 39 14 33 32 \n dcd C.2.1.2.1 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\ncl C.1 \n Total number of patients with at least one adverse event 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n Total number of events 39 16 52 11 44 20 \n hlt C.1.1.1 \n Total number of patients with at least one adverse event 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n Total number of events 39 16 52 11 44 20 \n dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adae\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Event Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\", \"SEX\"), c(\"ARM\", \"SEX\")),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n add_total = TRUE,\n event_type = \"adverse event\"\n )\n )\n)\n\n[INFO] 2023-09-08 19:43:22.7734 pid:5398 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nAdverse Events by Sex\nAdverse Events by Other Baseline Characteristics (e.g. Biomarker Group)\nAdverse Events by Baseline Characteristic from ADSUB (e.g. BMI Category)\nAdverse Events by Regrouped Baseline Characteristics (e.g. Race)\nAdverse Events by Baseline Characteristics (e.g. Sex) Including High-Level Terms\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\nadsub <- synthetic_cdisc_dataset(\"latest\", \"adsub\")\n\nadsub_bmi <- adsub %>%\n filter(PARAMCD == \"BBMISI\") %>%\n select(STUDYID, USUBJID, AVALCAT1) %>%\n mutate(\n AVALCAT1 = factor(AVALCAT1, levels = c(\"<18.5\", \"18.5 - 24.9\", \"25 - 29.9\", \">30\"))\n )\n\nadsl <- adsl %>%\n mutate(\n RACE1 = case_when(\n RACE == \"WHITE\" ~ \"WHITE\",\n TRUE ~ \"NON-WHITE\"\n ),\n RACE1 = factor(\n RACE1,\n levels = c(\"WHITE\", \"NON-WHITE\")\n )\n ) %>%\n left_join(\n y = adsub_bmi,\n by = c(\"STUDYID\", \"USUBJID\")\n )\n\nadae_labels <- var_labels(adae)\n\nadae <- adae %>%\n mutate(\n RACE1 = case_when(\n RACE == \"WHITE\" ~ \"WHITE\",\n TRUE ~ \"NON-WHITE\"\n ),\n RACE1 = factor(\n RACE1,\n levels = c(\"WHITE\", \"NON-WHITE\")\n )\n ) %>%\n left_join(\n y = adsub_bmi,\n by = c(\"STUDYID\", \"USUBJID\")\n )\n\nvar_labels(adae) <- c(adae_labels, \"RACE1\" = \"RACE WHITE/NON-WHITE\", \"AVALCAT1\" = \"Baseline BMI Category\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\nadsub_bmi <- df_explicit_na(adsub_bmi)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"SEX\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n Dictionary-Derived Term F M F M F M \n (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 72 (91.1%) 50 (90.9%) 77 (93.9%) 46 (88.5%) 65 (92.9%) 55 (88.7%)\nOverall total number of events 377 232 419 203 378 325 \ncl A.1 \n Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%)\n Total number of events 85 47 93 37 86 74 \n dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%)\n dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%)\ncl B.2 \n Total number of patients with at least one adverse event 46 (58.2%) 33 (60.0%) 45 (54.9%) 29 (55.8%) 44 (62.9%) 41 (66.1%)\n Total number of events 81 48 86 52 64 79 \n dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n dcd B.2.1.2.1 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%)\ncl D.1 \n Total number of patients with at least one adverse event 45 (57.0%) 34 (61.8%) 40 (48.8%) 27 (51.9%) 41 (58.6%) 39 (62.9%)\n Total number of events 72 55 64 42 73 62 \n dcd D.1.1.1.1 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%)\n dcd D.1.1.4.2 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%)\ncl D.2 \n Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\n Total number of events 35 27 49 23 43 31 \n dcd D.2.1.5.3 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\ncl B.1 \n Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\n Total number of events 33 23 36 24 35 27 \n dcd B.1.1.1.1 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\ncl C.2 \n Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\n Total number of events 32 16 39 14 33 32 \n dcd C.2.1.2.1 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\ncl C.1 \n Total number of patients with at least one adverse event 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n Total number of events 39 16 52 11 44 20 \n dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"BMRKR2\") %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n Dictionary-Derived Term LOW MEDIUM HIGH LOW MEDIUM HIGH LOW MEDIUM HIGH \n (N=50) (N=37) (N=47) (N=45) (N=56) (N=33) (N=40) (N=42) (N=50) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 46 (92.0%) 34 (91.9%) 42 (89.4%) 40 (88.9%) 53 (94.6%) 30 (90.9%) 36 (90.0%) 39 (92.9%) 45 (90.0%)\nOverall total number of events 248 166 195 196 261 165 220 258 225 \ncl A.1 \n Total number of patients with at least one adverse event 31 (62.0%) 19 (51.4%) 28 (59.6%) 25 (55.6%) 31 (55.4%) 19 (57.6%) 28 (70.0%) 30 (71.4%) 31 (62.0%)\n Total number of events 53 34 45 46 54 30 61 51 48 \n dcd A.1.1.1.1 22 (44.0%) 10 (27.0%) 18 (38.3%) 14 (31.1%) 20 (35.7%) 11 (33.3%) 21 (52.5%) 24 (57.1%) 18 (36.0%)\n dcd A.1.1.1.2 17 (34.0%) 13 (35.1%) 18 (38.3%) 18 (40.0%) 18 (32.1%) 12 (36.4%) 18 (45.0%) 14 (33.3%) 18 (36.0%)\ncl B.2 \n Total number of patients with at least one adverse event 34 (68.0%) 21 (56.8%) 24 (51.1%) 23 (51.1%) 33 (58.9%) 18 (54.5%) 24 (60.0%) 27 (64.3%) 34 (68.0%)\n Total number of events 53 37 39 40 61 37 40 47 56 \n dcd B.2.2.3.1 21 (42.0%) 13 (35.1%) 14 (29.8%) 18 (40.0%) 22 (39.3%) 14 (42.4%) 16 (40.0%) 15 (35.7%) 20 (40.0%)\n dcd B.2.1.2.1 21 (42.0%) 11 (29.7%) 17 (36.2%) 11 (24.4%) 21 (37.5%) 12 (36.4%) 13 (32.5%) 17 (40.5%) 22 (44.0%)\ncl D.1 \n Total number of patients with at least one adverse event 34 (68.0%) 21 (56.8%) 24 (51.1%) 18 (40.0%) 33 (58.9%) 16 (48.5%) 25 (62.5%) 31 (73.8%) 24 (48.0%)\n Total number of events 51 35 41 27 49 30 45 53 37 \n dcd D.1.1.1.1 19 (38.0%) 16 (43.2%) 15 (31.9%) 13 (28.9%) 19 (33.9%) 10 (30.3%) 14 (35.0%) 22 (52.4%) 15 (30.0%)\n dcd D.1.1.4.2 21 (42.0%) 9 (24.3%) 18 (38.3%) 9 (20.0%) 20 (35.7%) 13 (39.4%) 17 (42.5%) 18 (42.9%) 15 (30.0%)\ncl D.2 \n Total number of patients with at least one adverse event 20 (40.0%) 12 (32.4%) 15 (31.9%) 19 (42.2%) 22 (39.3%) 17 (51.5%) 13 (32.5%) 23 (54.8%) 21 (42.0%)\n Total number of events 27 13 22 23 26 23 17 33 24 \n dcd D.2.1.5.3 20 (40.0%) 12 (32.4%) 15 (31.9%) 19 (42.2%) 22 (39.3%) 17 (51.5%) 13 (32.5%) 23 (54.8%) 21 (42.0%)\ncl B.1 \n Total number of patients with at least one adverse event 14 (28.0%) 14 (37.8%) 19 (40.4%) 15 (33.3%) 24 (42.9%) 10 (30.3%) 14 (35.0%) 15 (35.7%) 14 (28.0%)\n Total number of events 16 19 21 18 25 17 19 25 18 \n dcd B.1.1.1.1 14 (28.0%) 14 (37.8%) 19 (40.4%) 15 (33.3%) 24 (42.9%) 10 (30.3%) 14 (35.0%) 15 (35.7%) 14 (28.0%)\ncl C.2 \n Total number of patients with at least one adverse event 18 (36.0%) 8 (21.6%) 9 (19.1%) 15 (33.3%) 22 (39.3%) 11 (33.3%) 18 (45.0%) 17 (40.5%) 20 (40.0%)\n Total number of events 27 9 12 18 23 12 20 20 25 \n dcd C.2.1.2.1 18 (36.0%) 8 (21.6%) 9 (19.1%) 15 (33.3%) 22 (39.3%) 11 (33.3%) 18 (45.0%) 17 (40.5%) 20 (40.0%)\ncl C.1 \n Total number of patients with at least one adverse event 17 (34.0%) 14 (37.8%) 12 (25.5%) 17 (37.8%) 17 (30.4%) 12 (36.4%) 12 (30.0%) 17 (40.5%) 14 (28.0%)\n Total number of events 21 19 15 24 23 16 18 29 17 \n dcd C.1.1.1.3 17 (34.0%) 14 (37.8%) 12 (25.5%) 17 (37.8%) 17 (30.4%) 12 (36.4%) 12 (30.0%) 17 (40.5%) 14 (28.0%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"AVALCAT1\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n Dictionary-Derived Term <18.5 18.5 - 24.9 25 - 29.9 >30 <18.5 18.5 - 24.9 25 - 29.9 >30 <18.5 18.5 - 24.9 25 - 29.9 >30 \n (N=44) (N=17) (N=11) (N=62) (N=37) (N=18) (N=10) (N=69) (N=28) (N=20) (N=18) (N=66) \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 41 (93.2%) 14 (82.4%) 11 (100%) 56 (90.3%) 35 (94.6%) 16 (88.9%) 9 (90.0%) 63 (91.3%) 25 (89.3%) 19 (95.0%) 15 (83.3%) 61 (92.4%)\nOverall total number of events 186 80 66 277 174 89 47 312 137 129 100 337 \ncl A.1 \n Total number of patients with at least one adverse event 23 (52.3%) 12 (70.6%) 7 (63.6%) 36 (58.1%) 19 (51.4%) 10 (55.6%) 6 (60.0%) 40 (58.0%) 16 (57.1%) 13 (65.0%) 14 (77.8%) 46 (69.7%)\n Total number of events 38 22 13 59 35 22 6 67 30 23 30 77 \n dcd A.1.1.1.1 14 (31.8%) 7 (41.2%) 3 (27.3%) 26 (41.9%) 12 (32.4%) 6 (33.3%) 4 (40.0%) 23 (33.3%) 12 (42.9%) 7 (35.0%) 13 (72.2%) 31 (47.0%)\n dcd A.1.1.1.2 15 (34.1%) 8 (47.1%) 5 (45.5%) 20 (32.3%) 12 (32.4%) 8 (44.4%) 2 (20.0%) 26 (37.7%) 9 (32.1%) 7 (35.0%) 7 (38.9%) 27 (40.9%)\ncl B.2 \n Total number of patients with at least one adverse event 23 (52.3%) 10 (58.8%) 8 (72.7%) 38 (61.3%) 21 (56.8%) 8 (44.4%) 7 (70.0%) 38 (55.1%) 16 (57.1%) 16 (80.0%) 12 (66.7%) 41 (62.1%)\n Total number of events 37 19 12 61 41 18 12 67 28 28 18 69 \n dcd B.2.2.3.1 13 (29.5%) 7 (41.2%) 6 (54.5%) 22 (35.5%) 14 (37.8%) 7 (38.9%) 6 (60.0%) 27 (39.1%) 7 (25.0%) 13 (65.0%) 5 (27.8%) 26 (39.4%)\n dcd B.2.1.2.1 14 (31.8%) 8 (47.1%) 4 (36.4%) 23 (37.1%) 14 (37.8%) 6 (33.3%) 4 (40.0%) 20 (29.0%) 13 (46.4%) 8 (40.0%) 8 (44.4%) 23 (34.8%)\ncl D.1 \n Total number of patients with at least one adverse event 24 (54.5%) 9 (52.9%) 8 (72.7%) 38 (61.3%) 18 (48.6%) 5 (27.8%) 7 (70.0%) 37 (53.6%) 15 (53.6%) 12 (60.0%) 11 (61.1%) 42 (63.6%)\n Total number of events 38 11 17 61 30 11 14 51 30 23 16 66 \n dcd D.1.1.1.1 13 (29.5%) 7 (41.2%) 7 (63.6%) 23 (37.1%) 13 (35.1%) 3 (16.7%) 4 (40.0%) 22 (31.9%) 12 (42.9%) 6 (30.0%) 8 (44.4%) 25 (37.9%)\n dcd D.1.1.4.2 16 (36.4%) 4 (23.5%) 6 (54.5%) 22 (35.5%) 10 (27.0%) 4 (22.2%) 5 (50.0%) 23 (33.3%) 10 (35.7%) 9 (45.0%) 6 (33.3%) 25 (37.9%)\ncl D.2 \n Total number of patients with at least one adverse event 14 (31.8%) 7 (41.2%) 5 (45.5%) 21 (33.9%) 14 (37.8%) 10 (55.6%) 4 (40.0%) 30 (43.5%) 13 (46.4%) 10 (50.0%) 7 (38.9%) 27 (40.9%)\n Total number of events 20 7 10 25 17 14 5 36 18 15 10 31 \n dcd D.2.1.5.3 14 (31.8%) 7 (41.2%) 5 (45.5%) 21 (33.9%) 14 (37.8%) 10 (55.6%) 4 (40.0%) 30 (43.5%) 13 (46.4%) 10 (50.0%) 7 (38.9%) 27 (40.9%)\ncl B.1 \n Total number of patients with at least one adverse event 17 (38.6%) 5 (29.4%) 7 (63.6%) 18 (29.0%) 14 (37.8%) 8 (44.4%) 4 (40.0%) 23 (33.3%) 7 (25.0%) 10 (50.0%) 7 (38.9%) 19 (28.8%)\n Total number of events 22 5 7 22 16 11 4 29 11 12 8 31 \n dcd B.1.1.1.1 17 (38.6%) 5 (29.4%) 7 (63.6%) 18 (29.0%) 14 (37.8%) 8 (44.4%) 4 (40.0%) 23 (33.3%) 7 (25.0%) 10 (50.0%) 7 (38.9%) 19 (28.8%)\ncl C.2 \n Total number of patients with at least one adverse event 14 (31.8%) 4 (23.5%) 2 (18.2%) 15 (24.2%) 15 (40.5%) 5 (27.8%) 4 (40.0%) 24 (34.8%) 10 (35.7%) 13 (65.0%) 8 (44.4%) 24 (36.4%)\n Total number of events 17 9 3 19 15 6 5 27 12 16 9 28 \n dcd C.2.1.2.1 14 (31.8%) 4 (23.5%) 2 (18.2%) 15 (24.2%) 15 (40.5%) 5 (27.8%) 4 (40.0%) 24 (34.8%) 10 (35.7%) 13 (65.0%) 8 (44.4%) 24 (36.4%)\ncl C.1 \n Total number of patients with at least one adverse event 11 (25.0%) 4 (23.5%) 4 (36.4%) 24 (38.7%) 13 (35.1%) 6 (33.3%) 1 (10.0%) 26 (37.7%) 6 (21.4%) 7 (35.0%) 6 (33.3%) 24 (36.4%)\n Total number of events 14 7 4 30 20 7 1 35 8 12 9 35 \n dcd C.1.1.1.3 11 (25.0%) 4 (23.5%) 4 (36.4%) 24 (38.7%) 13 (35.1%) 6 (33.3%) 1 (10.0%) 26 (37.7%) 6 (21.4%) 7 (35.0%) 6 (33.3%) 24 (36.4%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"RACE1\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n Dictionary-Derived Term WHITE NON-WHITE WHITE NON-WHITE WHITE NON-WHITE \n (N=27) (N=107) (N=26) (N=108) (N=21) (N=111) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 26 (96.3%) 96 (89.7%) 25 (96.2%) 98 (90.7%) 21 (100%) 99 (89.2%)\nOverall total number of events 109 500 144 478 114 589 \ncl A.1 \n Total number of patients with at least one adverse event 16 (59.3%) 62 (57.9%) 21 (80.8%) 54 (50.0%) 15 (71.4%) 74 (66.7%)\n Total number of events 30 102 37 93 25 135 \n dcd A.1.1.1.1 9 (33.3%) 41 (38.3%) 14 (53.8%) 31 (28.7%) 10 (47.6%) 53 (47.7%)\n dcd A.1.1.1.2 11 (40.7%) 37 (34.6%) 13 (50.0%) 35 (32.4%) 9 (42.9%) 41 (36.9%)\ncl B.2 \n Total number of patients with at least one adverse event 15 (55.6%) 64 (59.8%) 16 (61.5%) 58 (53.7%) 12 (57.1%) 73 (65.8%)\n Total number of events 18 111 28 110 17 126 \n dcd B.2.2.3.1 4 (14.8%) 44 (41.1%) 10 (38.5%) 44 (40.7%) 5 (23.8%) 46 (41.4%)\n dcd B.2.1.2.1 12 (44.4%) 37 (34.6%) 9 (34.6%) 35 (32.4%) 7 (33.3%) 45 (40.5%)\ncl D.1 \n Total number of patients with at least one adverse event 18 (66.7%) 61 (57.0%) 15 (57.7%) 52 (48.1%) 14 (66.7%) 66 (59.5%)\n Total number of events 27 100 23 83 27 108 \n dcd D.1.1.1.1 11 (40.7%) 39 (36.4%) 14 (53.8%) 28 (25.9%) 12 (57.1%) 39 (35.1%)\n dcd D.1.1.4.2 11 (40.7%) 37 (34.6%) 7 (26.9%) 35 (32.4%) 9 (42.9%) 41 (36.9%)\ncl D.2 \n Total number of patients with at least one adverse event 6 (22.2%) 41 (38.3%) 15 (57.7%) 43 (39.8%) 9 (42.9%) 48 (43.2%)\n Total number of events 6 56 18 54 12 62 \n dcd D.2.1.5.3 6 (22.2%) 41 (38.3%) 15 (57.7%) 43 (39.8%) 9 (42.9%) 48 (43.2%)\ncl B.1 \n Total number of patients with at least one adverse event 12 (44.4%) 35 (32.7%) 7 (26.9%) 42 (38.9%) 6 (28.6%) 37 (33.3%)\n Total number of events 15 41 8 52 8 54 \n dcd B.1.1.1.1 12 (44.4%) 35 (32.7%) 7 (26.9%) 42 (38.9%) 6 (28.6%) 37 (33.3%)\ncl C.2 \n Total number of patients with at least one adverse event 5 (18.5%) 30 (28.0%) 11 (42.3%) 37 (34.3%) 11 (52.4%) 44 (39.6%)\n Total number of events 8 40 12 41 12 53 \n dcd C.2.1.2.1 5 (18.5%) 30 (28.0%) 11 (42.3%) 37 (34.3%) 11 (52.4%) 44 (39.6%)\ncl C.1 \n Total number of patients with at least one adverse event 5 (18.5%) 38 (35.5%) 13 (50.0%) 33 (30.6%) 8 (38.1%) 35 (31.5%)\n Total number of events 5 50 18 45 13 51 \n dcd C.1.1.1.3 5 (18.5%) 38 (35.5%) 13 (50.0%) 33 (30.6%) 8 (38.1%) 35 (31.5%)\n\n\n\n\n\nCodesplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\") %>%\n split_cols_by(\"SEX\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Overall total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n split_rows_by(\n \"AEHLT\",\n child_labels = \"visible\",\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae$AEHLT)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(\"AEDECOD\", .indent_mods = -1L) %>%\n append_varlabels(adae, \"AEDECOD\", indent = 2L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n # Sorted by decreasing frequency across all groups by System Organ Class, High-Level Term and Preferred Term.\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination \n High Level Term F M F M F M \n Dictionary-Derived Term (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) \n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 72 (91.1%) 50 (90.9%) 77 (93.9%) 46 (88.5%) 65 (92.9%) 55 (88.7%)\nOverall total number of events 377 232 419 203 378 325 \ncl A.1 \n Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%)\n Total number of events 85 47 93 37 86 74 \n hlt A.1.1.1 \n Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%)\n Total number of events 85 47 93 37 86 74 \n dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%)\n dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%)\ncl B.2 \n Total number of patients with at least one adverse event 46 (58.2%) 33 (60.0%) 45 (54.9%) 29 (55.8%) 44 (62.9%) 41 (66.1%)\n Total number of events 81 48 86 52 64 79 \n hlt B.2.2.3 \n Total number of patients with at least one adverse event 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n Total number of events 40 24 43 33 37 40 \n dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n hlt B.2.1.2 \n Total number of patients with at least one adverse event 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%)\n Total number of events 41 24 43 19 27 39 \n dcd B.2.1.2.1 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%)\ncl D.1 \n Total number of patients with at least one adverse event 45 (57.0%) 34 (61.8%) 40 (48.8%) 27 (51.9%) 41 (58.6%) 39 (62.9%)\n Total number of events 72 55 64 42 73 62 \n hlt D.1.1.1 \n Total number of patients with at least one adverse event 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%)\n Total number of events 32 29 36 15 39 32 \n dcd D.1.1.1.1 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%)\n hlt D.1.1.4 \n Total number of patients with at least one adverse event 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%)\n Total number of events 40 26 28 27 34 30 \n dcd D.1.1.4.2 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%)\ncl D.2 \n Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\n Total number of events 35 27 49 23 43 31 \n hlt D.2.1.5 \n Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\n Total number of events 35 27 49 23 43 31 \n dcd D.2.1.5.3 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\ncl B.1 \n Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\n Total number of events 33 23 36 24 35 27 \n hlt B.1.1.1 \n Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\n Total number of events 33 23 36 24 35 27 \n dcd B.1.1.1.1 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%)\ncl C.2 \n Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\n Total number of events 32 16 39 14 33 32 \n hlt C.2.1.2 \n Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\n Total number of events 32 16 39 14 33 32 \n dcd C.2.1.2.1 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%)\ncl C.1 \n Total number of patients with at least one adverse event 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n Total number of events 39 16 52 11 44 20 \n hlt C.1.1.1 \n Total number of patients with at least one adverse event 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n Total number of events 39 16 52 11 44 20 \n dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adae\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Event Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\", \"SEX\"), c(\"ARM\", \"SEX\")),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AESOC\")),\n selected = \"AEBODSYS\"\n ),\n add_total = TRUE,\n event_type = \"adverse event\"\n )\n )\n)\n\n[INFO] 2023-09-09 18:03:02.5278 pid:5403 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet09.html",
"href": "tables/adverse-events/aet09.html",
"title": "AET09",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Including High-Level Terms\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nadae_labels <- var_labels(adae)\n\nadae_f <- adae %>%\n filter(AEREL == \"Y\")\n\nvar_labels(adae_f) <- adae_labels\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Overall total number of events related to study drug\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae_f$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Total number of events related to study drug\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = -1L\n ) %>%\n append_varlabels(adae_f, \"AEDECOD\", indent = 1L)\n\ntbl1 <- build_table(\n lyt = lyt,\n df = adae_f,\n alt_counts_df = adsl\n) %>%\n prune_table()\n\nresult <- tbl1 %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination All Patients\n Dictionary-Derived Term (N=134) (N=134) (N=132) (N=400) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event related to study drug 105 (78.4%) 108 (80.6%) 109 (82.6%) 322 (80.5%) \nOverall total number of events related to study drug 282 299 336 917 \ncl D.2 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \n Total number of events related to study drug 62 72 74 208 \n dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \ncl D.1 \n Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \n Total number of events related to study drug 61 51 71 183 \n dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \ncl B.1 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \n Total number of events related to study drug 56 60 62 178 \n dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \ncl C.2 \n Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \n Total number of events related to study drug 48 53 65 166 \n dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \ncl C.1 \n Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) \n Total number of events related to study drug 55 63 64 182 \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Overall total number of events related to study drug\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n indent_mod = 1L,\n label_pos = \"topleft\",\n split_label = obj_label(adae_f$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Total number of events related to study drug\"\n )\n ) %>%\n split_rows_by(\n \"AEHLT\",\n child_labels = \"visible\",\n nested = TRUE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae_f$AEHLT)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Total number of events related to study drug\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = -1L)\n ) %>%\n append_varlabels(adae_f, c(\"AEDECOD\"), indent = 2L)\n\ntbl2 <- build_table(\n lyt = lyt,\n df = adae_f,\n alt_counts_df = adsl\n) %>%\n prune_table()\n\nresult <- tbl2 %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class \n High Level Term A: Drug X B: Placebo C: Combination\n Dictionary-Derived Term (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event related to study drug 105 (78.4%) 108 (80.6%) 109 (82.6%) \nOverall total number of events related to study drug 282 299 336 \n cl D.2 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) \n Total number of events related to study drug 62 72 74 \n hlt D.2.1.5 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) \n Total number of events related to study drug 62 72 74 \n dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) \n cl D.1 \n Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) \n Total number of events related to study drug 61 51 71 \n hlt D.1.1.1 \n Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) \n Total number of events related to study drug 61 51 71 \n dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) \n cl B.1 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) \n Total number of events related to study drug 56 60 62 \n hlt B.1.1.1 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) \n Total number of events related to study drug 56 60 62 \n dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) \n cl C.2 \n Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) \n Total number of events related to study drug 48 53 65 \n hlt C.2.1.2 \n Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) \n Total number of events related to study drug 48 53 65 \n dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) \n cl C.1 \n Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) \n Total number of events related to study drug 55 63 64 \n hlt C.1.1.1 \n Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) \n Total number of events related to study drug 55 63 64 \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\n \"ADAE\",\n adae,\n code = 'ADAE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adae\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Events Related to Study Drug\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AEHLT\")),\n selected = c(\"AEBODSYS\")\n ),\n add_total = FALSE,\n event_type = \"adverse event related to study drug\", # define event type here\n )\n ),\n filter = list(ADAE = list(AEREL = \"Y\")) # related AEs only\n)\n\n[INFO] 2023-09-08 19:44:10.5849 pid:5594 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Including High-Level Terms\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nadae_labels <- var_labels(adae)\n\nadae_f <- adae %>%\n filter(AEREL == \"Y\")\n\nvar_labels(adae_f) <- adae_labels\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n add_overall_col(label = \"All Patients\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Overall total number of events related to study drug\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae_f$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Total number of events related to study drug\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = -1L\n ) %>%\n append_varlabels(adae_f, \"AEDECOD\", indent = 1L)\n\ntbl1 <- build_table(\n lyt = lyt,\n df = adae_f,\n alt_counts_df = adsl\n) %>%\n prune_table()\n\nresult <- tbl1 %>%\n prune_table() %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class A: Drug X B: Placebo C: Combination All Patients\n Dictionary-Derived Term (N=134) (N=134) (N=132) (N=400) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event related to study drug 105 (78.4%) 108 (80.6%) 109 (82.6%) 322 (80.5%) \nOverall total number of events related to study drug 282 299 336 917 \ncl D.2 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \n Total number of events related to study drug 62 72 74 208 \n dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) \ncl D.1 \n Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \n Total number of events related to study drug 61 51 71 183 \n dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) \ncl B.1 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \n Total number of events related to study drug 56 60 62 178 \n dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) \ncl C.2 \n Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \n Total number of events related to study drug 48 53 65 166 \n dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) \ncl C.1 \n Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) \n Total number of events related to study drug 55 63 64 182 \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Overall total number of events related to study drug\"\n )\n ) %>%\n split_rows_by(\n \"AEBODSYS\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = split_fun,\n indent_mod = 1L,\n label_pos = \"topleft\",\n split_label = obj_label(adae_f$AEBODSYS)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Total number of events related to study drug\"\n )\n ) %>%\n split_rows_by(\n \"AEHLT\",\n child_labels = \"visible\",\n nested = TRUE,\n indent_mod = -1L,\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adae_f$AEHLT)\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event related to study drug\",\n nonunique = \"Total number of events related to study drug\"\n )\n ) %>%\n count_occurrences(\n vars = \"AEDECOD\",\n .indent_mods = c(count_fraction = -1L)\n ) %>%\n append_varlabels(adae_f, c(\"AEDECOD\"), indent = 2L)\n\ntbl2 <- build_table(\n lyt = lyt,\n df = adae_f,\n alt_counts_df = adsl\n) %>%\n prune_table()\n\nresult <- tbl2 %>%\n sort_at_path(\n path = c(\"AEBODSYS\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\"),\n scorefun = cont_n_allcols\n ) %>%\n sort_at_path(\n path = c(\"AEBODSYS\", \"*\", \"AEHLT\", \"*\", \"AEDECOD\"),\n scorefun = score_occurrences\n )\n\nresult\n\nBody System or Organ Class \n High Level Term A: Drug X B: Placebo C: Combination\n Dictionary-Derived Term (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event related to study drug 105 (78.4%) 108 (80.6%) 109 (82.6%) \nOverall total number of events related to study drug 282 299 336 \n cl D.2 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) \n Total number of events related to study drug 62 72 74 \n hlt D.2.1.5 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) \n Total number of events related to study drug 62 72 74 \n dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) \n cl D.1 \n Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) \n Total number of events related to study drug 61 51 71 \n hlt D.1.1.1 \n Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) \n Total number of events related to study drug 61 51 71 \n dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) \n cl B.1 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) \n Total number of events related to study drug 56 60 62 \n hlt B.1.1.1 \n Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) \n Total number of events related to study drug 56 60 62 \n dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) \n cl C.2 \n Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) \n Total number of events related to study drug 48 53 65 \n hlt C.2.1.2 \n Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) \n Total number of events related to study drug 48 53 65 \n dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) \n cl C.1 \n Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) \n Total number of events related to study drug 55 63 64 \n hlt C.1.1.1 \n Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) \n Total number of events related to study drug 55 63 64 \n dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\n \"ADSL\",\n adsl,\n code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\n \"ADAE\",\n adae,\n code = 'ADAE <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adae\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Events Related to Study Drug\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\")),\n selected = c(\"AEDECOD\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AEBODSYS\", \"AEHLT\")),\n selected = c(\"AEBODSYS\")\n ),\n add_total = FALSE,\n event_type = \"adverse event related to study drug\", # define event type here\n )\n ),\n filter = list(ADAE = list(AEREL = \"Y\")) # related AEs only\n)\n\n[INFO] 2023-09-09 18:04:02.3559 pid:5599 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet01.html",
"href": "tables/adverse-events/aet01.html",
"title": "AET01",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Medical Concepts Section\nTable with Modified Rows\nTable with Rows Counting Events & Additional Sections\nteal App\nReproducibility\n\n\n\nTo illustrate, additional variables such as flags (TRUE/FALSE) for select AEs of interest and select AE baskets are added to the adae dataset.\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(\n adae,\n omit_columns = c(\"SMQ01NAM\", \"SMQ01SC\", \"SMQ02NAM\", \"SMQ02SC\", \"CQ01NAM\", \"STUDYID\", \"USUBJID\")\n)\n\nset.seed(99)\n\nadae <- adae %>%\n mutate(\n AEDECOD = with_label(as.character(AEDECOD), \"Dictionary-Derived Term\"),\n AESDTH = with_label(sample(c(\"N\", \"Y\"), size = nrow(adae), replace = TRUE, prob = c(0.99, 0.01)), \"Results in Death\"),\n AEACN = with_label(sample(\n c(\"DOSE NOT CHANGED\", \"DOSE INCREASED\", \"DRUG INTERRUPTED\", \"DRUG WITHDRAWN\"),\n size = nrow(adae),\n replace = TRUE, prob = c(0.68, 0.02, 0.25, 0.05)\n ), \"Action Taken with Study Treatment\"),\n FATAL = with_label(AESDTH == \"Y\", \"AE with fatal outcome\"),\n SEV = with_label(AESEV == \"SEVERE\", \"Severe AE (at greatest intensity)\"),\n SER = with_label(AESER == \"Y\", \"Serious AE\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Serious AE leading to withdrawal from treatment\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"Serious AE leading to dose modification/interruption\"\n ),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"Related Serious AE\"),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"AE leading to withdrawal from treatment\"),\n DSM = with_label(\n AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"AE leading to dose modification/interruption\"\n ),\n REL = with_label(AEREL == \"Y\", \"Related AE\"),\n RELWD = with_label(AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Related AE leading to withdrawal from treatment\"),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"Related AE leading to dose modification/interruption\"\n ),\n CTC35 = with_label(AETOXGR %in% c(\"3\", \"4\", \"5\"), \"Grade 3-5 AE\"),\n CTC45 = with_label(AETOXGR %in% c(\"4\", \"5\"), \"Grade 4/5 AE\"),\n SMQ01 = with_label(SMQ01NAM != \"\", aesi_label(adae$SMQ01NAM, adae$SMQ01SC)),\n SMQ02 = with_label(SMQ02NAM != \"\", aesi_label(adae$SMQ02NAM, adae$SMQ02SC)),\n CQ01 = with_label(CQ01NAM != \"\", aesi_label(adae$CQ01NAM)),\n USUBJID_AESEQ = paste(USUBJID, AESEQ, sep = \"@@\") # Create unique ID per AE in dataset.\n ) %>%\n filter(ANL01FL == \"Y\")\n\n\n\n\n\nCodeaesi_vars <- c(\"FATAL\", \"SER\", \"SERWD\", \"SERDSM\", \"RELSER\", \"WD\", \"DSM\", \"REL\", \"RELWD\", \"RELDSM\", \"SEV\")\n\n# Layout for variables from adsl dataset.\nlyt_adsl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DTHFL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of deaths\")\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"ADVERSE EVENT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn from study due to an AE\"),\n table_names = \"tot_wd\"\n )\n\nresult_adsl <- build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)\n\n# Layout for variables from adae dataset.\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one AE\",\n nonunique = \"Total number of AEs\"\n ),\n .formats = list(unique = format_count_fraction_fixed_dp, nonunique = \"xx\"),\n show_labels = \"hidden\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_vars,\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n )\n\nresult_adae <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\n\n# Combine tables.\ncol_info(result_adsl) <- col_info(result_adae)\nresult <- rbind(\n result_adae[1:2, ],\n result_adsl,\n result_adae[3:nrow(result_adae), ]\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) \nTotal number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%) \nTotal number of patients with at least one \n AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%) \n Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n Serious AE leading to withdrawal from treatment 6 (4.5%) 12 (9.0%) 9 (6.8%) \n Serious AE leading to dose modification/interruption 36 (26.9%) 40 (29.9%) 47 (35.6%) \n Related Serious AE 64 (47.8%) 52 (38.8%) 64 (48.5%) \n AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%) \n AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%) \n Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n Related AE leading to withdrawal from treatment 10 (7.5%) 9 (6.7%) 12 (9.1%) \n Related AE leading to dose modification/interruption 44 (32.8%) 44 (32.8%) 51 (38.6%) \n Severe AE (at greatest intensity) 77 (57.5%) 70 (52.2%) 79 (59.8%) \n\n\n\n\n\nCodeaesi_vars <- c(\"FATAL\", \"SER\", \"SERWD\", \"SERDSM\", \"RELSER\", \"WD\", \"DSM\", \"REL\", \"RELWD\", \"RELDSM\", \"CTC35\")\nbasket_vars <- c(\"SMQ01\", \"SMQ02\", \"CQ01\")\n\n# Layout for variables from adsl dataset.\nlyt_adsl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DTHFL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of deaths\")\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"ADVERSE EVENT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn from study due to an AE\"),\n table_names = \"tot_wd\"\n )\n\nresult_adsl <- build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)\n\n# Layout for variables from adae dataset.\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one AE\",\n nonunique = \"Total number of AEs\"\n ),\n .formats = list(unique = format_count_fraction_fixed_dp, nonunique = \"xx\"),\n show_labels = \"hidden\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_vars,\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = basket_vars,\n table_names = \"table_aesi\",\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n )\n\nresult_adae <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\n\n# Combine tables.\ncol_info(result_adsl) <- col_info(result_adae)\nresult <- rbind(\n result_adae[1:2, ],\n result_adsl,\n result_adae[3:nrow(result_adae), ]\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) \nTotal number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%) \nTotal number of patients with at least one \n AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%) \n Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n Serious AE leading to withdrawal from treatment 6 (4.5%) 12 (9.0%) 9 (6.8%) \n Serious AE leading to dose modification/interruption 36 (26.9%) 40 (29.9%) 47 (35.6%) \n Related Serious AE 64 (47.8%) 52 (38.8%) 64 (48.5%) \n AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%) \n AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%) \n Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n Related AE leading to withdrawal from treatment 10 (7.5%) 9 (6.7%) 12 (9.1%) \n Related AE leading to dose modification/interruption 44 (32.8%) 44 (32.8%) 51 (38.6%) \n Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%) \nTotal number of patients with at least one \n C.1.1.1.3/B.2.2.3.1 AESI (BROAD) 58 (43.3%) 60 (44.8%) 66 (50.0%) \n SMQ 02 Reference Name 0 0 0 \n D.2.1.5.3/A.1.1.1.1 AESI 62 (46.3%) 61 (45.5%) 76 (57.6%) \n\n\n\n\n\nCodeaesi_vars <- c(\"FATAL\", \"SER\", \"WD\", \"REL\", \"CTC35\", \"CTC45\")\n# Layout for variables from adsl dataset.\nlyt_adsl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DTHFL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of deaths\")\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"ADVERSE EVENT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn from study due to an AE\"),\n table_names = \"tot_wd\"\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"WITHDRAWAL BY SUBJECT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn informed consent\"),\n table_names = \"tot_dscsreas_wd\"\n )\nresult_adsl <- build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)\n\n# Layout for variables from adae dataset.\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one AE\",\n nonunique = \"Total number of AEs\"\n ),\n .formats = list(unique = format_count_fraction_fixed_dp, nonunique = \"xx\"),\n show_labels = \"hidden\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_vars,\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n )\nresult_adae <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\n\n# Combine tables.\ncol_info(result_adsl) <- col_info(result_adae)\nresult <- rbind(\n result_adae[1:2, ],\n result_adsl,\n result_adae[3:nrow(result_adae), ]\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) \nTotal number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%) \nTotal number of patients withdrawn informed consent 1 (0.7%) 1 (0.7%) 1 (0.8%) \nTotal number of patients with at least one \n AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%) \n Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%) \n Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%) \n Grade 4/5 AE 77 (57.5%) 70 (52.2%) 79 (59.8%) \n\n\n\n\n\nCodecount_subj_vars <- c(\"FATAL\", \"SER\", \"WD\", \"DSM\", \"REL\", \"CTC35\")\ncount_term_vars <- c(\"SER\", \"DSM\", \"REL\", \"CTC35\", \"CTC45\")\ncount_ae_vars <- c(\"SER\", \"DSM\", \"REL\", \"CTC35\", \"CTC45\")\n\n# Layout for variables from adsl dataset.\nlyt_adsl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DTHFL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of deaths\")\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"ADVERSE EVENT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn from study due to an AE\"),\n table_names = \"tot_wd\"\n )\n\nresult_adsl <- build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)\n\n# Layout for variables from adae dataset.\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one AE\",\n nonunique = \"Total number of AEs\"\n ),\n .formats = list(unique = format_count_fraction_fixed_dp, nonunique = \"xx\"),\n show_labels = \"hidden\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = count_subj_vars,\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"AEDECOD\",\n flag_variables = count_term_vars,\n .stats = \"count\",\n .formats = c(count = \"xx\"),\n table_names = \"table_term\",\n var_labels = \"Total number of unique preferred terms which are\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID_AESEQ\",\n flag_variables = count_ae_vars,\n .stats = \"count\",\n .formats = c(count = \"xx\"),\n table_names = \"table_ae\",\n var_labels = \"Total number of adverse events which are\",\n show_labels = \"visible\"\n )\n\nresult_adae <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\n\n# Combine tables.\ncol_info(result_adsl) <- col_info(result_adae)\nresult <- rbind(\n result_adae[1:2, ],\n result_adsl,\n result_adae[3:nrow(result_adae), ]\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) \nTotal number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%) \nTotal number of patients with at least one \n AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%) \n Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%) \n AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%) \n Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%) \nTotal number of unique preferred terms which are \n Serious AE 4 4 4 \n AE leading to dose modification/interruption 10 10 10 \n Related AE 5 5 5 \n Grade 3-5 AE 5 5 5 \n Grade 4/5 AE 3 3 3 \nTotal number of adverse events which are \n Serious AE 204 194 245 \n AE leading to dose modification/interruption 123 135 158 \n Related AE 231 231 290 \n Grade 3-5 AE 249 229 277 \n Grade 4/5 AE 143 134 168 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadd_event_flags <- function(dat) {\n dat %>%\n dplyr::mutate(\n TMPFL_SER = AESER == \"Y\",\n TMPFL_REL = AEREL == \"Y\",\n TMPFL_GR5 = AETOXGR == \"5\",\n TMP_SMQ01 = !is.na(SMQ01NAM),\n TMP_SMQ02 = !is.na(SMQ02NAM),\n TMP_CQ01 = !is.na(CQ01NAM)\n ) %>%\n var_relabel(\n TMPFL_SER = \"Serious AE\",\n TMPFL_REL = \"Related AE\",\n TMPFL_GR5 = \"Grade 5 AE\",\n TMP_SMQ01 = aesi_label(dat[[\"SMQ01NAM\"]], dat[[\"SMQ01SC\"]]),\n TMP_SMQ02 = aesi_label(dat[[\"SMQ02NAM\"]], dat[[\"SMQ02SC\"]]),\n TMP_CQ01 = aesi_label(dat[[\"CQ01NAM\"]])\n )\n}\n\n# Generating user-defined event flags.\nadae <- adae %>% add_event_flags()\n\nae_anl_vars <- names(adae)[startsWith(names(adae), \"TMPFL_\")]\naesi_vars <- names(adae)[startsWith(names(adae), \"TMP_\")]\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n add_event_flags <- function(dat) {\n dat %>%\n dplyr::mutate(\n TMPFL_SER = AESER == \"Y\",\n TMPFL_REL = AEREL == \"Y\",\n TMPFL_GR5 = AETOXGR == \"5\",\n TMP_SMQ01 = !is.na(SMQ01NAM),\n TMP_SMQ02 = !is.na(SMQ02NAM),\n TMP_CQ01 = !is.na(CQ01NAM)\n ) %>%\n var_relabel(\n TMPFL_SER = \"Serious AE\",\n TMPFL_REL = \"Related AE\",\n TMPFL_GR5 = \"Grade 5 AE\",\n TMP_SMQ01 = aesi_label(dat[[\"SMQ01NAM\"]], dat[[\"SMQ01SC\"]]),\n TMP_SMQ02 = aesi_label(dat[[\"SMQ02NAM\"]], dat[[\"SMQ02SC\"]]),\n TMP_CQ01 = aesi_label(dat[[\"CQ01NAM\"]])\n )\n }\n ADAE <- ADAE %>% add_event_flags()'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events_summary(\n label = \"Adverse Events Summary\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(\"ADSL\", c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n flag_var_anl = choices_selected(\n choices = variable_choices(\"ADAE\", ae_anl_vars),\n selected = ae_anl_vars[1],\n keep_order = TRUE,\n fixed = FALSE\n ),\n flag_var_aesi = choices_selected(\n choices = variable_choices(\"ADAE\", aesi_vars),\n selected = aesi_vars[1],\n keep_order = TRUE,\n fixed = FALSE\n ),\n add_total = TRUE\n )\n )\n)\n\n[INFO] 2023-09-08 19:45:10.1926 pid:5790 token:[] teal.modules.clinical Initializing tm_t_events_summary\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Medical Concepts Section\nTable with Modified Rows\nTable with Rows Counting Events & Additional Sections\nteal App\nReproducibility\n\n\n\nTo illustrate, additional variables such as flags (TRUE/FALSE) for select AEs of interest and select AE baskets are added to the adae dataset.\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(\n adae,\n omit_columns = c(\"SMQ01NAM\", \"SMQ01SC\", \"SMQ02NAM\", \"SMQ02SC\", \"CQ01NAM\", \"STUDYID\", \"USUBJID\")\n)\n\nset.seed(99)\n\nadae <- adae %>%\n mutate(\n AEDECOD = with_label(as.character(AEDECOD), \"Dictionary-Derived Term\"),\n AESDTH = with_label(sample(c(\"N\", \"Y\"), size = nrow(adae), replace = TRUE, prob = c(0.99, 0.01)), \"Results in Death\"),\n AEACN = with_label(sample(\n c(\"DOSE NOT CHANGED\", \"DOSE INCREASED\", \"DRUG INTERRUPTED\", \"DRUG WITHDRAWN\"),\n size = nrow(adae),\n replace = TRUE, prob = c(0.68, 0.02, 0.25, 0.05)\n ), \"Action Taken with Study Treatment\"),\n FATAL = with_label(AESDTH == \"Y\", \"AE with fatal outcome\"),\n SEV = with_label(AESEV == \"SEVERE\", \"Severe AE (at greatest intensity)\"),\n SER = with_label(AESER == \"Y\", \"Serious AE\"),\n SERWD = with_label(AESER == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Serious AE leading to withdrawal from treatment\"),\n SERDSM = with_label(\n AESER == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"Serious AE leading to dose modification/interruption\"\n ),\n RELSER = with_label(AESER == \"Y\" & AEREL == \"Y\", \"Related Serious AE\"),\n WD = with_label(AEACN == \"DRUG WITHDRAWN\", \"AE leading to withdrawal from treatment\"),\n DSM = with_label(\n AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"), \"AE leading to dose modification/interruption\"\n ),\n REL = with_label(AEREL == \"Y\", \"Related AE\"),\n RELWD = with_label(AEREL == \"Y\" & AEACN == \"DRUG WITHDRAWN\", \"Related AE leading to withdrawal from treatment\"),\n RELDSM = with_label(\n AEREL == \"Y\" & AEACN %in% c(\"DRUG INTERRUPTED\", \"DOSE INCREASED\", \"DOSE REDUCED\"),\n \"Related AE leading to dose modification/interruption\"\n ),\n CTC35 = with_label(AETOXGR %in% c(\"3\", \"4\", \"5\"), \"Grade 3-5 AE\"),\n CTC45 = with_label(AETOXGR %in% c(\"4\", \"5\"), \"Grade 4/5 AE\"),\n SMQ01 = with_label(SMQ01NAM != \"\", aesi_label(adae$SMQ01NAM, adae$SMQ01SC)),\n SMQ02 = with_label(SMQ02NAM != \"\", aesi_label(adae$SMQ02NAM, adae$SMQ02SC)),\n CQ01 = with_label(CQ01NAM != \"\", aesi_label(adae$CQ01NAM)),\n USUBJID_AESEQ = paste(USUBJID, AESEQ, sep = \"@@\") # Create unique ID per AE in dataset.\n ) %>%\n filter(ANL01FL == \"Y\")\n\n\n\n\n\nCodeaesi_vars <- c(\"FATAL\", \"SER\", \"SERWD\", \"SERDSM\", \"RELSER\", \"WD\", \"DSM\", \"REL\", \"RELWD\", \"RELDSM\", \"SEV\")\n\n# Layout for variables from adsl dataset.\nlyt_adsl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DTHFL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of deaths\")\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"ADVERSE EVENT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn from study due to an AE\"),\n table_names = \"tot_wd\"\n )\n\nresult_adsl <- build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)\n\n# Layout for variables from adae dataset.\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one AE\",\n nonunique = \"Total number of AEs\"\n ),\n .formats = list(unique = format_count_fraction_fixed_dp, nonunique = \"xx\"),\n show_labels = \"hidden\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_vars,\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n )\n\nresult_adae <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\n\n# Combine tables.\ncol_info(result_adsl) <- col_info(result_adae)\nresult <- rbind(\n result_adae[1:2, ],\n result_adsl,\n result_adae[3:nrow(result_adae), ]\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) \nTotal number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%) \nTotal number of patients with at least one \n AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%) \n Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n Serious AE leading to withdrawal from treatment 6 (4.5%) 12 (9.0%) 9 (6.8%) \n Serious AE leading to dose modification/interruption 36 (26.9%) 40 (29.9%) 47 (35.6%) \n Related Serious AE 64 (47.8%) 52 (38.8%) 64 (48.5%) \n AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%) \n AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%) \n Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n Related AE leading to withdrawal from treatment 10 (7.5%) 9 (6.7%) 12 (9.1%) \n Related AE leading to dose modification/interruption 44 (32.8%) 44 (32.8%) 51 (38.6%) \n Severe AE (at greatest intensity) 77 (57.5%) 70 (52.2%) 79 (59.8%) \n\n\n\n\n\nCodeaesi_vars <- c(\"FATAL\", \"SER\", \"SERWD\", \"SERDSM\", \"RELSER\", \"WD\", \"DSM\", \"REL\", \"RELWD\", \"RELDSM\", \"CTC35\")\nbasket_vars <- c(\"SMQ01\", \"SMQ02\", \"CQ01\")\n\n# Layout for variables from adsl dataset.\nlyt_adsl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DTHFL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of deaths\")\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"ADVERSE EVENT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn from study due to an AE\"),\n table_names = \"tot_wd\"\n )\n\nresult_adsl <- build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)\n\n# Layout for variables from adae dataset.\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one AE\",\n nonunique = \"Total number of AEs\"\n ),\n .formats = list(unique = format_count_fraction_fixed_dp, nonunique = \"xx\"),\n show_labels = \"hidden\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_vars,\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = basket_vars,\n table_names = \"table_aesi\",\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n )\n\nresult_adae <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\n\n# Combine tables.\ncol_info(result_adsl) <- col_info(result_adae)\nresult <- rbind(\n result_adae[1:2, ],\n result_adsl,\n result_adae[3:nrow(result_adae), ]\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) \nTotal number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%) \nTotal number of patients with at least one \n AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%) \n Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n Serious AE leading to withdrawal from treatment 6 (4.5%) 12 (9.0%) 9 (6.8%) \n Serious AE leading to dose modification/interruption 36 (26.9%) 40 (29.9%) 47 (35.6%) \n Related Serious AE 64 (47.8%) 52 (38.8%) 64 (48.5%) \n AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%) \n AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%) \n Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n Related AE leading to withdrawal from treatment 10 (7.5%) 9 (6.7%) 12 (9.1%) \n Related AE leading to dose modification/interruption 44 (32.8%) 44 (32.8%) 51 (38.6%) \n Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%) \nTotal number of patients with at least one \n C.1.1.1.3/B.2.2.3.1 AESI (BROAD) 58 (43.3%) 60 (44.8%) 66 (50.0%) \n SMQ 02 Reference Name 0 0 0 \n D.2.1.5.3/A.1.1.1.1 AESI 62 (46.3%) 61 (45.5%) 76 (57.6%) \n\n\n\n\n\nCodeaesi_vars <- c(\"FATAL\", \"SER\", \"WD\", \"REL\", \"CTC35\", \"CTC45\")\n# Layout for variables from adsl dataset.\nlyt_adsl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DTHFL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of deaths\")\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"ADVERSE EVENT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn from study due to an AE\"),\n table_names = \"tot_wd\"\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"WITHDRAWAL BY SUBJECT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn informed consent\"),\n table_names = \"tot_dscsreas_wd\"\n )\nresult_adsl <- build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)\n\n# Layout for variables from adae dataset.\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one AE\",\n nonunique = \"Total number of AEs\"\n ),\n .formats = list(unique = format_count_fraction_fixed_dp, nonunique = \"xx\"),\n show_labels = \"hidden\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = aesi_vars,\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n )\nresult_adae <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\n\n# Combine tables.\ncol_info(result_adsl) <- col_info(result_adae)\nresult <- rbind(\n result_adae[1:2, ],\n result_adsl,\n result_adae[3:nrow(result_adae), ]\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) \nTotal number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%) \nTotal number of patients withdrawn informed consent 1 (0.7%) 1 (0.7%) 1 (0.8%) \nTotal number of patients with at least one \n AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%) \n Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%) \n Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%) \n Grade 4/5 AE 77 (57.5%) 70 (52.2%) 79 (59.8%) \n\n\n\n\n\nCodecount_subj_vars <- c(\"FATAL\", \"SER\", \"WD\", \"DSM\", \"REL\", \"CTC35\")\ncount_term_vars <- c(\"SER\", \"DSM\", \"REL\", \"CTC35\", \"CTC45\")\ncount_ae_vars <- c(\"SER\", \"DSM\", \"REL\", \"CTC35\", \"CTC45\")\n\n# Layout for variables from adsl dataset.\nlyt_adsl <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DTHFL\" = \"Y\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of deaths\")\n ) %>%\n count_patients_with_event(\n \"USUBJID\",\n filters = c(\"DCSREAS\" = \"ADVERSE EVENT\"),\n denom = \"N_col\",\n .labels = c(count_fraction = \"Total number of patients withdrawn from study due to an AE\"),\n table_names = \"tot_wd\"\n )\n\nresult_adsl <- build_table(lyt_adsl, df = adsl, alt_counts_df = adsl)\n\n# Layout for variables from adae dataset.\nlyt_adae <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one AE\",\n nonunique = \"Total number of AEs\"\n ),\n .formats = list(unique = format_count_fraction_fixed_dp, nonunique = \"xx\"),\n show_labels = \"hidden\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID\",\n flag_variables = count_subj_vars,\n denom = \"N_col\",\n var_labels = \"Total number of patients with at least one\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"AEDECOD\",\n flag_variables = count_term_vars,\n .stats = \"count\",\n .formats = c(count = \"xx\"),\n table_names = \"table_term\",\n var_labels = \"Total number of unique preferred terms which are\",\n show_labels = \"visible\"\n ) %>%\n count_patients_with_flags(\n \"USUBJID_AESEQ\",\n flag_variables = count_ae_vars,\n .stats = \"count\",\n .formats = c(count = \"xx\"),\n table_names = \"table_ae\",\n var_labels = \"Total number of adverse events which are\",\n show_labels = \"visible\"\n )\n\nresult_adae <- build_table(lyt_adae, df = adae, alt_counts_df = adsl)\n\n# Combine tables.\ncol_info(result_adsl) <- col_info(result_adae)\nresult <- rbind(\n result_adae[1:2, ],\n result_adsl,\n result_adae[3:nrow(result_adae), ]\n)\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n——————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one AE 100 (74.6%) 98 (73.1%) 103 (78.0%) \nTotal number of AEs 502 480 604 \nTotal number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) \nTotal number of patients withdrawn from study due to an AE 3 (2.2%) 6 (4.5%) 5 (3.8%) \nTotal number of patients with at least one \n AE with fatal outcome 5 (3.7%) 5 (3.7%) 6 (4.5%) \n Serious AE 85 (63.4%) 80 (59.7%) 87 (65.9%) \n AE leading to withdrawal from treatment 20 (14.9%) 24 (17.9%) 26 (19.7%) \n AE leading to dose modification/interruption 63 (47.0%) 70 (52.2%) 77 (58.3%) \n Related AE 86 (64.2%) 85 (63.4%) 92 (69.7%) \n Grade 3-5 AE 90 (67.2%) 83 (61.9%) 93 (70.5%) \nTotal number of unique preferred terms which are \n Serious AE 4 4 4 \n AE leading to dose modification/interruption 10 10 10 \n Related AE 5 5 5 \n Grade 3-5 AE 5 5 5 \n Grade 4/5 AE 3 3 3 \nTotal number of adverse events which are \n Serious AE 204 194 245 \n AE leading to dose modification/interruption 123 135 158 \n Related AE 231 231 290 \n Grade 3-5 AE 249 229 277 \n Grade 4/5 AE 143 134 168 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadd_event_flags <- function(dat) {\n dat %>%\n dplyr::mutate(\n TMPFL_SER = AESER == \"Y\",\n TMPFL_REL = AEREL == \"Y\",\n TMPFL_GR5 = AETOXGR == \"5\",\n TMP_SMQ01 = !is.na(SMQ01NAM),\n TMP_SMQ02 = !is.na(SMQ02NAM),\n TMP_CQ01 = !is.na(CQ01NAM)\n ) %>%\n var_relabel(\n TMPFL_SER = \"Serious AE\",\n TMPFL_REL = \"Related AE\",\n TMPFL_GR5 = \"Grade 5 AE\",\n TMP_SMQ01 = aesi_label(dat[[\"SMQ01NAM\"]], dat[[\"SMQ01SC\"]]),\n TMP_SMQ02 = aesi_label(dat[[\"SMQ02NAM\"]], dat[[\"SMQ02SC\"]]),\n TMP_CQ01 = aesi_label(dat[[\"CQ01NAM\"]])\n )\n}\n\n# Generating user-defined event flags.\nadae <- adae %>% add_event_flags()\n\nae_anl_vars <- names(adae)[startsWith(names(adae), \"TMPFL_\")]\naesi_vars <- names(adae)[startsWith(names(adae), \"TMP_\")]\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADAE\", adae, code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n add_event_flags <- function(dat) {\n dat %>%\n dplyr::mutate(\n TMPFL_SER = AESER == \"Y\",\n TMPFL_REL = AEREL == \"Y\",\n TMPFL_GR5 = AETOXGR == \"5\",\n TMP_SMQ01 = !is.na(SMQ01NAM),\n TMP_SMQ02 = !is.na(SMQ02NAM),\n TMP_CQ01 = !is.na(CQ01NAM)\n ) %>%\n var_relabel(\n TMPFL_SER = \"Serious AE\",\n TMPFL_REL = \"Related AE\",\n TMPFL_GR5 = \"Grade 5 AE\",\n TMP_SMQ01 = aesi_label(dat[[\"SMQ01NAM\"]], dat[[\"SMQ01SC\"]]),\n TMP_SMQ02 = aesi_label(dat[[\"SMQ02NAM\"]], dat[[\"SMQ02SC\"]]),\n TMP_CQ01 = aesi_label(dat[[\"CQ01NAM\"]])\n )\n }\n ADAE <- ADAE %>% add_event_flags()'),\n check = TRUE\n ),\n modules = modules(\n tm_t_events_summary(\n label = \"Adverse Events Summary\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(\"ADSL\", c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n flag_var_anl = choices_selected(\n choices = variable_choices(\"ADAE\", ae_anl_vars),\n selected = ae_anl_vars[1],\n keep_order = TRUE,\n fixed = FALSE\n ),\n flag_var_aesi = choices_selected(\n choices = variable_choices(\"ADAE\", aesi_vars),\n selected = aesi_vars[1],\n keep_order = TRUE,\n fixed = FALSE\n ),\n add_total = TRUE\n )\n )\n)\n\n[INFO] 2023-09-09 18:05:17.6957 pid:5795 token:[] teal.modules.clinical Initializing tm_t_events_summary\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 dplyr_1.1.2 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet07.html",
"href": "tables/adverse-events/aet07.html",
"title": "AET07",
"section": "",
- "text": "Data Setup\nStandard Table\nTable with Fill-In of Treatment Groups without Deaths\nteal App\nReproducibility\n\n\n\nFor illustrative purposes, we will pre-process AESDTH in ADAE so there are no deaths in arm A and concatenate AEBODSYS and AEDECOD as per GDSR output standards for AET07.\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nadae_f <- adae %>%\n mutate(\n AESDTH = as.character(AESDTH), # characterizing AESDTH for next step\n AESDTH = case_when(\n ARM == \"A: Drug X\" ~ NA_character_, # For demonstration purpose only,\n TRUE ~ AESDTH\n ), # make \"A: Drug X\" as the arm without AE leading to death\n AESDTH = as.factor(AESDTH),\n SOC_PT = factor(paste(AEBODSYS, \"/\", AEDECOD))\n ) %>%\n filter(AESDTH == \"Y\") %>%\n mutate(ARM = droplevels(ARM))\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\", split_fun = drop_split_levels) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = c(unique = \"Total number of deaths\"),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(\n vars = \"SOC_PT\"\n ) %>%\n append_topleft(\"MedDRA SOC and Preferred Term\")\n\nresult <- build_table(\n lyt = lyt,\n df = adae_f,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = \"SOC_PT\",\n scorefun = score_occurrences,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA SOC and Preferred Term B: Placebo C: Combination\n (N=134) (N=132) \n———————————————————————————————————————————————————————————\nTotal number of deaths 70 (52.2%) 75 (56.8%) \ncl D.1 / dcd D.1.1.1.1 42 (31.3%) 51 (38.6%) \ncl B.1 / dcd B.1.1.1.1 49 (36.6%) 43 (32.6%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = c(unique = \"Total number of deaths\"),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(\n vars = \"SOC_PT\"\n ) %>%\n append_topleft(\"MedDRA SOC and Preferred Term\")\n\nresult <- build_table(\n lyt = lyt,\n df = adae_f,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = \"SOC_PT\",\n scorefun = score_occurrences,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA SOC and Preferred Term A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————\nTotal number of deaths 0 70 (52.2%) 75 (56.8%) \ncl D.1 / dcd D.1.1.1.1 0 42 (31.3%) 51 (38.6%) \ncl B.1 / dcd B.1.1.1.1 0 49 (36.6%) 43 (32.6%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nadsl <- adsl %>%\n mutate(\n DTHFL = case_when(\n !is.na(DTHDT) ~ \"Y\",\n TRUE ~ \"\"\n )\n ) %>%\n var_relabel(\n DTHFL = \"Subject Death Flag\"\n )\n\nadae <- adae %>%\n mutate(\n AESDTH = as.character(AESDTH), # characterizing AESDTH for next step\n AESDTH = case_when(\n ARM == \"A: Drug X\" ~ NA_character_, # For demonstration purpose only,\n TRUE ~ AESDTH\n ), # make \"A: Drug X\" as the arm without AE leading to death\n AESDTH = as.factor(AESDTH),\n SOC_PT = factor(paste(AEBODSYS, \"/\", AEDECOD))\n ) %>%\n filter(AESDTH == \"Y\") %>%\n mutate(ARM = droplevels(ARM)) %>%\n var_relabel(SOC_PT = \"MedDRA SOC and Preferred Term\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n df_explicit_na() %>%\n mutate(\n DTHFL = case_when(\n !is.na(DTHDT) ~ \"Y\",\n TRUE ~ \"\"\n )\n ) %>%\n var_relabel(\n DTHFL = \"Subject Death Flag\"\n )\n '),\n cdisc_dataset(\"ADAE\", adae, code = '\n ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\") %>%\n df_explicit_na() %>%\n mutate(\n AESDTH = as.character(AESDTH),\n AESDTH = case_when(\n ARM == \"A: Drug X\" ~ NA_character_,\n TRUE ~ AESDTH),\n AESDTH = as.factor(AESDTH),\n SOC_PT = factor(paste(AEBODSYS, \"/\", AEDECOD))\n ) %>%\n filter(AESDTH == \"Y\") %>%\n mutate(ARM = droplevels(ARM)) %>%\n var_relabel(SOC_PT = \"MedDRA SOC and Preferred Term\")\n '),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Event Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\", \"SOC_PT\")),\n selected = c(\"SOC_PT\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\", \"SOC_PT\")),\n selected = NULL\n ),\n add_total = FALSE,\n event_type = \"adverse event\"\n )\n )\n)\n\n[INFO] 2023-09-08 19:46:09.0733 pid:5987 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable with Fill-In of Treatment Groups without Deaths\nteal App\nReproducibility\n\n\n\nFor illustrative purposes, we will pre-process AESDTH in ADAE so there are no deaths in arm A and concatenate AEBODSYS and AEDECOD as per GDSR output standards for AET07.\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nadae_f <- adae %>%\n mutate(\n AESDTH = as.character(AESDTH), # characterizing AESDTH for next step\n AESDTH = case_when(\n ARM == \"A: Drug X\" ~ NA_character_, # For demonstration purpose only,\n TRUE ~ AESDTH\n ), # make \"A: Drug X\" as the arm without AE leading to death\n AESDTH = as.factor(AESDTH),\n SOC_PT = factor(paste(AEBODSYS, \"/\", AEDECOD))\n ) %>%\n filter(AESDTH == \"Y\") %>%\n mutate(ARM = droplevels(ARM))\n\n\n\n\n\nCode# Define the split function\nsplit_fun <- drop_split_levels\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\", split_fun = drop_split_levels) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = c(unique = \"Total number of deaths\"),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(\n vars = \"SOC_PT\"\n ) %>%\n append_topleft(\"MedDRA SOC and Preferred Term\")\n\nresult <- build_table(\n lyt = lyt,\n df = adae_f,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = \"SOC_PT\",\n scorefun = score_occurrences,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA SOC and Preferred Term B: Placebo C: Combination\n (N=134) (N=132) \n———————————————————————————————————————————————————————————\nTotal number of deaths 70 (52.2%) 75 (56.8%) \ncl D.1 / dcd D.1.1.1.1 42 (31.3%) 51 (38.6%) \ncl B.1 / dcd B.1.1.1.1 49 (36.6%) 43 (32.6%) \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARM\") %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = \"unique\",\n .labels = c(unique = \"Total number of deaths\"),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(\n vars = \"SOC_PT\"\n ) %>%\n append_topleft(\"MedDRA SOC and Preferred Term\")\n\nresult <- build_table(\n lyt = lyt,\n df = adae_f,\n alt_counts_df = adsl\n) %>%\n prune_table() %>%\n sort_at_path(\n path = \"SOC_PT\",\n scorefun = score_occurrences,\n decreasing = TRUE\n )\n\nresult\n\nMedDRA SOC and Preferred Term A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————\nTotal number of deaths 0 70 (52.2%) 75 (56.8%) \ncl D.1 / dcd D.1.1.1.1 0 42 (31.3%) 51 (38.6%) \ncl B.1 / dcd B.1.1.1.1 0 49 (36.6%) 43 (32.6%) \n\n\n\n\n\nCodelibrary(dplyr)\nlibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\nadsl <- adsl %>%\n mutate(\n DTHFL = case_when(\n !is.na(DTHDT) ~ \"Y\",\n TRUE ~ \"\"\n )\n ) %>%\n var_relabel(\n DTHFL = \"Subject Death Flag\"\n )\n\nadae <- adae %>%\n mutate(\n AESDTH = as.character(AESDTH), # characterizing AESDTH for next step\n AESDTH = case_when(\n ARM == \"A: Drug X\" ~ NA_character_, # For demonstration purpose only,\n TRUE ~ AESDTH\n ), # make \"A: Drug X\" as the arm without AE leading to death\n AESDTH = as.factor(AESDTH),\n SOC_PT = factor(paste(AEBODSYS, \"/\", AEDECOD))\n ) %>%\n filter(AESDTH == \"Y\") %>%\n mutate(ARM = droplevels(ARM)) %>%\n var_relabel(SOC_PT = \"MedDRA SOC and Preferred Term\")\n\napp <- teal::init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = '\n ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n df_explicit_na() %>%\n mutate(\n DTHFL = case_when(\n !is.na(DTHDT) ~ \"Y\",\n TRUE ~ \"\"\n )\n ) %>%\n var_relabel(\n DTHFL = \"Subject Death Flag\"\n )\n '),\n cdisc_dataset(\"ADAE\", adae, code = '\n ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\") %>%\n df_explicit_na() %>%\n mutate(\n AESDTH = as.character(AESDTH),\n AESDTH = case_when(\n ARM == \"A: Drug X\" ~ NA_character_,\n TRUE ~ AESDTH),\n AESDTH = as.factor(AESDTH),\n SOC_PT = factor(paste(AEBODSYS, \"/\", AEDECOD))\n ) %>%\n filter(AESDTH == \"Y\") %>%\n mutate(ARM = droplevels(ARM)) %>%\n var_relabel(SOC_PT = \"MedDRA SOC and Preferred Term\")\n '),\n check = TRUE\n ),\n modules = modules(\n tm_t_events(\n label = \"Adverse Event Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\"), \"ARM\"),\n llt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\", \"SOC_PT\")),\n selected = c(\"SOC_PT\")\n ),\n hlt = choices_selected(\n choices = variable_choices(adae, c(\"AETERM\", \"AEDECOD\", \"SOC_PT\")),\n selected = NULL\n ),\n add_total = FALSE,\n event_type = \"adverse event\"\n )\n )\n)\n\n[INFO] 2023-09-09 18:06:28.8037 pid:5991 token:[] teal.modules.clinical Initializing tm_t_events\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 purrr_1.0.2 shinyWidgets_0.7.6 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[40] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[43] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[46] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[49] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[52] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[55] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[58] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[61] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[64] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[73] broom_1.0.5 teal.reporter_0.2.1 httpuv_1.6.11 \n[76] bslib_0.5.1 Rcpp_1.0.11 coda_0.19-4 \n[79] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[82] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/adverse-events/aet06_smq.html",
"href": "tables/adverse-events/aet06_smq.html",
"title": "AET06_SMQ",
"section": "",
- "text": "Data Setup\nAdverse Events by Sex, by SMQ and Preferred Term\nAdverse Events by Sex, by SMQ and Preferred Term (with Customized Queries)\nAdverse Events by Other Baseline Characteristics (e.g. Age Group)\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(stringr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadsl_labels <- var_labels(adsl)\nadae_labels <- var_labels(adae)\n\nadsl <- adsl %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )\n\nadae <- adae %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing\n# levels. For details, refer to Teal and Study Data article.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\n# Simulate a random AAG dataset.\naag <- data.frame(\n NAMVAR = c(\"SMQ01NAM\", \"SMQ01NAM\", \"SMQ02NAM\", \"CQ01NAM\", \"CQ01NAM\"),\n SRCVAR = rep(\"AEDECOD\", 5),\n GRPTYPE = c(\"SMQ\", \"SMQ\", \"SMQ\", \"CUSTOM\", \"CUSTOM\"),\n REFID = c(1, 1, 2, 3, 3),\n REFNAME = c(rep(\"C.1.1.1.3/B.2.2.3.1 AESI\", 2), \"non observed SMQ02NAM level\", rep(\"D.2.1.5.3/A.1.1.1.1 AESI\", 2)),\n SCOPE = c(\"BROAD\", \"BROAD\", \"BROAD\", \"\", \"\"),\n REFTERM = c(\"C.1.1.1.3\", \"B.2.2.3.1\", \"Z.9.9.9.9\", \"D.2.1.5.3\", \"A.1.1.1.1\"),\n stringsAsFactors = FALSE\n)\n\n# Create summary AAG dataset (used for labelling).\n# Note it's important to incorporate SCOPE into the basket names for SMQs so as to\n# match the flags present in ADAE.\naag_summary <- aag %>%\n select(NAMVAR, REFNAME, SCOPE) %>%\n unique() %>%\n mutate(\n REFNAME_SCOPE = ifelse(SCOPE == \"\", REFNAME, paste0(REFNAME, \"(\", SCOPE, \")\"))\n ) %>%\n rename(basket = NAMVAR, basket_name = REFNAME_SCOPE) %>%\n select(basket, basket_name)\n\n# Make a summary of the full ADAE based on AAG by using h_stack_by_baskets helper function\nadae_smq_all <- h_stack_by_baskets(\n df = adae,\n aag_summary = aag_summary,\n keys = c(\"STUDYID\", \"USUBJID\", \"ACTARMCD\", \"AEDECOD\", \"SEX\", \"AGE65\")\n)\n# Post-process adae_smq_all to keep only certain baskets of interest for variant 1\n# Not need to drop baskets for variant 2 as all baskets will be considered.\nbaskets_to_drop_variant <- aag_summary$basket_name[!aag_summary$basket %in% c(\"SMQ01NAM\")]\n\n# Adjust the analysis dataset based on basket subset for variant 1.\nadae_smq_1 <- adae_smq_all %>%\n filter(!adae_smq_all$SMQ %in% baskets_to_drop_variant) %>%\n mutate(\n SMQ = tern::fct_discard(SMQ, discard = baskets_to_drop_variant)\n )\n\n\n\n\n\nCodecriteria_fun <- function(tr) !is(tr, \"ContentRow\") && all_zero_or_na(tr)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n split_cols_by(\"SEX\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(unique = \"Total number of patients with at least one adverse event\")\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", drop = FALSE) %>%\n append_varlabels(adae_smq_1, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae_smq_1,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term F M F M F M \n (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 47 (59.5%) 25 (45.5%) 51 (62.2%) 28 (53.8%) 42 (60.0%) 33 (53.2%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 47 (59.5%) 25 (45.5%) 51 (62.2%) 28 (53.8%) 42 (60.0%) 33 (53.2%)\n Total number of events 79 40 95 44 81 60 \n dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n\n\n\n\n\nCodecriteria_fun <- function(tr) {\n !is(tr, \"ContentRow\") && all_zero_or_na(tr) && !grepl(\"Total number of\", obj_label(tr))\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n split_cols_by(\"SEX\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(unique = \"Total number of patients with at least one adverse event\")\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"AEDECOD\", drop = FALSE) %>%\n append_varlabels(adae_smq_all, \"AEDECOD\", indent = 1L)\n\nscore_ae_pts <- function(tt) {\n count_vals <- cell_values(tree_children(tt)[[\"USUBJID\"]])[[1]]\n sum(matrix(unlist(count_vals), nrow = length(count_vals), byrow = TRUE)[, 1])\n}\n\nresult <- build_table(\n lyt = lyt,\n df = adae_smq_all,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = score_ae_pts) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term F M F M F M \n (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 59 (74.7%) 36 (65.5%) 68 (82.9%) 35 (67.3%) 61 (87.1%) 47 (75.8%)\nD.2.1.5.3/A.1.1.1.1 AESI \n Total number of patients with at least one adverse event 45 (57.0%) 29 (52.7%) 54 (65.9%) 26 (50.0%) 50 (71.4%) 37 (59.7%)\n Total number of events 78 48 91 43 88 74 \n dcd D.2.1.5.3 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\n dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 47 (59.5%) 25 (45.5%) 51 (62.2%) 28 (53.8%) 42 (60.0%) 33 (53.2%)\n Total number of events 79 40 95 44 81 60 \n dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\nnon observed SMQ02NAM level(BROAD) \n Total number of patients with at least one adverse event 0 0 0 0 0 0 \n Total number of events 0 0 0 0 0 0 \n\n\n\n\n\nCodecriteria_fun <- function(tr) !is(tr, \"ContentRow\") && all_zero_or_na(tr)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n split_cols_by(\"AGE65\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(unique = \"Total number of patients with at least one adverse event\")\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", drop = FALSE) %>%\n append_varlabels(adae_smq_1, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae_smq_1,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term < 65 >= 65 < 65 >= 65 < 65 >= 65\n (N=134) (N=0) (N=134) (N=0) (N=131) (N=1)\n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 72 (53.7%) 0 79 (59.0%) 0 75 (57.3%) 0 \nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 72 (53.7%) 0 79 (59.0%) 0 75 (57.3%) 0 \n Total number of events 119 0 139 0 141 0 \n dcd B.2.2.3.1 48 (35.8%) 0 54 (40.3%) 0 51 (38.9%) 0 \n dcd C.1.1.1.3 43 (32.1%) 0 46 (34.3%) 0 43 (32.8%) 0 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\") %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )\n\nnames_baskets <- grep(\"^(SMQ|CQ).*NAM$\", names(adae), value = TRUE)\nnames_scopes <- grep(\"^SMQ.*SC$\", names(adae), value = TRUE)\n\ncs_baskets <- choices_selected(\n choices = variable_choices(adae, subset = names_baskets),\n selected = names_baskets\n)\ncs_scopes <- choices_selected(\n choices = variable_choices(adae, subset = names_scopes),\n selected = names_scopes,\n fixed = TRUE\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )'\n ),\n cdisc_dataset(\"ADAE\", adae,\n code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\") %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_smq(\n label = \"Adverse events by `SMQ` Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"SEX\", \"AGE65\")),\n selected = c(\"ARM\", \"SEX\")\n ),\n add_total = FALSE,\n baskets = cs_baskets,\n scopes = cs_scopes,\n llt = choices_selected(\n choices = variable_choices(adae, subset = c(\"AEDECOD\")),\n selected = \"AEDECOD\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:47:06.1330 pid:6183 token:[] teal.modules.clinical Initializing tm_t_smq\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] stringr_1.5.0 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] stringi_1.7.12 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nAdverse Events by Sex, by SMQ and Preferred Term\nAdverse Events by Sex, by SMQ and Preferred Term (with Customized Queries)\nAdverse Events by Other Baseline Characteristics (e.g. Age Group)\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(stringr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\")\n\nadsl_labels <- var_labels(adsl)\nadae_labels <- var_labels(adae)\n\nadsl <- adsl %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )\n\nadae <- adae %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing\n# levels. For details, refer to Teal and Study Data article.\nadsl <- df_explicit_na(adsl)\nadae <- df_explicit_na(adae)\n\n# Simulate a random AAG dataset.\naag <- data.frame(\n NAMVAR = c(\"SMQ01NAM\", \"SMQ01NAM\", \"SMQ02NAM\", \"CQ01NAM\", \"CQ01NAM\"),\n SRCVAR = rep(\"AEDECOD\", 5),\n GRPTYPE = c(\"SMQ\", \"SMQ\", \"SMQ\", \"CUSTOM\", \"CUSTOM\"),\n REFID = c(1, 1, 2, 3, 3),\n REFNAME = c(rep(\"C.1.1.1.3/B.2.2.3.1 AESI\", 2), \"non observed SMQ02NAM level\", rep(\"D.2.1.5.3/A.1.1.1.1 AESI\", 2)),\n SCOPE = c(\"BROAD\", \"BROAD\", \"BROAD\", \"\", \"\"),\n REFTERM = c(\"C.1.1.1.3\", \"B.2.2.3.1\", \"Z.9.9.9.9\", \"D.2.1.5.3\", \"A.1.1.1.1\"),\n stringsAsFactors = FALSE\n)\n\n# Create summary AAG dataset (used for labelling).\n# Note it's important to incorporate SCOPE into the basket names for SMQs so as to\n# match the flags present in ADAE.\naag_summary <- aag %>%\n select(NAMVAR, REFNAME, SCOPE) %>%\n unique() %>%\n mutate(\n REFNAME_SCOPE = ifelse(SCOPE == \"\", REFNAME, paste0(REFNAME, \"(\", SCOPE, \")\"))\n ) %>%\n rename(basket = NAMVAR, basket_name = REFNAME_SCOPE) %>%\n select(basket, basket_name)\n\n# Make a summary of the full ADAE based on AAG by using h_stack_by_baskets helper function\nadae_smq_all <- h_stack_by_baskets(\n df = adae,\n aag_summary = aag_summary,\n keys = c(\"STUDYID\", \"USUBJID\", \"ACTARMCD\", \"AEDECOD\", \"SEX\", \"AGE65\")\n)\n# Post-process adae_smq_all to keep only certain baskets of interest for variant 1\n# Not need to drop baskets for variant 2 as all baskets will be considered.\nbaskets_to_drop_variant <- aag_summary$basket_name[!aag_summary$basket %in% c(\"SMQ01NAM\")]\n\n# Adjust the analysis dataset based on basket subset for variant 1.\nadae_smq_1 <- adae_smq_all %>%\n filter(!adae_smq_all$SMQ %in% baskets_to_drop_variant) %>%\n mutate(\n SMQ = tern::fct_discard(SMQ, discard = baskets_to_drop_variant)\n )\n\n\n\n\n\nCodecriteria_fun <- function(tr) !is(tr, \"ContentRow\") && all_zero_or_na(tr)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n split_cols_by(\"SEX\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(unique = \"Total number of patients with at least one adverse event\")\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", drop = FALSE) %>%\n append_varlabels(adae_smq_1, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae_smq_1,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term F M F M F M \n (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 47 (59.5%) 25 (45.5%) 51 (62.2%) 28 (53.8%) 42 (60.0%) 33 (53.2%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 47 (59.5%) 25 (45.5%) 51 (62.2%) 28 (53.8%) 42 (60.0%) 33 (53.2%)\n Total number of events 79 40 95 44 81 60 \n dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\n\n\n\n\n\nCodecriteria_fun <- function(tr) {\n !is(tr, \"ContentRow\") && all_zero_or_na(tr) && !grepl(\"Total number of\", obj_label(tr))\n}\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n split_cols_by(\"SEX\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(unique = \"Total number of patients with at least one adverse event\")\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n analyze_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n ),\n show_labels = \"hidden\"\n ) %>%\n count_occurrences(vars = \"AEDECOD\", drop = FALSE) %>%\n append_varlabels(adae_smq_all, \"AEDECOD\", indent = 1L)\n\nscore_ae_pts <- function(tt) {\n count_vals <- cell_values(tree_children(tt)[[\"USUBJID\"]])[[1]]\n sum(matrix(unlist(count_vals), nrow = length(count_vals), byrow = TRUE)[, 1])\n}\n\nresult <- build_table(\n lyt = lyt,\n df = adae_smq_all,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = score_ae_pts) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term F M F M F M \n (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 59 (74.7%) 36 (65.5%) 68 (82.9%) 35 (67.3%) 61 (87.1%) 47 (75.8%)\nD.2.1.5.3/A.1.1.1.1 AESI \n Total number of patients with at least one adverse event 45 (57.0%) 29 (52.7%) 54 (65.9%) 26 (50.0%) 50 (71.4%) 37 (59.7%)\n Total number of events 78 48 91 43 88 74 \n dcd D.2.1.5.3 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%)\n dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%)\nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 47 (59.5%) 25 (45.5%) 51 (62.2%) 28 (53.8%) 42 (60.0%) 33 (53.2%)\n Total number of events 79 40 95 44 81 60 \n dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%)\n dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%)\nnon observed SMQ02NAM level(BROAD) \n Total number of patients with at least one adverse event 0 0 0 0 0 0 \n Total number of events 0 0 0 0 0 0 \n\n\n\n\n\nCodecriteria_fun <- function(tr) !is(tr, \"ContentRow\") && all_zero_or_na(tr)\n\nlyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ACTARMCD\") %>%\n split_cols_by(\"AGE65\") %>%\n analyze_num_patients(\n vars = \"USUBJID\",\n .stats = c(\"unique\"),\n .labels = c(unique = \"Total number of patients with at least one adverse event\")\n ) %>%\n split_rows_by(\n \"SMQ\",\n child_labels = \"visible\",\n nested = FALSE,\n split_fun = trim_levels_in_group(\"AEDECOD\", drop_outlevs = FALSE),\n label_pos = \"topleft\",\n split_label = \"Standardized MedDRA Query\"\n ) %>%\n summarize_num_patients(\n var = \"USUBJID\",\n .stats = c(\"unique\", \"nonunique\"),\n .labels = c(\n unique = \"Total number of patients with at least one adverse event\",\n nonunique = \"Total number of events\"\n )\n ) %>%\n count_occurrences(vars = \"AEDECOD\", drop = FALSE) %>%\n append_varlabels(adae_smq_1, \"AEDECOD\", indent = 1L)\n\nresult <- build_table(\n lyt = lyt,\n df = adae_smq_1,\n alt_counts_df = adsl\n) %>%\n sort_at_path(path = c(\"SMQ\"), scorefun = cont_n_allcols) %>%\n sort_at_path(path = c(\"SMQ\", \"*\", \"AEDECOD\"), scorefun = score_occurrences, na.pos = \"last\") %>%\n trim_rows(criteria = criteria_fun)\n\nresult\n\nStandardized MedDRA Query ARM A ARM B ARM C \n Dictionary-Derived Term < 65 >= 65 < 65 >= 65 < 65 >= 65\n (N=134) (N=0) (N=134) (N=0) (N=131) (N=1)\n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal number of patients with at least one adverse event 72 (53.7%) 0 79 (59.0%) 0 75 (57.3%) 0 \nC.1.1.1.3/B.2.2.3.1 AESI(BROAD) \n Total number of patients with at least one adverse event 72 (53.7%) 0 79 (59.0%) 0 75 (57.3%) 0 \n Total number of events 119 0 139 0 141 0 \n dcd B.2.2.3.1 48 (35.8%) 0 54 (40.3%) 0 51 (38.9%) 0 \n dcd C.1.1.1.3 43 (32.1%) 0 46 (34.3%) 0 43 (32.8%) 0 \n\n\n\n\n\nCodelibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )\nadae <- synthetic_cdisc_dataset(\"latest\", \"adae\") %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )\n\nnames_baskets <- grep(\"^(SMQ|CQ).*NAM$\", names(adae), value = TRUE)\nnames_scopes <- grep(\"^SMQ.*SC$\", names(adae), value = TRUE)\n\ncs_baskets <- choices_selected(\n choices = variable_choices(adae, subset = names_baskets),\n selected = names_baskets\n)\ncs_scopes <- choices_selected(\n choices = variable_choices(adae, subset = names_scopes),\n selected = names_scopes,\n fixed = TRUE\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl,\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )'\n ),\n cdisc_dataset(\"ADAE\", adae,\n code = 'ADAE <- synthetic_cdisc_dataset(\"latest\", \"adae\") %>%\n mutate(\n AGE65 = case_when(\n AGE >= 65 ~ \">= 65\",\n TRUE ~ \"< 65\"\n ),\n AGE65 = factor(\n AGE65,\n levels = c(\"< 65\", \">= 65\")\n )\n )'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_smq(\n label = \"Adverse events by `SMQ` Table\",\n dataname = \"ADAE\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, subset = c(\"ARM\", \"SEX\", \"AGE65\")),\n selected = c(\"ARM\", \"SEX\")\n ),\n add_total = FALSE,\n baskets = cs_baskets,\n scopes = cs_scopes,\n llt = choices_selected(\n choices = variable_choices(adae, subset = c(\"AEDECOD\")),\n selected = \"AEDECOD\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:07:44.1243 pid:6187 token:[] teal.modules.clinical Initializing tm_t_smq\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] stringr_1.5.0 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] stringi_1.7.12 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/pharmacokinetic/pkpt04.html",
@@ -746,70 +746,70 @@
"href": "tables/efficacy/cfbt01.html",
"title": "CFBT01",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\n# This example focuses on \"BFI All Questions\" starting from baseline.\nadqs <- adqs %>%\n dplyr::filter(\n PARAM == \"BFI All Questions\",\n AVISIT != \"SCREENING\"\n )\n\n# Define the split function for AVISIT\nsplit_fun <- drop_split_levels\n\n\n\n\n\nCodeafun <- function(x, .var, .spl_context, ...) {\n n_fun <- sum(!is.na(x), na.rm = TRUE)\n if (n_fun == 0) {\n mean_sd_fun <- c(NA, NA)\n median_fun <- NA\n min_max_fun <- c(NA, NA)\n } else {\n mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))\n median_fun <- median(x, na.rm = TRUE)\n min_max_fun <- c(min(x), max(x))\n }\n is_chg <- .var == \"CHG\"\n is_baseline <- .spl_context$value[which(.spl_context$split == \"AVISIT\")] == \"BASELINE\"\n if (is_baseline && is_chg) n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL\n\n in_rows(\n \"n\" = n_fun,\n \"Mean (SD)\" = mean_sd_fun,\n \"Median\" = median_fun,\n \"Min - Max\" = min_max_fun,\n .formats = list(\"n\" = \"xx\", \"Mean (SD)\" = \"xx.xx (xx.xx)\", \"Median\" = \"xx.xx\", \"Min - Max\" = \"xx.xx - xx.xx\"),\n .format_na_strs = list(\"n\" = \"NE\", \"Mean (SD)\" = \"NE (NE)\", \"Median\" = \"NE\", \"Min - Max\" = \"NE - NE\")\n )\n}\n\nlyt <- basic_table() %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adqs$PARAM)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adqs$AVISIT)\n ) %>%\n split_cols_by_multivar(\n vars = c(\"AVAL\", \"CHG\"),\n varlabels = c(\"Value at Visit\", \"Change from\\nBaseline\")\n ) %>%\n analyze_colvars(afun = afun)\n\nresult <- build_table(lyt, adqs)\nresult\n\nParameter A: Drug X B: Placebo C: Combination \n Analysis Visit Change from Change from Change from \n Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nBFI All Questions \n BASELINE \n n 134 134 132 \n Mean (SD) 49.93 (7.44) 49.74 (8.29) 50.30 (9.06) \n Median 48.69 49.28 49.74 \n Min - Max 33.72 - 65.91 25.82 - 71.47 26.04 - 69.99 \n WEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 54.51 (8.61) 4.58 (11.23) 56.33 (7.86) 6.59 (11.81) 54.03 (8.31) 3.72 (12.66) \n Median 55.15 5.47 56.39 6.96 53.76 3.71 \n Min - Max 34.26 - 75.42 -25.52 - 29.68 36.82 - 74.45 -25.10 - 31.05 26.89 - 75.95 -26.81 - 33.75\n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 60.98 (10.31) 11.05 (12.46) 59.68 (9.59) 9.94 (12.84) 60.11 (8.76) 9.80 (12.59) \n Median 60.60 10.45 58.18 8.95 61.08 10.04 \n Min - Max 35.94 - 96.53 -14.02 - 45.01 40.44 - 84.70 -17.59 - 40.52 32.76 - 78.25 -26.57 - 39.56\n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 64.64 (9.88) 14.72 (11.99) 65.78 (10.17) 16.04 (13.80) 63.65 (10.50) 13.35 (13.39) \n Median 65.21 15.10 66.28 15.49 63.79 12.24 \n Min - Max 40.49 - 95.35 -16.76 - 43.40 42.16 - 92.32 -17.70 - 46.85 29.29 - 88.41 -22.40 - 39.94\n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 69.43 (11.12) 19.51 (13.83) 69.79 (11.46) 20.05 (14.38) 70.68 (10.23) 20.37 (12.99) \n Median 69.22 19.90 70.37 20.99 70.85 20.94 \n Min - Max 38.38 - 95.48 -17.34 - 49.18 45.79 - 93.33 -19.66 - 58.05 30.53 - 90.61 -14.01 - 60.23\n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 74.31 (12.44) 24.38 (14.75) 74.73 (12.96) 24.99 (14.67) 75.89 (13.54) 25.59 (17.18) \n Median 76.12 25.20 74.13 22.81 76.70 25.32 \n Min - Max 39.45 - 103.92 -7.53 - 56.23 38.19 - 109.61 -18.42 - 64.15 43.79 - 102.40 -16.11 - 67.78\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'adsl <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\"ADQS\",\n adqs,\n code = 'adqs <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adqs\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Efficacy Data and Change from Baseline by Visit\",\n dataname = \"ADQS\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adqs, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adqs, c(\"AVAL\", \"CHG\")),\n selected = c(\"AVAL\", \"CHG\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = \"BFIALL\"\n ),\n add_total = FALSE,\n parallel_vars = TRUE\n )\n ),\n filter = list(ADQS = list(AVISIT = list(), AVAL = list()))\n)\n\n[INFO] 2023-09-08 19:49:55.6953 pid:7093 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\n# This example focuses on \"BFI All Questions\" starting from baseline.\nadqs <- adqs %>%\n dplyr::filter(\n PARAM == \"BFI All Questions\",\n AVISIT != \"SCREENING\"\n )\n\n# Define the split function for AVISIT\nsplit_fun <- drop_split_levels\n\n\n\n\n\nCodeafun <- function(x, .var, .spl_context, ...) {\n n_fun <- sum(!is.na(x), na.rm = TRUE)\n if (n_fun == 0) {\n mean_sd_fun <- c(NA, NA)\n median_fun <- NA\n min_max_fun <- c(NA, NA)\n } else {\n mean_sd_fun <- c(mean(x, na.rm = TRUE), sd(x, na.rm = TRUE))\n median_fun <- median(x, na.rm = TRUE)\n min_max_fun <- c(min(x), max(x))\n }\n is_chg <- .var == \"CHG\"\n is_baseline <- .spl_context$value[which(.spl_context$split == \"AVISIT\")] == \"BASELINE\"\n if (is_baseline && is_chg) n_fun <- mean_sd_fun <- median_fun <- min_max_fun <- NULL\n\n in_rows(\n \"n\" = n_fun,\n \"Mean (SD)\" = mean_sd_fun,\n \"Median\" = median_fun,\n \"Min - Max\" = min_max_fun,\n .formats = list(\"n\" = \"xx\", \"Mean (SD)\" = \"xx.xx (xx.xx)\", \"Median\" = \"xx.xx\", \"Min - Max\" = \"xx.xx - xx.xx\"),\n .format_na_strs = list(\"n\" = \"NE\", \"Mean (SD)\" = \"NE (NE)\", \"Median\" = \"NE\", \"Min - Max\" = \"NE - NE\")\n )\n}\n\nlyt <- basic_table() %>%\n split_cols_by(\"ARM\") %>%\n split_rows_by(\n \"PARAM\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adqs$PARAM)\n ) %>%\n split_rows_by(\n \"AVISIT\",\n split_fun = split_fun,\n label_pos = \"topleft\",\n split_label = obj_label(adqs$AVISIT)\n ) %>%\n split_cols_by_multivar(\n vars = c(\"AVAL\", \"CHG\"),\n varlabels = c(\"Value at Visit\", \"Change from\\nBaseline\")\n ) %>%\n analyze_colvars(afun = afun)\n\nresult <- build_table(lyt, adqs)\nresult\n\nParameter A: Drug X B: Placebo C: Combination \n Analysis Visit Change from Change from Change from \n Value at Visit Baseline Value at Visit Baseline Value at Visit Baseline \n———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nBFI All Questions \n BASELINE \n n 134 134 132 \n Mean (SD) 49.93 (7.44) 49.74 (8.29) 50.30 (9.06) \n Median 48.69 49.28 49.74 \n Min - Max 33.72 - 65.91 25.82 - 71.47 26.04 - 69.99 \n WEEK 1 DAY 8 \n n 134 134 134 134 132 132 \n Mean (SD) 54.51 (8.61) 4.58 (11.23) 56.33 (7.86) 6.59 (11.81) 54.03 (8.31) 3.72 (12.66) \n Median 55.15 5.47 56.39 6.96 53.76 3.71 \n Min - Max 34.26 - 75.42 -25.52 - 29.68 36.82 - 74.45 -25.10 - 31.05 26.89 - 75.95 -26.81 - 33.75\n WEEK 2 DAY 15 \n n 134 134 134 134 132 132 \n Mean (SD) 60.98 (10.31) 11.05 (12.46) 59.68 (9.59) 9.94 (12.84) 60.11 (8.76) 9.80 (12.59) \n Median 60.60 10.45 58.18 8.95 61.08 10.04 \n Min - Max 35.94 - 96.53 -14.02 - 45.01 40.44 - 84.70 -17.59 - 40.52 32.76 - 78.25 -26.57 - 39.56\n WEEK 3 DAY 22 \n n 134 134 134 134 132 132 \n Mean (SD) 64.64 (9.88) 14.72 (11.99) 65.78 (10.17) 16.04 (13.80) 63.65 (10.50) 13.35 (13.39) \n Median 65.21 15.10 66.28 15.49 63.79 12.24 \n Min - Max 40.49 - 95.35 -16.76 - 43.40 42.16 - 92.32 -17.70 - 46.85 29.29 - 88.41 -22.40 - 39.94\n WEEK 4 DAY 29 \n n 134 134 134 134 132 132 \n Mean (SD) 69.43 (11.12) 19.51 (13.83) 69.79 (11.46) 20.05 (14.38) 70.68 (10.23) 20.37 (12.99) \n Median 69.22 19.90 70.37 20.99 70.85 20.94 \n Min - Max 38.38 - 95.48 -17.34 - 49.18 45.79 - 93.33 -19.66 - 58.05 30.53 - 90.61 -14.01 - 60.23\n WEEK 5 DAY 36 \n n 134 134 134 134 132 132 \n Mean (SD) 74.31 (12.44) 24.38 (14.75) 74.73 (12.96) 24.99 (14.67) 75.89 (13.54) 25.59 (17.18) \n Median 76.12 25.20 74.13 22.81 76.70 25.32 \n Min - Max 39.45 - 103.92 -7.53 - 56.23 38.19 - 109.61 -18.42 - 64.15 43.79 - 102.40 -16.11 - 67.78\n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\",\n adsl,\n code = 'adsl <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'\n ),\n cdisc_dataset(\"ADQS\",\n adqs,\n code = 'adqs <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adqs\"))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_summary_by(\n label = \"Efficacy Data and Change from Baseline by Visit\",\n dataname = \"ADQS\",\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n selected = \"ARM\"\n ),\n by_vars = choices_selected(\n choices = variable_choices(adqs, c(\"PARAM\", \"AVISIT\")),\n selected = c(\"AVISIT\")\n ),\n summarize_vars = choices_selected(\n choices = variable_choices(adqs, c(\"AVAL\", \"CHG\")),\n selected = c(\"AVAL\", \"CHG\")\n ),\n useNA = \"ifany\",\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = \"BFIALL\"\n ),\n add_total = FALSE,\n parallel_vars = TRUE\n )\n ),\n filter = list(ADQS = list(AVISIT = list(), AVAL = list()))\n)\n\n[INFO] 2023-09-09 18:11:51.5296 pid:7098 token:[] teal.modules.clinical Initializing tm_t_summary_by\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/efficacy/rspt01.html",
"href": "tables/efficacy/rspt01.html",
"title": "RSPT01",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Selecting Sections to Display\nTable Modifying Analysis Details like Type of Confidence Interval, Alpha Level, Test Statistic\nTable with Stratified Analysis\nTable Modifying the Definition of Overall Response\nTable Defining New Sections to Display\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadrs <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadrs <- df_explicit_na(adrs)\n\nanl_adrs <- adrs %>%\n filter(PARAMCD == \"INVET\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVISIT, AVALC)\nanl_adsl <- adsl %>%\n select(STUDYID, USUBJID, ARM, STRATA1)\n\n\nData pre-processing is done to label the analysis value (AVALC) so as to improve the readability of the output table. In addition, the response is binary defined (is_rsp, responder yes/no) depending on the analysis value. Finally, for comparison purposes, the reference arm is specified.\n\nCode# Pre-Processing\n\nanl <- anl_adsl %>%\n left_join(anl_adrs, by = c(\"STUDYID\", \"USUBJID\")) %>%\n mutate(rsp_lab = d_onco_rsp_label(AVALC)) %>%\n mutate(is_rsp = AVALC %in% c(\"CR\", \"PR\")) %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\")\n\n\n\n\nThe tabulation layout is built in layers for the analysis of overall response and applied to the pre-processed dataset.\n\nCodelyt_01 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(\n vars = \"is_rsp\",\n table_names = \"est_prop\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Unstratified Analysis\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n table_names = \"test_prop_diff\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n table_names = \"est_or\"\n ) %>%\n estimate_multinomial_response(var = \"rsp_lab\")\n\nresult <- build_table(lyt = lyt_01, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————\nResponders 100 (74.6%) 84 (62.7%) 81 (61.4%) \n95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) \nUnstratified Analysis \n Difference in Response rate (%) -11.9 -13.3 \n 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) \n p-value (Chi-Squared Test) 0.0351 0.0204 \nOdds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.91)\nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) \nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) \nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\nRemove (or add) rows of results by removing/adding the corresponding layers from the layout. For instance, the odds-ratio row is removed by simply removing the estimate_odds_ratio call:\n\nCodelyt_02 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(\n vars = \"is_rsp\",\n table_names = \"est_prop\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Unstratified Analysis\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n table_names = \"test_prop\"\n ) %>%\n estimate_multinomial_response(var = \"rsp_lab\")\n\nresult <- build_table(lyt = lyt_02, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\nResponders 100 (74.6%) 84 (62.7%) 81 (61.4%) \n95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) \nUnstratified Analysis \n Difference in Response rate (%) -11.9 -13.3 \n 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) \n p-value (Chi-Squared Test) 0.0351 0.0204 \nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01)\nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14)\nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77)\nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\nThe confidence level is controlled by the conf_level parameter to the estimation functions. Similarly, the methods for tests and confidence interval can be modified (see ?estimate_proportion_diff).\n\nCodeconf_level <- 0.90\nlyt_03 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(\n vars = \"is_rsp\",\n conf_level = conf_level,\n method = \"clopper-pearson\",\n table_names = \"est_prop\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Unstratified Analysis\",\n conf_level = conf_level,\n method = \"ha\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n method = \"fisher\",\n table_names = \"test_prop\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n conf_level = conf_level,\n table_names = \"est_or\"\n ) %>%\n estimate_multinomial_response(\n var = \"rsp_lab\",\n conf_level = conf_level,\n method = \"clopper-pearson\"\n )\n\nresult <- build_table(lyt = lyt_03, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nResponders 100 (74.6%) 84 (62.7%) 81 (61.4%) \n90% CI (Clopper-Pearson) (67.7, 80.7) (55.3, 69.7) (53.9, 68.5) \nUnstratified Analysis \n Difference in Response rate (%) -11.9 -13.3 \n 90% CI (Anderson-Hauck) (-21.6, -2.3) (-23.0, -3.5) \n p-value (Fisher's Exact Test) 0.0479 0.0253 \nOdds Ratio (90% CI) 0.57 (0.37 - 0.89) 0.54 (0.35 - 0.84)\nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 90% CI (Clopper-Pearson) (37.48, 52.25) (28.22, 42.43) (35.88, 50.71) \nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 90% CI (Clopper-Pearson) (23.36, 37.02) (21.31, 34.67) (12.87, 24.61) \nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 90% CI (Clopper-Pearson) (3.55, 11.43) (11.38, 22.61) (5.92, 15.20) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 90% CI (Clopper-Pearson) (12.67, 24.25) (7.63, 17.57) (18.90, 31.97) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 90% CI (Clopper-Pearson) (0.04, 3.49) (5.25, 14.11) (1.50, 7.80) \n\n\n\n\nThe stratified analysis section can be added by defining the analyses needed with control_binary_comparison for the argument strat_analysis and identifying the stratification variables to use.\n\nCodestrata <- \"STRATA1\"\nlyt_04 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(\n vars = \"is_rsp\",\n table_names = \"est_prop\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Unstratified Analysis\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n table_names = \"test_prop\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n table_names = \"est_or\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Stratified Analysis\",\n method = \"cmh\",\n variables = list(strata = strata),\n table_names = \"est_prop_diff_strat\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n method = \"cmh\",\n variables = list(strata = strata),\n table_names = \"test_prop_strat\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n variables = list(strata = strata, arm = \"ARM\"),\n table_names = \"est_or_strat\"\n ) %>%\n estimate_multinomial_response(var = \"rsp_lab\")\n\nresult <- build_table(lyt = lyt_04, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nResponders 100 (74.6%) 84 (62.7%) 81 (61.4%) \n95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) \nUnstratified Analysis \n Difference in Response rate (%) -11.9 -13.3 \n 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) \n p-value (Chi-Squared Test) 0.0351 0.0204 \nOdds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.91)\nStratified Analysis \n Difference in Response rate (%) -11.9 -13.5 \n 95% CI (CMH, without correction) (-22.7, -1.0) (-24.5, -2.5) \n p-value (Cochran-Mantel-Haenszel Test) 0.0366 0.0180 \nOdds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.90)\nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) \nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) \nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\nThe definition of responders is realized during the pre-processing step. The layout does not need to be modified and can be reused.\n\nCodeanl <- anl_adsl %>%\n left_join(anl_adrs, by = c(\"STUDYID\", \"USUBJID\")) %>%\n mutate(rsp_lab = d_onco_rsp_label(AVALC)) %>%\n mutate(is_rsp = AVALC == \"CR\") %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\")\n\nresult <- build_table(lyt = lyt_01, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————\nResponders 60 (44.8%) 47 (35.1%) 57 (43.2%) \n95% CI (Wald, with correction) (36.0, 53.6) (26.6, 43.5) (34.4, 52.0) \nUnstratified Analysis \n Difference in Response rate (%) -9.7 -1.6 \n 95% CI (Wald, with correction) (-22.1, 2.7) (-14.3, 11.1) \n p-value (Chi-Squared Test) 0.1049 0.7934 \nOdds Ratio (95% CI) 0.67 (0.41 - 1.09) 0.94 (0.58 - 1.52)\nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) \nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) \nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\nSimilarly to in the previous tab, redefinition or relabeling of the result is a pre-processing step and the original table layout can be reused.\n\nCodeanl <- anl_adsl %>%\n left_join(anl_adrs, by = c(\"STUDYID\", \"USUBJID\")) %>%\n mutate(rsp_lab = as.character(d_onco_rsp_label(AVALC))) %>%\n mutate(\n rsp_lab = case_when(\n rsp_lab == \"Complete Response (CR)\" ~ \"No Progression\",\n rsp_lab == \"Partial Response (PR)\" ~ \"No Progression\",\n rsp_lab == \"Stable Disease (SD)\" ~ \"No Progression\",\n TRUE ~ rsp_lab\n )\n ) %>%\n mutate(is_rsp = rsp_lab %in% \"No Progression\") %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\")\n\nresult <- build_table(lyt = lyt_01, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————\nResponders 109 (81.3%) 106 (79.1%) 94 (71.2%) \n95% CI (Wald, with correction) (74.4, 88.3) (71.8, 86.4) (63.1, 79.3) \nUnstratified Analysis \n Difference in Response rate (%) -2.2 -10.1 \n 95% CI (Wald, with correction) (-12.5, 8.0) (-21.0, 0.8) \n p-value (Chi-Squared Test) 0.6455 0.0520 \nOdds Ratio (95% CI) 0.87 (0.48 - 1.59) 0.57 (0.32 - 1.01)\nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) \nNo Progression 109 (81.3%) 106 (79.1%) 94 (71.2%) \n 95% CI (Wald, with correction) (74.37, 88.31) (71.85, 86.36) (63.11, 79.31) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nADSL <- df_explicit_na(ADSL)\nADRS <- df_explicit_na(ADRS)\n\nADSL <- ADSL %>%\n mutate(Dum_ARM = factor(rep(\"Single ARM\", nrow(.))))\nADRS <- ADRS %>%\n mutate(Dum_ARM = factor(rep(\"Single ARM\", nrow(.))))\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\n dataname = \"ADSL\",\n x = ADSL,\n code =\n 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\")) %>%\n mutate(Dum_ARM = factor(rep(\"Single ARM\", nrow(.))))'\n ),\n cdisc_dataset(\n dataname = \"ADRS\",\n x = ADRS,\n code =\n 'ADRS <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adrs\")) %>%\n mutate(Dum_ARM = factor(rep(\"Single ARM\", nrow(.))))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_binary_outcome(\n label = \"Responders\",\n dataname = \"ADRS\",\n paramcd = choices_selected(\n choices = value_choices(ADRS, \"PARAMCD\", \"PARAM\"),\n selected = \"BESRSPI\"\n ),\n arm_var = choices_selected(\n choices = variable_choices(ADRS, c(\"ARM\", \"ARMCD\", \"ACTARMCD\", \"Dum_ARM\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n strata_var = choices_selected(\n choices = variable_choices(ADRS, c(\"SEX\", \"BMRKR2\")),\n select = NULL\n ),\n rsp_table = TRUE\n )\n )\n)\n\n[INFO] 2023-09-08 19:51:15.8818 pid:7292 token:[] teal.modules.clinical Initializing tm_t_binary_outcome\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Selecting Sections to Display\nTable Modifying Analysis Details like Type of Confidence Interval, Alpha Level, Test Statistic\nTable with Stratified Analysis\nTable Modifying the Definition of Overall Response\nTable Defining New Sections to Display\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadrs <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadrs <- df_explicit_na(adrs)\n\nanl_adrs <- adrs %>%\n filter(PARAMCD == \"INVET\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVISIT, AVALC)\nanl_adsl <- adsl %>%\n select(STUDYID, USUBJID, ARM, STRATA1)\n\n\nData pre-processing is done to label the analysis value (AVALC) so as to improve the readability of the output table. In addition, the response is binary defined (is_rsp, responder yes/no) depending on the analysis value. Finally, for comparison purposes, the reference arm is specified.\n\nCode# Pre-Processing\n\nanl <- anl_adsl %>%\n left_join(anl_adrs, by = c(\"STUDYID\", \"USUBJID\")) %>%\n mutate(rsp_lab = d_onco_rsp_label(AVALC)) %>%\n mutate(is_rsp = AVALC %in% c(\"CR\", \"PR\")) %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\")\n\n\n\n\nThe tabulation layout is built in layers for the analysis of overall response and applied to the pre-processed dataset.\n\nCodelyt_01 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(\n vars = \"is_rsp\",\n table_names = \"est_prop\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Unstratified Analysis\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n table_names = \"test_prop_diff\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n table_names = \"est_or\"\n ) %>%\n estimate_multinomial_response(var = \"rsp_lab\")\n\nresult <- build_table(lyt = lyt_01, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————\nResponders 100 (74.6%) 84 (62.7%) 81 (61.4%) \n95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) \nUnstratified Analysis \n Difference in Response rate (%) -11.9 -13.3 \n 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) \n p-value (Chi-Squared Test) 0.0351 0.0204 \nOdds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.91)\nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) \nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) \nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\nRemove (or add) rows of results by removing/adding the corresponding layers from the layout. For instance, the odds-ratio row is removed by simply removing the estimate_odds_ratio call:\n\nCodelyt_02 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(\n vars = \"is_rsp\",\n table_names = \"est_prop\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Unstratified Analysis\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n table_names = \"test_prop\"\n ) %>%\n estimate_multinomial_response(var = \"rsp_lab\")\n\nresult <- build_table(lyt = lyt_02, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————\nResponders 100 (74.6%) 84 (62.7%) 81 (61.4%) \n95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) \nUnstratified Analysis \n Difference in Response rate (%) -11.9 -13.3 \n 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) \n p-value (Chi-Squared Test) 0.0351 0.0204 \nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01)\nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14)\nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77)\nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\nThe confidence level is controlled by the conf_level parameter to the estimation functions. Similarly, the methods for tests and confidence interval can be modified (see ?estimate_proportion_diff).\n\nCodeconf_level <- 0.90\nlyt_03 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(\n vars = \"is_rsp\",\n conf_level = conf_level,\n method = \"clopper-pearson\",\n table_names = \"est_prop\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Unstratified Analysis\",\n conf_level = conf_level,\n method = \"ha\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n method = \"fisher\",\n table_names = \"test_prop\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n conf_level = conf_level,\n table_names = \"est_or\"\n ) %>%\n estimate_multinomial_response(\n var = \"rsp_lab\",\n conf_level = conf_level,\n method = \"clopper-pearson\"\n )\n\nresult <- build_table(lyt = lyt_03, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n————————————————————————————————————————————————————————————————————————————————————————————\nResponders 100 (74.6%) 84 (62.7%) 81 (61.4%) \n90% CI (Clopper-Pearson) (67.7, 80.7) (55.3, 69.7) (53.9, 68.5) \nUnstratified Analysis \n Difference in Response rate (%) -11.9 -13.3 \n 90% CI (Anderson-Hauck) (-21.6, -2.3) (-23.0, -3.5) \n p-value (Fisher's Exact Test) 0.0479 0.0253 \nOdds Ratio (90% CI) 0.57 (0.37 - 0.89) 0.54 (0.35 - 0.84)\nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 90% CI (Clopper-Pearson) (37.48, 52.25) (28.22, 42.43) (35.88, 50.71) \nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 90% CI (Clopper-Pearson) (23.36, 37.02) (21.31, 34.67) (12.87, 24.61) \nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 90% CI (Clopper-Pearson) (3.55, 11.43) (11.38, 22.61) (5.92, 15.20) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 90% CI (Clopper-Pearson) (12.67, 24.25) (7.63, 17.57) (18.90, 31.97) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 90% CI (Clopper-Pearson) (0.04, 3.49) (5.25, 14.11) (1.50, 7.80) \n\n\n\n\nThe stratified analysis section can be added by defining the analyses needed with control_binary_comparison for the argument strat_analysis and identifying the stratification variables to use.\n\nCodestrata <- \"STRATA1\"\nlyt_04 <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(var = \"ARM\", ref_group = \"A: Drug X\") %>%\n estimate_proportion(\n vars = \"is_rsp\",\n table_names = \"est_prop\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Unstratified Analysis\",\n table_names = \"est_prop_diff\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n table_names = \"test_prop\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n table_names = \"est_or\"\n ) %>%\n estimate_proportion_diff(\n vars = \"is_rsp\",\n show_labels = \"visible\",\n var_labels = \"Stratified Analysis\",\n method = \"cmh\",\n variables = list(strata = strata),\n table_names = \"est_prop_diff_strat\"\n ) %>%\n test_proportion_diff(\n vars = \"is_rsp\",\n method = \"cmh\",\n variables = list(strata = strata),\n table_names = \"test_prop_strat\"\n ) %>%\n estimate_odds_ratio(\n vars = \"is_rsp\",\n variables = list(strata = strata, arm = \"ARM\"),\n table_names = \"est_or_strat\"\n ) %>%\n estimate_multinomial_response(var = \"rsp_lab\")\n\nresult <- build_table(lyt = lyt_04, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————————————\nResponders 100 (74.6%) 84 (62.7%) 81 (61.4%) \n95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) \nUnstratified Analysis \n Difference in Response rate (%) -11.9 -13.3 \n 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) \n p-value (Chi-Squared Test) 0.0351 0.0204 \nOdds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.91)\nStratified Analysis \n Difference in Response rate (%) -11.9 -13.5 \n 95% CI (CMH, without correction) (-22.7, -1.0) (-24.5, -2.5) \n p-value (Cochran-Mantel-Haenszel Test) 0.0366 0.0180 \nOdds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.90)\nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) \nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) \nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\nThe definition of responders is realized during the pre-processing step. The layout does not need to be modified and can be reused.\n\nCodeanl <- anl_adsl %>%\n left_join(anl_adrs, by = c(\"STUDYID\", \"USUBJID\")) %>%\n mutate(rsp_lab = d_onco_rsp_label(AVALC)) %>%\n mutate(is_rsp = AVALC == \"CR\") %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\")\n\nresult <- build_table(lyt = lyt_01, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————\nResponders 60 (44.8%) 47 (35.1%) 57 (43.2%) \n95% CI (Wald, with correction) (36.0, 53.6) (26.6, 43.5) (34.4, 52.0) \nUnstratified Analysis \n Difference in Response rate (%) -9.7 -1.6 \n 95% CI (Wald, with correction) (-22.1, 2.7) (-14.3, 11.1) \n p-value (Chi-Squared Test) 0.1049 0.7934 \nOdds Ratio (95% CI) 0.67 (0.41 - 1.09) 0.94 (0.58 - 1.52)\nComplete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) \n 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) \nPartial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) \n 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) \nStable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) \n 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) \nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\nSimilarly to in the previous tab, redefinition or relabeling of the result is a pre-processing step and the original table layout can be reused.\n\nCodeanl <- anl_adsl %>%\n left_join(anl_adrs, by = c(\"STUDYID\", \"USUBJID\")) %>%\n mutate(rsp_lab = as.character(d_onco_rsp_label(AVALC))) %>%\n mutate(\n rsp_lab = case_when(\n rsp_lab == \"Complete Response (CR)\" ~ \"No Progression\",\n rsp_lab == \"Partial Response (PR)\" ~ \"No Progression\",\n rsp_lab == \"Stable Disease (SD)\" ~ \"No Progression\",\n TRUE ~ rsp_lab\n )\n ) %>%\n mutate(is_rsp = rsp_lab %in% \"No Progression\") %>%\n mutate(ARM = relevel(ARM, ref = \"A: Drug X\")) %>%\n var_relabel(ARM = \"Description of Planned Arm\")\n\nresult <- build_table(lyt = lyt_01, df = anl)\nresult\n\n A: Drug X B: Placebo C: Combination \n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————————————————\nResponders 109 (81.3%) 106 (79.1%) 94 (71.2%) \n95% CI (Wald, with correction) (74.4, 88.3) (71.8, 86.4) (63.1, 79.3) \nUnstratified Analysis \n Difference in Response rate (%) -2.2 -10.1 \n 95% CI (Wald, with correction) (-12.5, 8.0) (-21.0, 0.8) \n p-value (Chi-Squared Test) 0.6455 0.0520 \nOdds Ratio (95% CI) 0.87 (0.48 - 1.59) 0.57 (0.32 - 1.01)\nProgressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) \n 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) \nNo Progression 109 (81.3%) 106 (79.1%) 94 (71.2%) \n 95% CI (Wald, with correction) (74.37, 88.31) (71.85, 86.36) (63.11, 79.31) \nNot Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) \n 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\nlibrary(dplyr)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADRS <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nADSL <- df_explicit_na(ADSL)\nADRS <- df_explicit_na(ADRS)\n\nADSL <- ADSL %>%\n mutate(Dum_ARM = factor(rep(\"Single ARM\", nrow(.))))\nADRS <- ADRS %>%\n mutate(Dum_ARM = factor(rep(\"Single ARM\", nrow(.))))\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\n dataname = \"ADSL\",\n x = ADSL,\n code =\n 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\")) %>%\n mutate(Dum_ARM = factor(rep(\"Single ARM\", nrow(.))))'\n ),\n cdisc_dataset(\n dataname = \"ADRS\",\n x = ADRS,\n code =\n 'ADRS <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adrs\")) %>%\n mutate(Dum_ARM = factor(rep(\"Single ARM\", nrow(.))))'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_binary_outcome(\n label = \"Responders\",\n dataname = \"ADRS\",\n paramcd = choices_selected(\n choices = value_choices(ADRS, \"PARAMCD\", \"PARAM\"),\n selected = \"BESRSPI\"\n ),\n arm_var = choices_selected(\n choices = variable_choices(ADRS, c(\"ARM\", \"ARMCD\", \"ACTARMCD\", \"Dum_ARM\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n strata_var = choices_selected(\n choices = variable_choices(ADRS, c(\"SEX\", \"BMRKR2\")),\n select = NULL\n ),\n rsp_table = TRUE\n )\n )\n)\n\n[INFO] 2023-09-09 18:13:26.2996 pid:7297 token:[] teal.modules.clinical Initializing tm_t_binary_outcome\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] scda_0.1.6.9012 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/efficacy/ttet01.html",
"href": "tables/efficacy/ttet01.html",
"title": "TTET01",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Selecting Sections to Display\nTable Modifying Analysis Details like Conf. Type, Ties, Alpha Level\nTable with Stratified Analysis\nTable Modifying Time Point for the “XX Months” Analysis\nTable Requesting > 1 p-value\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure that character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\nadtte_f <- adtte %>%\n dplyr::filter(PARAMCD == \"OS\") %>%\n dplyr::mutate(\n AVAL = day2month(AVAL),\n is_event = CNSR == 0,\n is_not_event = CNSR == 1,\n EVNT1 = factor(\n case_when(\n is_event == TRUE ~ \"Patients with event (%)\",\n is_event == FALSE ~ \"Patients without event (%)\"\n ),\n levels = c(\"Patients with event (%)\", \"Patients without event (%)\")\n ),\n EVNTDESC = factor(EVNTDESC)\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n var = \"ARM\", ref_group = \"A: Drug X\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n time_point = c(6, 12),\n is_event = \"is_event\",\n method = \"both\",\n control = control_surv_timepoint()\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n6 Months \n Patients remaining at risk 97 97 90 \n Event Free Rate (%) 72.39 72.39 68.18 \n 95% CI (64.82, 79.96) (64.82, 79.96) (60.24, 76.13)\n Difference in Event Free Rate 0.00 -4.21 \n 95% CI (-10.71, 10.71) (-15.18, 6.77)\n p-value (Z-test) 1.0000 0.4525 \n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 95% CI (48.33, 65.11) (48.33, 65.11) (39.21, 56.25)\n Difference in Event Free Rate 0.00 -8.99 \n 95% CI (-11.86, 11.86) (-20.95, 2.97)\n p-value (Z-test) 1.0000 0.1406 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n analyze_vars(\n \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n method = \"surv\",\n time_point = c(6, 12)\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n6 Months \n Patients remaining at risk 97 97 90 \n Event Free Rate (%) 72.39 72.39 68.18 \n 95% CI (64.82, 79.96) (64.82, 79.96) (60.24, 76.13)\n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 95% CI (48.33, 65.11) (48.33, 65.11) (39.21, 56.25)\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n control = control_surv_time(conf_level = 0.9, conf_type = \"log-log\"),\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(\n pval_method = \"log-rank\",\n conf_level = 0.95,\n ties = \"efron\"\n ),\n table_names = \"coxph_unstratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n time_point = 12,\n control = control_surv_timepoint(conf_level = 0.9, conf_type = \"log-log\"),\n table_names_suffix = \"_log_log\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n show_labels = \"hidden\",\n is_event = \"is_event\",\n time_point = 12,\n method = \"surv_diff\",\n control = control_surv_timepoint(conf_level = 0.975),\n table_names_suffix = \"_975_pct\"\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 90% CI (9.6, NA) (9.6, NA) (7.7, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 90% CI (49.37, 63.41) (49.37, 63.41) (40.42, 54.66)\nDifference in Event Free Rate 0.00 -8.99 \n 97.5% CI (-13.57, 13.57) (-22.66, 4.69)\n p-value (Z-test) 1.0000 0.1406 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n table_names = \"coxph_unstratified\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Stratified Analysis\",\n strat = \"SEX\",\n table_names = \"coxph_stratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n method = \"both\",\n time_point = 12\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \nStratified Analysis \n p-value (log-rank) 0.9978 0.1733 \n Hazard Ratio 1.00 1.27 \n 95% CI (0.69, 1.44) (0.90, 1.81) \n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 95% CI (48.33, 65.11) (48.33, 65.11) (39.21, 56.25)\n Difference in Event Free Rate 0.00 -8.99 \n 95% CI (-11.86, 11.86) (-20.95, 2.97)\n p-value (Z-test) 1.0000 0.1406 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n time_point = 6,\n method = \"both\"\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n6 Months \n Patients remaining at risk 97 97 90 \n Event Free Rate (%) 72.39 72.39 68.18 \n 95% CI (64.82, 79.96) (64.82, 79.96) (60.24, 76.13)\n Difference in Event Free Rate 0.00 -4.21 \n 95% CI (-10.71, 10.71) (-15.18, 6.77)\n p-value (Z-test) 1.0000 0.4525 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n .stats = \"pvalue\",\n table_names = \"coxph_unstratified\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n show_labels = \"hidden\",\n control = control_coxph(pval_method = \"wald\"),\n .stats = \"pvalue\",\n .indent_mods = c(pvalue = 1L),\n table_names = \"coxph_wald_pvalue\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n show_labels = \"hidden\",\n control = control_coxph(pval_method = \"likelihood\"),\n .indent_mods = c(pvalue = 1L, hr = 2L, hr_ci = 3L),\n table_names = \"coxph_likelihood_pvalue\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n time_point = 12,\n method = \"both\"\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n p-value (wald) 0.9998 0.1552 \n p-value (likelihood) 0.9998 0.1543 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 95% CI (48.33, 65.11) (48.33, 65.11) (39.21, 56.25)\n Difference in Event Free Rate 0.00 -8.99 \n 95% CI (-11.86, 11.86) (-20.95, 2.97)\n p-value (Z-test) 1.0000 0.1406 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% df_explicit_na()'),\n cdisc_dataset(\"ADTTE\", adtte, code = 'ADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\") %>% df_explicit_na()'),\n check = TRUE\n ),\n modules = modules(\n tm_t_tte(\n label = \"Time To Event Table\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(\n variable_choices(adsl, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adtte, \"PARAMCD\", \"PARAM\"),\n \"OS\"\n ),\n strata_var = choices_selected(\n variable_choices(adsl, c(\"SEX\", \"BMRKR2\")),\n \"SEX\"\n ),\n time_points = choices_selected(c(6, 8), 6),\n event_desc_var = choices_selected(\n variable_choices(adtte, \"EVNTDESC\"),\n \"EVNTDESC\",\n fixed = TRUE\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:52:51.7977 pid:7488 token:[] teal.modules.clinical Initializing tm_t_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Selecting Sections to Display\nTable Modifying Analysis Details like Conf. Type, Ties, Alpha Level\nTable with Stratified Analysis\nTable Modifying Time Point for the “XX Months” Analysis\nTable Requesting > 1 p-value\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure that character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\nadtte_f <- adtte %>%\n dplyr::filter(PARAMCD == \"OS\") %>%\n dplyr::mutate(\n AVAL = day2month(AVAL),\n is_event = CNSR == 0,\n is_not_event = CNSR == 1,\n EVNT1 = factor(\n case_when(\n is_event == TRUE ~ \"Patients with event (%)\",\n is_event == FALSE ~ \"Patients without event (%)\"\n ),\n levels = c(\"Patients with event (%)\", \"Patients without event (%)\")\n ),\n EVNTDESC = factor(EVNTDESC)\n )\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\n var = \"ARM\", ref_group = \"A: Drug X\"\n ) %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n time_point = c(6, 12),\n is_event = \"is_event\",\n method = \"both\",\n control = control_surv_timepoint()\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n6 Months \n Patients remaining at risk 97 97 90 \n Event Free Rate (%) 72.39 72.39 68.18 \n 95% CI (64.82, 79.96) (64.82, 79.96) (60.24, 76.13)\n Difference in Event Free Rate 0.00 -4.21 \n 95% CI (-10.71, 10.71) (-15.18, 6.77)\n p-value (Z-test) 1.0000 0.4525 \n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 95% CI (48.33, 65.11) (48.33, 65.11) (39.21, 56.25)\n Difference in Event Free Rate 0.00 -8.99 \n 95% CI (-11.86, 11.86) (-20.95, 2.97)\n p-value (Z-test) 1.0000 0.1406 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n analyze_vars(\n \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n method = \"surv\",\n time_point = c(6, 12)\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl)\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n6 Months \n Patients remaining at risk 97 97 90 \n Event Free Rate (%) 72.39 72.39 68.18 \n 95% CI (64.82, 79.96) (64.82, 79.96) (60.24, 76.13)\n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 95% CI (48.33, 65.11) (48.33, 65.11) (39.21, 56.25)\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n control = control_surv_time(conf_level = 0.9, conf_type = \"log-log\"),\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(\n pval_method = \"log-rank\",\n conf_level = 0.95,\n ties = \"efron\"\n ),\n table_names = \"coxph_unstratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n time_point = 12,\n control = control_surv_timepoint(conf_level = 0.9, conf_type = \"log-log\"),\n table_names_suffix = \"_log_log\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n show_labels = \"hidden\",\n is_event = \"is_event\",\n time_point = 12,\n method = \"surv_diff\",\n control = control_surv_timepoint(conf_level = 0.975),\n table_names_suffix = \"_975_pct\"\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n—————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 90% CI (9.6, NA) (9.6, NA) (7.7, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 90% CI (49.37, 63.41) (49.37, 63.41) (40.42, 54.66)\nDifference in Event Free Rate 0.00 -8.99 \n 97.5% CI (-13.57, 13.57) (-22.66, 4.69)\n p-value (Z-test) 1.0000 0.1406 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Unstratified Analysis\",\n table_names = \"coxph_unstratified\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = \"Stratified Analysis\",\n strat = \"SEX\",\n table_names = \"coxph_stratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n method = \"both\",\n time_point = 12\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \nStratified Analysis \n p-value (log-rank) 0.9978 0.1733 \n Hazard Ratio 1.00 1.27 \n 95% CI (0.69, 1.44) (0.90, 1.81) \n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 95% CI (48.33, 65.11) (48.33, 65.11) (39.21, 56.25)\n Difference in Event Free Rate 0.00 -8.99 \n 95% CI (-11.86, 11.86) (-20.95, 2.97)\n p-value (Z-test) 1.0000 0.1406 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n table_names = \"coxph_unstratified\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n time_point = 6,\n method = \"both\"\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n6 Months \n Patients remaining at risk 97 97 90 \n Event Free Rate (%) 72.39 72.39 68.18 \n 95% CI (64.82, 79.96) (64.82, 79.96) (60.24, 76.13)\n Difference in Event Free Rate 0.00 -4.21 \n 95% CI (-10.71, 10.71) (-15.18, 6.77)\n p-value (Z-test) 1.0000 0.4525 \n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARM\", ref_group = \"A: Drug X\") %>%\n analyze_vars(\n vars = \"is_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients with event (%)\")\n ) %>%\n split_rows_by(\n \"EVNT1\",\n split_label = \"Earliest contributing event\",\n split_fun = keep_split_levels(\"Patients with event (%)\"),\n label_pos = \"visible\",\n child_labels = \"hidden\",\n indent_mod = 1L,\n ) %>%\n analyze(\"EVNTDESC\") %>%\n analyze_vars(\n vars = \"is_not_event\",\n .stats = \"count_fraction\",\n .labels = c(count_fraction = \"Patients without event (%)\"),\n nested = FALSE,\n show_labels = \"hidden\"\n ) %>%\n surv_time(\n vars = \"AVAL\",\n var_labels = \"Time to Event (Months)\",\n is_event = \"is_event\",\n table_names = \"time_to_event\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n var_labels = c(\"Unstratified Analysis\"),\n control = control_coxph(pval_method = \"log-rank\"),\n .stats = \"pvalue\",\n table_names = \"coxph_unstratified\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n show_labels = \"hidden\",\n control = control_coxph(pval_method = \"wald\"),\n .stats = \"pvalue\",\n .indent_mods = c(pvalue = 1L),\n table_names = \"coxph_wald_pvalue\"\n ) %>%\n coxph_pairwise(\n vars = \"AVAL\",\n is_event = \"is_event\",\n show_labels = \"hidden\",\n control = control_coxph(pval_method = \"likelihood\"),\n .indent_mods = c(pvalue = 1L, hr = 2L, hr_ci = 3L),\n table_names = \"coxph_likelihood_pvalue\"\n ) %>%\n surv_timepoint(\n vars = \"AVAL\",\n var_labels = \"Months\",\n is_event = \"is_event\",\n time_point = 12,\n method = \"both\"\n )\n\nresult <- build_table(lyt, df = adtte_f, alt_counts_df = adsl) %>%\n prune_table()\n\nresult\n\n A: Drug X B: Placebo C: Combination\n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————\nPatients with event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) \n Earliest contributing event \n Death 58 58 69 \nPatients without event (%) 76 (56.7%) 76 (56.7%) 63 (47.7%) \nTime to Event (Months) \n Median NA NA 9.4 \n 95% CI (9.3, NA) (9.4, NA) (7.6, NA) \n 25% and 75%-ile 5.6, NA 5.6, NA 5.0, NA \n Range (censored) 9.9 to 16.4 9.9 to 16.3 9.9 to 16.3 \n Range (event) 0.5 to 9.6 0.9 to 9.6 0.5 to 9.8 \nUnstratified Analysis \n p-value (log-rank) 0.9998 0.1541 \n p-value (wald) 0.9998 0.1552 \n p-value (likelihood) 0.9998 0.1543 \n Hazard Ratio 1.00 1.29 \n 95% CI (0.69, 1.44) (0.91, 1.83) \n12 Months \n Patients remaining at risk 49 48 37 \n Event Free Rate (%) 56.72 56.72 47.73 \n 95% CI (48.33, 65.11) (48.33, 65.11) (39.21, 56.25)\n Difference in Event Free Rate 0.00 -8.99 \n 95% CI (-11.86, 11.86) (-20.95, 2.97)\n p-value (Z-test) 1.0000 0.1406 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% df_explicit_na()'),\n cdisc_dataset(\"ADTTE\", adtte, code = 'ADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\") %>% df_explicit_na()'),\n check = TRUE\n ),\n modules = modules(\n tm_t_tte(\n label = \"Time To Event Table\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(\n variable_choices(adsl, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adtte, \"PARAMCD\", \"PARAM\"),\n \"OS\"\n ),\n strata_var = choices_selected(\n variable_choices(adsl, c(\"SEX\", \"BMRKR2\")),\n \"SEX\"\n ),\n time_points = choices_selected(c(6, 8), 6),\n event_desc_var = choices_selected(\n variable_choices(adtte, \"EVNTDESC\"),\n \"EVNTDESC\",\n fixed = TRUE\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:15:16.4773 pid:7493 token:[] teal.modules.clinical Initializing tm_t_tte\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/efficacy/coxt01.html",
"href": "tables/efficacy/coxt01.html",
"title": "COXT01",
"section": "",
- "text": "Cox models are the most commonly used methods to estimate the magnitude of the effect in survival analyses. It assumes proportional hazards; that is, it assumes that the ratio of the hazards of the two groups (e.g. two arms) is constant over time. This ratio is referred to as the “hazard ratio” and is one of the most commonly reported metrics to describe the effect size in survival analysis.\n\n\nData Setup\nCox Regression\nCox Regression with Interaction Term\nCox Regression Specifying Covariates\nCox Regression Setting Strata, Ties, Alpha Level\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\nadsl_filtered <- adsl %>% dplyr::filter(\n RACE %in% c(\"ASIAN\", \"BLACK OR AFRICAN AMERICAN\", \"WHITE\")\n)\nadtte_filtered <- dplyr::inner_join(\n x = adsl_filtered[, c(\"STUDYID\", \"USUBJID\")],\n y = adtte,\n by = c(\"STUDYID\", \"USUBJID\")\n)\n\nanl <- adtte_filtered %>%\n filter(PARAMCD == \"OS\") %>%\n mutate(EVENT = 1 - CNSR) %>%\n filter(ARM %in% c(\"B: Placebo\", \"A: Drug X\")) %>%\n mutate(ARM = droplevels(relevel(ARM, \"B: Placebo\"))) %>%\n mutate(RACE = droplevels(RACE) %>% formatters::with_label(\"Race\"))\n\n# Add variable for column split label\nanl <- anl %>% mutate(col_label = \"Treatment Effect Adjusted for Covariate\")\n\n\n\n\nThe summarize_coxreg function fits, tidies and arranges a Cox regression model in a table layout using the rtables framework. For a Cox regression model, arguments variables, control, and at can be specified (see ?summarize_coxreg for more details and customization options). All variables specified within variables must be present in the data used when building the table.\nTo see the same model as a data.frame object, these three arguments (as well as the data) can be passed to the fit_coxreg_univar function, and the resulting list tidied using broom::tidy().\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"AGE\", \"SEX\", \"RACE\")\n)\n\nlyt <- basic_table() %>%\n split_cols_by(\"col_label\") %>%\n summarize_coxreg(variables = variables) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Treatment Effect Adjusted for Covariate \n n Hazard Ratio 95% CI p-value \n—————————————————————————————————————————————————————————————————————————————————————————\nTreatment: \n A: Drug X vs control (B: Placebo) 247 0.97 (0.66, 1.43) 0.8934 \nCovariate: \n Age 247 0.95 (0.65, 1.40) 0.7948 \n Sex 247 0.98 (0.67, 1.43) 0.8970 \n Race 247 0.98 (0.67, 1.44) 0.9239 \n\n\n\n\nThe argument control can be used to modify standard outputs; control_coxreg() helps in adopting the right settings (see ?control_coxreg). For instance, control is used to include the interaction terms.\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"AGE\", \"RACE\")\n)\n\nlyt <- basic_table() %>%\n split_cols_by(\"col_label\") %>%\n summarize_coxreg(\n variables = variables,\n control = control_coxreg(interaction = TRUE),\n .stats = c(\"n\", \"hr\", \"ci\", \"pval\", \"pval_inter\")\n ) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Treatment Effect Adjusted for Covariate \n n Hazard Ratio 95% CI p-value Interaction p-value\n——————————————————————————————————————————————————————————————————————————————————————————————————————————\nTreatment: \n A: Drug X vs control (B: Placebo) 247 0.97 (0.66, 1.43) 0.8934 \nCovariate: \n Age 247 0.7878 \n 34 0.95 (0.65, 1.40) \n Race 247 0.6850 \n ASIAN 1.05 (0.63, 1.75) \n BLACK OR AFRICAN AMERICAN 1.08 (0.51, 2.29) \n WHITE 0.67 (0.27, 1.71) \n\n\n\n\nThe optional argument at allows the user to provide the expected level of estimation for the interaction when the predictor is a quantitative variable. For instance, it might be relevant to choose the age at which the hazard ratio should be estimated. If no input is provided to at, the median value is used in the row name (as in the previous tab).\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"AGE\", \"SEX\")\n)\n\nlyt <- basic_table() %>%\n split_cols_by(\"col_label\") %>%\n summarize_coxreg(\n variables = variables,\n control = control_coxreg(interaction = TRUE),\n at = list(AGE = c(30, 40, 50)),\n .stats = c(\"n\", \"hr\", \"ci\", \"pval\", \"pval_inter\")\n ) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Treatment Effect Adjusted for Covariate \n n Hazard Ratio 95% CI p-value Interaction p-value\n——————————————————————————————————————————————————————————————————————————————————————————————————————————\nTreatment: \n A: Drug X vs control (B: Placebo) 247 0.97 (0.66, 1.43) 0.8934 \nCovariate: \n Age 247 0.7878 \n 30 0.98 (0.63, 1.51) \n 40 0.91 (0.54, 1.51) \n 50 0.84 (0.32, 2.20) \n Sex 247 0.1455 \n F 0.77 (0.47, 1.27) \n M 1.38 (0.75, 2.52) \n\n\n\n\nAdditional controls can be customized using control_coxreg (see ?control_coxreg) such as the ties calculation method and the confidence level. Stratification variables can be added via the strata element of the variables list.\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"AGE\", \"RACE\"),\n strata = \"SEX\"\n)\n\ncontrol <- control_coxreg(\n ties = \"breslow\",\n interaction = TRUE,\n conf_level = 0.90\n)\n\nlyt <- basic_table() %>%\n split_cols_by(\"col_label\") %>%\n summarize_coxreg(\n variables = variables,\n control = control,\n at = list(AGE = c(30, 40, 50)),\n .stats = c(\"n\", \"hr\", \"ci\", \"pval\", \"pval_inter\")\n ) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Treatment Effect Adjusted for Covariate \n n Hazard Ratio 90% CI p-value Interaction p-value\n——————————————————————————————————————————————————————————————————————————————————————————————————————————\nTreatment: \n A: Drug X vs control (B: Placebo) 247 0.98 (0.71, 1.35) 0.9063 \nCovariate: \n Age 247 0.7733 \n 30 0.98 (0.68, 1.42) \n 40 0.91 (0.59, 1.39) \n 50 0.84 (0.38, 1.87) \n Race 247 0.6501 \n ASIAN 1.07 (0.64, 1.77) \n BLACK OR AFRICAN AMERICAN 1.08 (0.51, 2.29) \n WHITE 0.66 (0.26, 1.67) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'adsl <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADTTE\", adtte, code = 'adtte <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adtte\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_coxreg(\n label = \"Cox Reg.\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\", \"ACTARMCD\"), \"ARM\"),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adtte, \"PARAMCD\", \"PARAM\"), \"OS\"\n ),\n strata_var = choices_selected(\n c(\"SEX\", \"STRATA1\", \"STRATA2\"), NULL\n ),\n cov_var = choices_selected(\n c(\"AGE\", \"SEX\", \"RACE\"), \"AGE\"\n ),\n multivariate = FALSE\n )\n )\n)\n\n[INFO] 2023-09-08 19:54:13.3144 pid:7689 token:[] teal.modules.clinical Initializing tm_t_coxreg\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] abind_1.4-5 multcomp_1.4-25 withr_2.5.0 \n[25] purrr_1.0.2 shinyWidgets_0.7.6 geepack_1.3.9 \n[28] grid_4.3.1 fansi_1.0.4 teal.logger_0.1.3.9000 \n[31] xtable_1.8-4 colorspace_2.1-0 ggplot2_3.4.3 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] stringr_1.5.0 splines_4.3.1 assertthat_0.2.1 \n[46] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[49] sandwich_3.0-2 jsonlite_1.8.7 carData_3.0-5 \n[52] callr_3.7.3 car_3.1-2 teal.widgets_0.4.0.9007\n[55] testthat_3.1.10 fontawesome_0.5.1 jquerylib_0.1.4 \n[58] tidyr_1.3.0 glue_1.6.2 ps_1.7.5 \n[61] codetools_0.2-19 stringi_1.7.12 gtable_0.3.3 \n[64] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[67] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[70] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[73] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[76] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[79] broom_1.0.5 teal.reporter_0.2.1 bslib_0.5.1 \n[82] httpuv_1.6.11 Rcpp_1.0.11 coda_0.19-4 \n[85] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[88] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Cox models are the most commonly used methods to estimate the magnitude of the effect in survival analyses. It assumes proportional hazards; that is, it assumes that the ratio of the hazards of the two groups (e.g. two arms) is constant over time. This ratio is referred to as the “hazard ratio” and is one of the most commonly reported metrics to describe the effect size in survival analysis.\n\n\nData Setup\nCox Regression\nCox Regression with Interaction Term\nCox Regression Specifying Covariates\nCox Regression Setting Strata, Ties, Alpha Level\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(tern)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\nadsl_filtered <- adsl %>% dplyr::filter(\n RACE %in% c(\"ASIAN\", \"BLACK OR AFRICAN AMERICAN\", \"WHITE\")\n)\nadtte_filtered <- dplyr::inner_join(\n x = adsl_filtered[, c(\"STUDYID\", \"USUBJID\")],\n y = adtte,\n by = c(\"STUDYID\", \"USUBJID\")\n)\n\nanl <- adtte_filtered %>%\n filter(PARAMCD == \"OS\") %>%\n mutate(EVENT = 1 - CNSR) %>%\n filter(ARM %in% c(\"B: Placebo\", \"A: Drug X\")) %>%\n mutate(ARM = droplevels(relevel(ARM, \"B: Placebo\"))) %>%\n mutate(RACE = droplevels(RACE) %>% formatters::with_label(\"Race\"))\n\n# Add variable for column split label\nanl <- anl %>% mutate(col_label = \"Treatment Effect Adjusted for Covariate\")\n\n\n\n\nThe summarize_coxreg function fits, tidies and arranges a Cox regression model in a table layout using the rtables framework. For a Cox regression model, arguments variables, control, and at can be specified (see ?summarize_coxreg for more details and customization options). All variables specified within variables must be present in the data used when building the table.\nTo see the same model as a data.frame object, these three arguments (as well as the data) can be passed to the fit_coxreg_univar function, and the resulting list tidied using broom::tidy().\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"AGE\", \"SEX\", \"RACE\")\n)\n\nlyt <- basic_table() %>%\n split_cols_by(\"col_label\") %>%\n summarize_coxreg(variables = variables) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Treatment Effect Adjusted for Covariate \n n Hazard Ratio 95% CI p-value \n—————————————————————————————————————————————————————————————————————————————————————————\nTreatment: \n A: Drug X vs control (B: Placebo) 247 0.97 (0.66, 1.43) 0.8934 \nCovariate: \n Age 247 0.95 (0.65, 1.40) 0.7948 \n Sex 247 0.98 (0.67, 1.43) 0.8970 \n Race 247 0.98 (0.67, 1.44) 0.9239 \n\n\n\n\nThe argument control can be used to modify standard outputs; control_coxreg() helps in adopting the right settings (see ?control_coxreg). For instance, control is used to include the interaction terms.\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"AGE\", \"RACE\")\n)\n\nlyt <- basic_table() %>%\n split_cols_by(\"col_label\") %>%\n summarize_coxreg(\n variables = variables,\n control = control_coxreg(interaction = TRUE),\n .stats = c(\"n\", \"hr\", \"ci\", \"pval\", \"pval_inter\")\n ) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Treatment Effect Adjusted for Covariate \n n Hazard Ratio 95% CI p-value Interaction p-value\n——————————————————————————————————————————————————————————————————————————————————————————————————————————\nTreatment: \n A: Drug X vs control (B: Placebo) 247 0.97 (0.66, 1.43) 0.8934 \nCovariate: \n Age 247 0.7878 \n 34 0.95 (0.65, 1.40) \n Race 247 0.6850 \n ASIAN 1.05 (0.63, 1.75) \n BLACK OR AFRICAN AMERICAN 1.08 (0.51, 2.29) \n WHITE 0.67 (0.27, 1.71) \n\n\n\n\nThe optional argument at allows the user to provide the expected level of estimation for the interaction when the predictor is a quantitative variable. For instance, it might be relevant to choose the age at which the hazard ratio should be estimated. If no input is provided to at, the median value is used in the row name (as in the previous tab).\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"AGE\", \"SEX\")\n)\n\nlyt <- basic_table() %>%\n split_cols_by(\"col_label\") %>%\n summarize_coxreg(\n variables = variables,\n control = control_coxreg(interaction = TRUE),\n at = list(AGE = c(30, 40, 50)),\n .stats = c(\"n\", \"hr\", \"ci\", \"pval\", \"pval_inter\")\n ) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Treatment Effect Adjusted for Covariate \n n Hazard Ratio 95% CI p-value Interaction p-value\n——————————————————————————————————————————————————————————————————————————————————————————————————————————\nTreatment: \n A: Drug X vs control (B: Placebo) 247 0.97 (0.66, 1.43) 0.8934 \nCovariate: \n Age 247 0.7878 \n 30 0.98 (0.63, 1.51) \n 40 0.91 (0.54, 1.51) \n 50 0.84 (0.32, 2.20) \n Sex 247 0.1455 \n F 0.77 (0.47, 1.27) \n M 1.38 (0.75, 2.52) \n\n\n\n\nAdditional controls can be customized using control_coxreg (see ?control_coxreg) such as the ties calculation method and the confidence level. Stratification variables can be added via the strata element of the variables list.\n\nCodevariables <- list(\n time = \"AVAL\",\n event = \"EVENT\",\n arm = \"ARM\",\n covariates = c(\"AGE\", \"RACE\"),\n strata = \"SEX\"\n)\n\ncontrol <- control_coxreg(\n ties = \"breslow\",\n interaction = TRUE,\n conf_level = 0.90\n)\n\nlyt <- basic_table() %>%\n split_cols_by(\"col_label\") %>%\n summarize_coxreg(\n variables = variables,\n control = control,\n at = list(AGE = c(30, 40, 50)),\n .stats = c(\"n\", \"hr\", \"ci\", \"pval\", \"pval_inter\")\n ) %>%\n append_topleft(\"Effect/Covariate Included in the Model\")\n\nresult <- build_table(lyt = lyt, df = anl)\nresult\n\nEffect/Covariate Included in the Model Treatment Effect Adjusted for Covariate \n n Hazard Ratio 90% CI p-value Interaction p-value\n——————————————————————————————————————————————————————————————————————————————————————————————————————————\nTreatment: \n A: Drug X vs control (B: Placebo) 247 0.98 (0.71, 1.35) 0.9063 \nCovariate: \n Age 247 0.7733 \n 30 0.98 (0.68, 1.42) \n 40 0.91 (0.59, 1.39) \n 50 0.84 (0.38, 1.87) \n Race 247 0.6501 \n ASIAN 1.07 (0.64, 1.77) \n BLACK OR AFRICAN AMERICAN 1.08 (0.51, 2.29) \n WHITE 0.66 (0.26, 1.67) \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadtte <- df_explicit_na(adtte)\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'adsl <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADTTE\", adtte, code = 'adtte <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adtte\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_t_coxreg(\n label = \"Cox Reg.\",\n dataname = \"ADTTE\",\n arm_var = choices_selected(c(\"ARM\", \"ARMCD\", \"ACTARMCD\"), \"ARM\"),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adtte, \"PARAMCD\", \"PARAM\"), \"OS\"\n ),\n strata_var = choices_selected(\n c(\"SEX\", \"STRATA1\", \"STRATA2\"), NULL\n ),\n cov_var = choices_selected(\n c(\"AGE\", \"SEX\", \"RACE\"), \"AGE\"\n ),\n multivariate = FALSE\n )\n )\n)\n\n[INFO] 2023-09-09 18:16:55.7362 pid:7695 token:[] teal.modules.clinical Initializing tm_t_coxreg\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] tern_0.9.0.9002 rtables_0.6.3.9000 \n [9] magrittr_2.0.3 formatters_0.5.2.9001 \n[11] dplyr_1.1.2 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] abind_1.4-5 multcomp_1.4-25 withr_2.5.0 \n[25] purrr_1.0.2 shinyWidgets_0.7.6 geepack_1.3.9 \n[28] grid_4.3.1 fansi_1.0.4 teal.logger_0.1.3.9001 \n[31] xtable_1.8-4 colorspace_2.1-0 ggplot2_3.4.3 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] stringr_1.5.0 splines_4.3.1 assertthat_0.2.1 \n[46] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[49] sandwich_3.0-2 jsonlite_1.8.7 carData_3.0-5 \n[52] callr_3.7.3 car_3.1-2 teal.widgets_0.4.0.9007\n[55] testthat_3.1.10 fontawesome_0.5.1 jquerylib_0.1.4 \n[58] tidyr_1.3.0 glue_1.6.2 ps_1.7.5 \n[61] codetools_0.2-19 stringi_1.7.12 gtable_0.3.3 \n[64] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[67] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[70] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[73] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[76] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[79] broom_1.0.5 teal.reporter_0.2.1 bslib_0.5.1 \n[82] httpuv_1.6.11 Rcpp_1.0.11 coda_0.19-4 \n[85] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[88] zoo_1.8-12 forcats_1.0.0 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/efficacy/onct05.html",
"href": "tables/efficacy/onct05.html",
"title": "ONCT05",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Specifying Class Variables\nTable Selecting Columns and Changing the Alpha Level\nTable Setting Values Indicating Response\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadrs <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadrs <- df_explicit_na(adrs)\n\nadsl <- adsl %>%\n select(STUDYID, USUBJID, ARM, SEX, RACE, STRATA1, STRATA2)\n\nadrs <- adrs %>%\n filter(PARAMCD == \"INVET\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVALC)\n\nanl <- inner_join(adsl, adrs, by = c(\"STUDYID\", \"USUBJID\"))\nanl_labels <- var_labels(anl)\n\nanl <- anl %>%\n filter(ARM %in% c(\"A: Drug X\", \"B: Placebo\")) %>%\n mutate(\n # Reorder levels of factor to make the placebo group the reference arm.\n ARM = relevel(ARM, ref = \"B: Placebo\") %>%\n droplevels()\n ) %>%\n droplevels() %>%\n mutate(rsp = AVALC %in% c(\"CR\", \"PR\"))\n\nvar_labels(anl) <- c(anl_labels, rsp = \"Is Response\")\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"STRATA2\")\n ),\n data = anl\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 84 62.7% 134 100 74.6% 1.75 (1.04, 2.95)\nSex \n F 161 82 48 58.5% 79 61 77.2% 2.40 (1.21, 4.76)\n M 107 52 36 69.2% 55 39 70.9% 1.08 (0.47, 2.48)\nStratification Factor 2 \n S1 140 67 38 56.7% 73 56 76.7% 2.51 (1.22, 5.20)\n S2 128 67 46 68.7% 61 44 72.1% 1.18 (0.55, 2.53)\n\n\n\n\nHere, the levels of subgroup variables SEX and STRATA1 are reordered. STRATA1 is reordered by frequency.\n\nCodeanl_reorder <- anl %>%\n mutate(\n SEX = forcats::fct_relevel(SEX, \"M\", \"F\"),\n STRATA1 = forcats::fct_infreq(STRATA1)\n )\n\ndf <- extract_rsp_subgroups(\n variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"STRATA1\")),\n data = anl_reorder\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 84 62.7% 134 100 74.6% 1.75 (1.04, 2.95)\nSex \n M 107 52 36 69.2% 55 39 70.9% 1.08 (0.47, 2.48)\n F 161 82 48 58.5% 79 61 77.2% 2.40 (1.21, 4.76)\nStratification Factor 1 \n C 94 45 33 73.3% 49 37 75.5% 1.12 (0.44, 2.83)\n B 92 45 26 57.8% 47 32 68.1% 1.56 (0.66, 3.66)\n A 82 44 25 56.8% 38 31 81.6% 3.37 (1.22, 9.28)\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"STRATA2\")\n ),\n data = anl,\n conf_level = 0.9,\n method = \"chisq\"\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\", \"pval\"))\n\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Responders Response (%) n Responders Response (%) Odds Ratio 90% CI p-value (Chi-Squared Test)\n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 84 62.7% 134 100 74.6% 1.75 (1.13, 2.72) 0.0351 \nSex \n F 161 82 48 58.5% 79 61 77.2% 2.40 (1.35, 4.27) 0.0113 \n M 107 52 36 69.2% 55 39 70.9% 1.08 (0.54, 2.17) 0.8497 \nStratification Factor 2 \n S1 140 67 38 56.7% 73 56 76.7% 2.51 (1.37, 4.63) 0.0119 \n S2 128 67 46 68.7% 61 44 72.1% 1.18 (0.62, 2.24) 0.6674 \n\n\n\n\nCreate a new variable new_rsp in anl data that uses new criteria for responder.\n\nCodeanl_new <- anl %>%\n mutate(new_rsp = AVALC == \"CR\")\n\ndf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"new_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"STRATA2\")\n ),\n data = anl_new\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 47 35.1% 134 60 44.8% 1.50 (0.92, 2.45)\nSex \n F 161 82 25 30.5% 79 39 49.4% 2.22 (1.17, 4.24)\n M 107 52 22 42.3% 55 21 38.2% 0.84 (0.39, 1.83)\nStratification Factor 2 \n S1 140 67 21 31.3% 73 31 42.5% 1.62 (0.81, 3.24)\n S2 128 67 26 38.8% 61 29 47.5% 1.43 (0.71, 2.89)\n\n\n\n\n\nCode# Use table, embedded in response forest plot module.\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\nlibrary(forcats)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadrs <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadrs <- df_explicit_na(adrs)\n\narm_ref_comp <- list(\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n ),\n ARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADRS\", adrs, code = 'ADRS <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adrs\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_g_forest_rsp(\n label = \"Forest Response\",\n dataname = \"ADRS\",\n arm_var = choices_selected(\n variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n \"ARMCD\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adrs, \"PARAMCD\", \"PARAM\"),\n \"BESRSPI\"\n ),\n subgroup_var = choices_selected(\n variable_choices(adsl, names(adsl)),\n c(\"SEX\")\n ),\n strata_var = choices_selected(\n variable_choices(adsl, c(\"STRATA1\", \"STRATA2\")),\n \"STRATA2\"\n ),\n plot_height = c(600L, 200L, 2000L)\n )\n )\n)\n\n[INFO] 2023-09-08 19:55:29.0842 pid:7886 token:[] teal.modules.clinical Initializing tm_g_forest_rsp\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] forcats_1.0.0 teal.modules.clinical_0.8.16.9003\n [3] teal_0.14.0.9005 teal.transform_0.4.0.9003 \n [5] teal.slice_0.4.0.9011 teal.data_0.3.0.9003 \n [7] shiny_1.7.5 scda_0.1.6.9012 \n [9] dplyr_1.1.2 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Specifying Class Variables\nTable Selecting Columns and Changing the Alpha Level\nTable Setting Values Indicating Response\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(dplyr)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadrs <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadrs <- df_explicit_na(adrs)\n\nadsl <- adsl %>%\n select(STUDYID, USUBJID, ARM, SEX, RACE, STRATA1, STRATA2)\n\nadrs <- adrs %>%\n filter(PARAMCD == \"INVET\") %>%\n select(STUDYID, USUBJID, PARAMCD, AVALC)\n\nanl <- inner_join(adsl, adrs, by = c(\"STUDYID\", \"USUBJID\"))\nanl_labels <- var_labels(anl)\n\nanl <- anl %>%\n filter(ARM %in% c(\"A: Drug X\", \"B: Placebo\")) %>%\n mutate(\n # Reorder levels of factor to make the placebo group the reference arm.\n ARM = relevel(ARM, ref = \"B: Placebo\") %>%\n droplevels()\n ) %>%\n droplevels() %>%\n mutate(rsp = AVALC %in% c(\"CR\", \"PR\"))\n\nvar_labels(anl) <- c(anl_labels, rsp = \"Is Response\")\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"STRATA2\")\n ),\n data = anl\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 84 62.7% 134 100 74.6% 1.75 (1.04, 2.95)\nSex \n F 161 82 48 58.5% 79 61 77.2% 2.40 (1.21, 4.76)\n M 107 52 36 69.2% 55 39 70.9% 1.08 (0.47, 2.48)\nStratification Factor 2 \n S1 140 67 38 56.7% 73 56 76.7% 2.51 (1.22, 5.20)\n S2 128 67 46 68.7% 61 44 72.1% 1.18 (0.55, 2.53)\n\n\n\n\nHere, the levels of subgroup variables SEX and STRATA1 are reordered. STRATA1 is reordered by frequency.\n\nCodeanl_reorder <- anl %>%\n mutate(\n SEX = forcats::fct_relevel(SEX, \"M\", \"F\"),\n STRATA1 = forcats::fct_infreq(STRATA1)\n )\n\ndf <- extract_rsp_subgroups(\n variables = list(rsp = \"rsp\", arm = \"ARM\", subgroups = c(\"SEX\", \"STRATA1\")),\n data = anl_reorder\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 84 62.7% 134 100 74.6% 1.75 (1.04, 2.95)\nSex \n M 107 52 36 69.2% 55 39 70.9% 1.08 (0.47, 2.48)\n F 161 82 48 58.5% 79 61 77.2% 2.40 (1.21, 4.76)\nStratification Factor 1 \n C 94 45 33 73.3% 49 37 75.5% 1.12 (0.44, 2.83)\n B 92 45 26 57.8% 47 32 68.1% 1.56 (0.66, 3.66)\n A 82 44 25 56.8% 38 31 81.6% 3.37 (1.22, 9.28)\n\n\n\n\n\nCodedf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"STRATA2\")\n ),\n data = anl,\n conf_level = 0.9,\n method = \"chisq\"\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\", \"pval\"))\n\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Responders Response (%) n Responders Response (%) Odds Ratio 90% CI p-value (Chi-Squared Test)\n——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 84 62.7% 134 100 74.6% 1.75 (1.13, 2.72) 0.0351 \nSex \n F 161 82 48 58.5% 79 61 77.2% 2.40 (1.35, 4.27) 0.0113 \n M 107 52 36 69.2% 55 39 70.9% 1.08 (0.54, 2.17) 0.8497 \nStratification Factor 2 \n S1 140 67 38 56.7% 73 56 76.7% 2.51 (1.37, 4.63) 0.0119 \n S2 128 67 46 68.7% 61 44 72.1% 1.18 (0.62, 2.24) 0.6674 \n\n\n\n\nCreate a new variable new_rsp in anl data that uses new criteria for responder.\n\nCodeanl_new <- anl %>%\n mutate(new_rsp = AVALC == \"CR\")\n\ndf <- extract_rsp_subgroups(\n variables = list(\n rsp = \"new_rsp\",\n arm = \"ARM\",\n subgroups = c(\"SEX\", \"STRATA2\")\n ),\n data = anl_new\n)\n\nresult <- basic_table() %>%\n tabulate_rsp_subgroups(df, vars = c(\"n_tot\", \"n\", \"n_rsp\", \"prop\", \"or\", \"ci\"))\n\nresult\n\nBaseline Risk Factors B: Placebo A: Drug X \n Total n n Responders Response (%) n Responders Response (%) Odds Ratio 95% CI \n—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nAll Patients 268 134 47 35.1% 134 60 44.8% 1.50 (0.92, 2.45)\nSex \n F 161 82 25 30.5% 79 39 49.4% 2.22 (1.17, 4.24)\n M 107 52 22 42.3% 55 21 38.2% 0.84 (0.39, 1.83)\nStratification Factor 2 \n S1 140 67 21 31.3% 73 31 42.5% 1.62 (0.81, 3.24)\n S2 128 67 26 38.8% 61 29 47.5% 1.43 (0.71, 2.89)\n\n\n\n\n\nCode# Use table, embedded in response forest plot module.\nlibrary(teal.modules.clinical)\nlibrary(dplyr)\nlibrary(forcats)\nlibrary(scda)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadrs <- synthetic_cdisc_dataset(\"latest\", \"adrs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadrs <- df_explicit_na(adrs)\n\narm_ref_comp <- list(\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n ),\n ARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))'),\n cdisc_dataset(\"ADRS\", adrs, code = 'ADRS <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adrs\"))'),\n check = TRUE\n ),\n modules = modules(\n tm_g_forest_rsp(\n label = \"Forest Response\",\n dataname = \"ADRS\",\n arm_var = choices_selected(\n variable_choices(adsl, c(\"ARM\", \"ARMCD\")),\n \"ARMCD\"\n ),\n arm_ref_comp = arm_ref_comp,\n paramcd = choices_selected(\n value_choices(adrs, \"PARAMCD\", \"PARAM\"),\n \"BESRSPI\"\n ),\n subgroup_var = choices_selected(\n variable_choices(adsl, names(adsl)),\n c(\"SEX\")\n ),\n strata_var = choices_selected(\n variable_choices(adsl, c(\"STRATA1\", \"STRATA2\")),\n \"STRATA2\"\n ),\n plot_height = c(600L, 200L, 2000L)\n )\n )\n)\n\n[INFO] 2023-09-09 18:18:26.6205 pid:7892 token:[] teal.modules.clinical Initializing tm_g_forest_rsp\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] forcats_1.0.0 teal.modules.clinical_0.8.16.9003\n [3] teal_0.14.0.9005 teal.transform_0.4.0.9003 \n [5] teal.slice_0.4.0.9012 teal.data_0.3.0.9003 \n [7] shiny_1.7.5 scda_0.1.6.9012 \n [9] dplyr_1.1.2 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/other/rmpt03.html",
"href": "tables/other/rmpt03.html",
"title": "RMPT03",
"section": "",
- "text": "Data Setup\nStandard Table\nTable Excluding Empty Age Groups\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\n# Simulate ADEX records with PARAMCD == \"TDURD\" as they are not in sample scda dataset.\nset.seed(1, kind = \"Mersenne-Twister\")\nadex2 <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE)\n ) %>%\n bind_rows(adex)\n\n# Now pre-processing steps are carried out.\nanl <- adex2 %>%\n filter(\n PARAMCD == \"TDURD\",\n PARCAT2 == \"Drug A\",\n SAFFL == \"Y\"\n ) %>%\n mutate(\n AGEGR1 = factor(ifelse(AGE < 65, \"<65\", \">=65\")),\n AGEGR2 = factor(case_when(\n AGE < 18 ~ \"< 18\",\n AGE >= 18 & AGE <= 40 ~ \"18 - 40\",\n AGE > 40 & AGE <= 64 ~ \"41 - 64\",\n TRUE ~ \">=65\"\n ), levels = c(\"< 18\", \"18 - 40\", \"41 - 64\", \">=65\")),\n SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n ))\n )\n\nadsl_f <- adsl %>%\n filter(adsl$SAFFL == \"Y\") %>%\n mutate(SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n )))\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Extent of Exposure by Age Group and Gender: Safety-Evaluable Patients\",\n main_footer = \"* Patient Time is the sum of exposure across all patients in days.\"\n) %>%\n split_cols_by(\"SEX\", split_fun = add_overall_level(\"Total\", first = FALSE)) %>%\n summarize_patients_exposure_in_cols(\n var = \"AVAL\", col_split = TRUE,\n .labels = c(n_patients = \"Number of Patients\", sum_exposure = \"Patient Time*\"),\n custom_label = \"Total Number of Patients and Patient Time\"\n ) %>%\n analyze_patients_exposure_in_cols(\n var = \"AGEGR1\",\n col_split = FALSE\n ) %>%\n append_topleft(c(\"\", \"Age group (years)\"))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f)\nresult\n\nExtent of Exposure by Age Group and Gender: Safety-Evaluable Patients\n\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\n Female Male Total \nAge group (years) Number of Patients Patient Time* Number of Patients Patient Time* Number of Patients Patient Time*\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal Number of Patients and Patient Time 134 (58.0%) 12591 83 (49.1%) 8050 217 (54.2%) 20641 \n <65 134 (58.0%) 12591 82 (48.5%) 7970 216 (54.0%) 20561 \n >=65 0 (0.0%) 0 1 (0.6%) 80 1 (0.2%) 80 \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\n\n* Patient Time is the sum of exposure across all patients in days.\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Duration of Exposure: Safety-Evaluable Patients\",\n main_footer = \"* Patient Time is the sum of exposure across all patients in days.\"\n) %>%\n split_cols_by(\"SEX\", split_fun = add_overall_level(\"Total\", first = FALSE)) %>%\n summarize_patients_exposure_in_cols(\n var = \"AVAL\", col_split = TRUE,\n .labels = c(n_patients = \"Number of Patients\", sum_exposure = \"Patient Time*\"),\n custom_label = \"Total Number of Patients and Patient Time\"\n ) %>%\n analyze_patients_exposure_in_cols(\n var = \"AGEGR2\",\n col_split = FALSE\n ) %>%\n append_topleft(c(\"\", \"Age group (years)\"))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f) %>%\n prune_table()\nresult\n\nDuration of Exposure: Safety-Evaluable Patients\n\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\n Female Male Total \nAge group (years) Number of Patients Patient Time* Number of Patients Patient Time* Number of Patients Patient Time*\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal Number of Patients and Patient Time 134 (58.0%) 12591 83 (49.1%) 8050 217 (54.2%) 20641 \n 18 - 40 118 (51.1%) 11203 60 (35.5%) 5787 178 (44.5%) 16990 \n 41 - 64 16 (6.9%) 1388 22 (13.0%) 2183 38 (9.5%) 3571 \n >=65 0 (0.0%) 0 1 (0.6%) 80 1 (0.2%) 80 \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\n\n* Patient Time is the sum of exposure across all patients in days.\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\nset.seed(1, kind = \"Mersenne-Twister\")\n\nlabels <- var_labels(adex)\nadex <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\"\n ) %>%\n bind_rows(adex)\n\nadex <- adex %>%\n mutate(\n AGEGR1 = factor(ifelse(AGE < 65, \"<65\", \">=65\")),\n AGEGR2 = factor(case_when(\n AGE < 18 ~ \"< 18\",\n AGE >= 18 & AGE <= 40 ~ \"18 - 40\",\n AGE > 40 & AGE <= 64 ~ \"41 - 64\",\n TRUE ~ \">=65\"\n ), levels = c(\"< 18\", \"18 - 40\", \"41 - 64\", \">=65\")),\n SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n ))\n )\n\nvar_labels(adex) <- c(labels, \"Age group (years)\", \"Age group (years)\")\n\nadsl <- adsl %>%\n mutate(SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n )))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- ADSL %>% filter(ADSL$SAFFL == \"Y\") %>%\n mutate(SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n )))'),\n cdisc_dataset(\"ADEX\", adex, code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n set.seed(1, kind = \"Mersenne-Twister\")\n labels <- var_labels(ADEX)\n ADEX <- ADEX %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\") %>%\n bind_rows(ADEX)\n\n ADEX <- ADEX %>%\n mutate(\n AGEGR1 = factor(ifelse(AGE < 65, \"<65\", \">=65\")),\n AGEGR2 = factor(case_when(\n AGE < 18 ~ \"< 18\",\n AGE >= 18 & AGE <= 40 ~ \"18 - 40\",\n AGE > 40 & AGE <= 64 ~ \"41 - 64\",\n TRUE ~ \">=65\"\n ), levels = c(\"< 18\", \"18 - 40\", \"41 - 64\", \">=65\")),\n SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n )))\n var_labels(ADEX) <- c(labels, \"Age group (years)\", \"Age group (years)\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_exposure(\n label = \"Duration of Exposure Table\",\n dataname = \"ADEX\",\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = \"TDURD\"\n ),\n col_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"SEX\", \"ARM\")),\n selected = \"SEX\"\n ),\n row_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"AGEGR1\", \"AGEGR2\")),\n selected = \"AGEGR1\"\n ),\n parcat = choices_selected(\n choices = value_choices(adex, \"PARCAT2\"),\n selected = \"Drug A\"\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-08 19:56:38.1881 pid:8083 token:[] teal.modules.clinical Initializing tm_t_exposure\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nTable Excluding Empty Age Groups\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\n# Simulate ADEX records with PARAMCD == \"TDURD\" as they are not in sample scda dataset.\nset.seed(1, kind = \"Mersenne-Twister\")\nadex2 <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE)\n ) %>%\n bind_rows(adex)\n\n# Now pre-processing steps are carried out.\nanl <- adex2 %>%\n filter(\n PARAMCD == \"TDURD\",\n PARCAT2 == \"Drug A\",\n SAFFL == \"Y\"\n ) %>%\n mutate(\n AGEGR1 = factor(ifelse(AGE < 65, \"<65\", \">=65\")),\n AGEGR2 = factor(case_when(\n AGE < 18 ~ \"< 18\",\n AGE >= 18 & AGE <= 40 ~ \"18 - 40\",\n AGE > 40 & AGE <= 64 ~ \"41 - 64\",\n TRUE ~ \">=65\"\n ), levels = c(\"< 18\", \"18 - 40\", \"41 - 64\", \">=65\")),\n SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n ))\n )\n\nadsl_f <- adsl %>%\n filter(adsl$SAFFL == \"Y\") %>%\n mutate(SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n )))\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Extent of Exposure by Age Group and Gender: Safety-Evaluable Patients\",\n main_footer = \"* Patient Time is the sum of exposure across all patients in days.\"\n) %>%\n split_cols_by(\"SEX\", split_fun = add_overall_level(\"Total\", first = FALSE)) %>%\n summarize_patients_exposure_in_cols(\n var = \"AVAL\", col_split = TRUE,\n .labels = c(n_patients = \"Number of Patients\", sum_exposure = \"Patient Time*\"),\n custom_label = \"Total Number of Patients and Patient Time\"\n ) %>%\n analyze_patients_exposure_in_cols(\n var = \"AGEGR1\",\n col_split = FALSE\n ) %>%\n append_topleft(c(\"\", \"Age group (years)\"))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f)\nresult\n\nExtent of Exposure by Age Group and Gender: Safety-Evaluable Patients\n\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\n Female Male Total \nAge group (years) Number of Patients Patient Time* Number of Patients Patient Time* Number of Patients Patient Time*\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal Number of Patients and Patient Time 134 (58.0%) 12591 83 (49.1%) 8050 217 (54.2%) 20641 \n <65 134 (58.0%) 12591 82 (48.5%) 7970 216 (54.0%) 20561 \n >=65 0 (0.0%) 0 1 (0.6%) 80 1 (0.2%) 80 \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\n\n* Patient Time is the sum of exposure across all patients in days.\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Duration of Exposure: Safety-Evaluable Patients\",\n main_footer = \"* Patient Time is the sum of exposure across all patients in days.\"\n) %>%\n split_cols_by(\"SEX\", split_fun = add_overall_level(\"Total\", first = FALSE)) %>%\n summarize_patients_exposure_in_cols(\n var = \"AVAL\", col_split = TRUE,\n .labels = c(n_patients = \"Number of Patients\", sum_exposure = \"Patient Time*\"),\n custom_label = \"Total Number of Patients and Patient Time\"\n ) %>%\n analyze_patients_exposure_in_cols(\n var = \"AGEGR2\",\n col_split = FALSE\n ) %>%\n append_topleft(c(\"\", \"Age group (years)\"))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f) %>%\n prune_table()\nresult\n\nDuration of Exposure: Safety-Evaluable Patients\n\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\n Female Male Total \nAge group (years) Number of Patients Patient Time* Number of Patients Patient Time* Number of Patients Patient Time*\n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nTotal Number of Patients and Patient Time 134 (58.0%) 12591 83 (49.1%) 8050 217 (54.2%) 20641 \n 18 - 40 118 (51.1%) 11203 60 (35.5%) 5787 178 (44.5%) 16990 \n 41 - 64 16 (6.9%) 1388 22 (13.0%) 2183 38 (9.5%) 3571 \n >=65 0 (0.0%) 0 1 (0.6%) 80 1 (0.2%) 80 \n————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\n\n* Patient Time is the sum of exposure across all patients in days.\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\nset.seed(1, kind = \"Mersenne-Twister\")\n\nlabels <- var_labels(adex)\nadex <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\"\n ) %>%\n bind_rows(adex)\n\nadex <- adex %>%\n mutate(\n AGEGR1 = factor(ifelse(AGE < 65, \"<65\", \">=65\")),\n AGEGR2 = factor(case_when(\n AGE < 18 ~ \"< 18\",\n AGE >= 18 & AGE <= 40 ~ \"18 - 40\",\n AGE > 40 & AGE <= 64 ~ \"41 - 64\",\n TRUE ~ \">=65\"\n ), levels = c(\"< 18\", \"18 - 40\", \"41 - 64\", \">=65\")),\n SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n ))\n )\n\nvar_labels(adex) <- c(labels, \"Age group (years)\", \"Age group (years)\")\n\nadsl <- adsl %>%\n mutate(SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n )))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADSL <- ADSL %>% filter(ADSL$SAFFL == \"Y\") %>%\n mutate(SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n )))'),\n cdisc_dataset(\"ADEX\", adex, code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n set.seed(1, kind = \"Mersenne-Twister\")\n labels <- var_labels(ADEX)\n ADEX <- ADEX %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\") %>%\n bind_rows(ADEX)\n\n ADEX <- ADEX %>%\n mutate(\n AGEGR1 = factor(ifelse(AGE < 65, \"<65\", \">=65\")),\n AGEGR2 = factor(case_when(\n AGE < 18 ~ \"< 18\",\n AGE >= 18 & AGE <= 40 ~ \"18 - 40\",\n AGE > 40 & AGE <= 64 ~ \"41 - 64\",\n TRUE ~ \">=65\"\n ), levels = c(\"< 18\", \"18 - 40\", \"41 - 64\", \">=65\")),\n SEX = factor(case_when(\n SEX == \"F\" ~ \"Female\",\n SEX == \"M\" ~ \"Male\"\n )))\n var_labels(ADEX) <- c(labels, \"Age group (years)\", \"Age group (years)\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_exposure(\n label = \"Duration of Exposure Table\",\n dataname = \"ADEX\",\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = \"TDURD\"\n ),\n col_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"SEX\", \"ARM\")),\n selected = \"SEX\"\n ),\n row_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"AGEGR1\", \"AGEGR2\")),\n selected = \"AGEGR1\"\n ),\n parcat = choices_selected(\n choices = value_choices(adex, \"PARCAT2\"),\n selected = \"Drug A\"\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-09 18:19:49.3887 pid:8088 token:[] teal.modules.clinical Initializing tm_t_exposure\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/other/rmpt01.html",
"href": "tables/other/rmpt01.html",
"title": "RMPT01",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\n# Simulate ADEX records with PARAMCD == \"TDURD\" as they are not in sample scda dataset.\nset.seed(1, kind = \"Mersenne-Twister\")\nadex2 <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE)\n ) %>%\n bind_rows(adex)\n\n# Now pre-processing steps are carried out.\nanl <- adex2 %>%\n filter(\n PARAMCD == \"TDURD\",\n PARCAT2 == \"Drug A\",\n SAFFL == \"Y\"\n ) %>%\n mutate(\n aval_months = day2month(AVAL),\n aval_months_cat = factor(case_when(\n aval_months < 1 ~ \"< 1 month\",\n aval_months >= 1 & aval_months < 3 ~ \"1 to <3 months\",\n aval_months >= 3 & aval_months < 6 ~ \"3 to <6 months\",\n TRUE ~ \">=6 months\"\n ), levels = c(\"< 1 month\", \"1 to <3 months\", \"3 to <6 months\", \">=6 months\"))\n )\n\nadsl_f <- adsl %>% filter(adsl$SAFFL == \"Y\")\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Duration of Exposure: Safety-Evaluable Patients\",\n main_footer = \"* Patient Time is the sum of exposure across all patients in days.\",\n show_colcounts = TRUE\n) %>%\n summarize_patients_exposure_in_cols(\n var = \"AVAL\", col_split = TRUE,\n .labels = c(n_patients = \"Number of Patients\", sum_exposure = \"Patient Time*\"),\n custom_label = \"Total Number of Patients and Patient Time\"\n ) %>%\n analyze_patients_exposure_in_cols(\n var = \"aval_months_cat\",\n col_split = FALSE\n ) %>%\n append_topleft(c(\"\", \"Duration of exposure\"))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f)\nresult\n\nDuration of Exposure: Safety-Evaluable Patients\n\n——————————————————————————————————————————————————————————————————————————————\n Number of Patients Patient Time*\nDuration of exposure (N=400) (N=400) \n——————————————————————————————————————————————————————————————————————————————\nTotal Number of Patients and Patient Time 217 (54.2%) 20641 \n < 1 month 28 (7.0%) 504 \n 1 to <3 months 79 (19.8%) 4727 \n 3 to <6 months 101 (25.2%) 13690 \n >=6 months 9 (2.2%) 1720 \n——————————————————————————————————————————————————————————————————————————————\n\n* Patient Time is the sum of exposure across all patients in days.\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\nlabels <- var_labels(adex)\nset.seed(1, kind = \"Mersenne-Twister\")\nadex <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\"\n ) %>%\n bind_rows(adex)\n\nadex <- adex %>%\n mutate(\n aval_months = day2month(AVAL),\n aval_months_cat = factor(case_when(\n aval_months < 1 ~ \"< 1 month\",\n aval_months >= 1 & aval_months < 3 ~ \"1 to <3 months\",\n aval_months >= 3 & aval_months < 6 ~ \"3 to <6 months\",\n TRUE ~ \">=6 months\"\n ), levels = c(\"< 1 month\", \"1 to <3 months\", \"3 to <6 months\", \">=6 months\"))\n ) %>%\n select(-aval_months)\n\nvar_labels(adex) <- c(labels, \"Overall duration\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEX\", adex, code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n labels <- var_labels(ADEX)\n set.seed(1, kind = \"Mersenne-Twister\")\n ADEX <- ADEX %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(\n x = seq(1, 200), size = n(), replace = TRUE\n ),\n AVALU = \"Days\") %>%\n bind_rows(ADEX)\n\n ADEX <-ADEX %>%\n mutate(\n aval_months = day2month(AVAL),\n aval_months_cat = factor(case_when(\n aval_months < 1 ~ \"< 1 month\",\n aval_months >= 1 & aval_months < 3 ~ \"1 to <3 months\",\n aval_months >= 3 & aval_months < 6 ~ \"3 to <6 months\",\n TRUE ~ \">=6 months\"\n ), levels = c(\"< 1 month\", \"1 to <3 months\", \"3 to <6 months\", \">=6 months\"))) %>%\n select(-aval_months)\n\n var_labels(ADEX) <- c(labels, \"Overall duration\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_exposure(\n label = \"Duration of Exposure Table\",\n dataname = \"ADEX\",\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = \"TDURD\"\n ),\n col_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"SEX\", \"ARM\")),\n selected = NULL\n ),\n row_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"aval_months_cat\", \"RACE\", \"STRATA1\", \"SEX\")),\n selected = \"aval_months_cat\"\n ),\n parcat = choices_selected(\n choices = value_choices(adex, \"PARCAT2\"),\n selected = \"Drug A\"\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-08 19:57:10.7036 pid:8232 token:[] teal.modules.clinical Initializing tm_t_exposure\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\n# Simulate ADEX records with PARAMCD == \"TDURD\" as they are not in sample scda dataset.\nset.seed(1, kind = \"Mersenne-Twister\")\nadex2 <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE)\n ) %>%\n bind_rows(adex)\n\n# Now pre-processing steps are carried out.\nanl <- adex2 %>%\n filter(\n PARAMCD == \"TDURD\",\n PARCAT2 == \"Drug A\",\n SAFFL == \"Y\"\n ) %>%\n mutate(\n aval_months = day2month(AVAL),\n aval_months_cat = factor(case_when(\n aval_months < 1 ~ \"< 1 month\",\n aval_months >= 1 & aval_months < 3 ~ \"1 to <3 months\",\n aval_months >= 3 & aval_months < 6 ~ \"3 to <6 months\",\n TRUE ~ \">=6 months\"\n ), levels = c(\"< 1 month\", \"1 to <3 months\", \"3 to <6 months\", \">=6 months\"))\n )\n\nadsl_f <- adsl %>% filter(adsl$SAFFL == \"Y\")\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Duration of Exposure: Safety-Evaluable Patients\",\n main_footer = \"* Patient Time is the sum of exposure across all patients in days.\",\n show_colcounts = TRUE\n) %>%\n summarize_patients_exposure_in_cols(\n var = \"AVAL\", col_split = TRUE,\n .labels = c(n_patients = \"Number of Patients\", sum_exposure = \"Patient Time*\"),\n custom_label = \"Total Number of Patients and Patient Time\"\n ) %>%\n analyze_patients_exposure_in_cols(\n var = \"aval_months_cat\",\n col_split = FALSE\n ) %>%\n append_topleft(c(\"\", \"Duration of exposure\"))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f)\nresult\n\nDuration of Exposure: Safety-Evaluable Patients\n\n——————————————————————————————————————————————————————————————————————————————\n Number of Patients Patient Time*\nDuration of exposure (N=400) (N=400) \n——————————————————————————————————————————————————————————————————————————————\nTotal Number of Patients and Patient Time 217 (54.2%) 20641 \n < 1 month 28 (7.0%) 504 \n 1 to <3 months 79 (19.8%) 4727 \n 3 to <6 months 101 (25.2%) 13690 \n >=6 months 9 (2.2%) 1720 \n——————————————————————————————————————————————————————————————————————————————\n\n* Patient Time is the sum of exposure across all patients in days.\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\nlabels <- var_labels(adex)\nset.seed(1, kind = \"Mersenne-Twister\")\nadex <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\"\n ) %>%\n bind_rows(adex)\n\nadex <- adex %>%\n mutate(\n aval_months = day2month(AVAL),\n aval_months_cat = factor(case_when(\n aval_months < 1 ~ \"< 1 month\",\n aval_months >= 1 & aval_months < 3 ~ \"1 to <3 months\",\n aval_months >= 3 & aval_months < 6 ~ \"3 to <6 months\",\n TRUE ~ \">=6 months\"\n ), levels = c(\"< 1 month\", \"1 to <3 months\", \"3 to <6 months\", \">=6 months\"))\n ) %>%\n select(-aval_months)\n\nvar_labels(adex) <- c(labels, \"Overall duration\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEX\", adex, code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n labels <- var_labels(ADEX)\n set.seed(1, kind = \"Mersenne-Twister\")\n ADEX <- ADEX %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(\n x = seq(1, 200), size = n(), replace = TRUE\n ),\n AVALU = \"Days\") %>%\n bind_rows(ADEX)\n\n ADEX <-ADEX %>%\n mutate(\n aval_months = day2month(AVAL),\n aval_months_cat = factor(case_when(\n aval_months < 1 ~ \"< 1 month\",\n aval_months >= 1 & aval_months < 3 ~ \"1 to <3 months\",\n aval_months >= 3 & aval_months < 6 ~ \"3 to <6 months\",\n TRUE ~ \">=6 months\"\n ), levels = c(\"< 1 month\", \"1 to <3 months\", \"3 to <6 months\", \">=6 months\"))) %>%\n select(-aval_months)\n\n var_labels(ADEX) <- c(labels, \"Overall duration\")'),\n check = TRUE\n ),\n modules = modules(\n tm_t_exposure(\n label = \"Duration of Exposure Table\",\n dataname = \"ADEX\",\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = \"TDURD\"\n ),\n col_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"SEX\", \"ARM\")),\n selected = NULL\n ),\n row_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"aval_months_cat\", \"RACE\", \"STRATA1\", \"SEX\")),\n selected = \"aval_months_cat\"\n ),\n parcat = choices_selected(\n choices = value_choices(adex, \"PARCAT2\"),\n selected = \"Drug A\"\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-09 18:20:33.0329 pid:8238 token:[] teal.modules.clinical Initializing tm_t_exposure\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/other/aovt02.html",
"href": "tables/other/aovt02.html",
"title": "AOVT02",
"section": "",
- "text": "This example will focus on data from a single visit “WEEK 1 DAY 8” and a single endpoint “FKSI-FWB”. Only evaluable populations will be analyzed.\n\n\nData Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\nadqs_single <- adqs %>%\n filter(\n AVISIT == \"WEEK 1 DAY 8\",\n PARAMCD == \"FKSI-FWB\"\n ) %>%\n mutate(CHG = ifelse(BMEASIFL == \"Y\", CHG, NA))\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\", ref_group = \"ARM A\") %>%\n append_varlabels(adqs_single, \"PARAM\") %>%\n summarize_ancova(\n vars = \"CHG\",\n variables = list(arm = \"ARMCD\", covariates = NULL),\n conf_level = 0.95,\n var_labels = \"Unadjusted comparison\",\n .labels = c(lsmean = \"Mean\", lsmean_diff = \"Difference in Means\"),\n table_names = \"unadjusted\"\n ) %>%\n summarize_ancova(\n vars = \"CHG\",\n variables = list(arm = \"ARMCD\", covariates = c(\"BASE\", \"STRATA1\")),\n conf_level = 0.95,\n var_labels = \"Adjusted comparison (covariates BASE and STRATA1)\",\n table_names = \"adjusted\"\n )\n\nresult <- build_table(\n lyt = lyt,\n df = adqs_single,\n alt_counts_df = adsl\n)\n\nresult\n\nParameter ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————\nUnadjusted comparison \n n 68 73 62 \n Mean 3.68 5.07 3.09 \n Difference in Means 1.38 -0.59 \n 95% CI (-2.76, 5.53) (-4.91, 3.73)\n p-value 0.5113 0.7873 \nAdjusted comparison (covariates BASE and STRATA1) \n n 68 73 62 \n Adjusted Mean 4.06 3.57 3.34 \n Difference in Adjusted Means -0.49 -0.72 \n 95% CI (-3.28, 2.29) (-3.57, 2.12)\n p-value 0.7277 0.6165 \n\n\n\n\n\nCodelibrary(teal)\nlibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\narm_ref_comp <- list(\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n ),\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADQS\", adqs),\n code =\n 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\n ADQS <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adqs\"))',\n check = TRUE\n ),\n modules = modules(\n tm_t_ancova(\n label = \"ANCOVA table\",\n dataname = \"ADQS\",\n avisit = choices_selected(\n choices = value_choices(adqs, \"AVISIT\"),\n selected = \"WEEK 1 DAY 8\"\n ),\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ACTARMCD\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n aval_var = choices_selected(\n choices = variable_choices(adqs, c(\"CHG\", \"AVAL\")),\n selected = \"CHG\"\n ),\n cov_var = choices_selected(\n choices = variable_choices(adqs, c(\"BASE\", \"STRATA1\", \"SEX\")),\n selected = \"STRATA1\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = \"FKSI-FWB\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 19:57:43.2081 pid:8381 token:[] teal.modules.clinical Initializing tm_t_ancova\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "This example will focus on data from a single visit “WEEK 1 DAY 8” and a single endpoint “FKSI-FWB”. Only evaluable populations will be analyzed.\n\n\nData Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\nadqs_single <- adqs %>%\n filter(\n AVISIT == \"WEEK 1 DAY 8\",\n PARAMCD == \"FKSI-FWB\"\n ) %>%\n mutate(CHG = ifelse(BMEASIFL == \"Y\", CHG, NA))\n\n\n\n\n\nCodelyt <- basic_table(show_colcounts = TRUE) %>%\n split_cols_by(\"ARMCD\", ref_group = \"ARM A\") %>%\n append_varlabels(adqs_single, \"PARAM\") %>%\n summarize_ancova(\n vars = \"CHG\",\n variables = list(arm = \"ARMCD\", covariates = NULL),\n conf_level = 0.95,\n var_labels = \"Unadjusted comparison\",\n .labels = c(lsmean = \"Mean\", lsmean_diff = \"Difference in Means\"),\n table_names = \"unadjusted\"\n ) %>%\n summarize_ancova(\n vars = \"CHG\",\n variables = list(arm = \"ARMCD\", covariates = c(\"BASE\", \"STRATA1\")),\n conf_level = 0.95,\n var_labels = \"Adjusted comparison (covariates BASE and STRATA1)\",\n table_names = \"adjusted\"\n )\n\nresult <- build_table(\n lyt = lyt,\n df = adqs_single,\n alt_counts_df = adsl\n)\n\nresult\n\nParameter ARM A ARM B ARM C \n (N=134) (N=134) (N=132) \n———————————————————————————————————————————————————————————————————————————————————————————\nUnadjusted comparison \n n 68 73 62 \n Mean 3.68 5.07 3.09 \n Difference in Means 1.38 -0.59 \n 95% CI (-2.76, 5.53) (-4.91, 3.73)\n p-value 0.5113 0.7873 \nAdjusted comparison (covariates BASE and STRATA1) \n n 68 73 62 \n Adjusted Mean 4.06 3.57 3.34 \n Difference in Adjusted Means -0.49 -0.72 \n 95% CI (-3.28, 2.29) (-3.57, 2.12)\n p-value 0.7277 0.6165 \n\n\n\n\n\nCodelibrary(teal)\nlibrary(scda)\nlibrary(teal.modules.clinical)\nlibrary(tern)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadqs <- synthetic_cdisc_dataset(\"latest\", \"adqs\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadqs <- df_explicit_na(adqs)\n\narm_ref_comp <- list(\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n ),\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl),\n cdisc_dataset(\"ADQS\", adqs),\n code =\n 'ADSL <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adsl\"))\n ADQS <- df_explicit_na(synthetic_cdisc_dataset(\"latest\", \"adqs\"))',\n check = TRUE\n ),\n modules = modules(\n tm_t_ancova(\n label = \"ANCOVA table\",\n dataname = \"ADQS\",\n avisit = choices_selected(\n choices = value_choices(adqs, \"AVISIT\"),\n selected = \"WEEK 1 DAY 8\"\n ),\n arm_var = choices_selected(\n choices = variable_choices(adsl, c(\"ARM\", \"ACTARMCD\")),\n selected = \"ARM\"\n ),\n arm_ref_comp = arm_ref_comp,\n aval_var = choices_selected(\n choices = variable_choices(adqs, c(\"CHG\", \"AVAL\")),\n selected = \"CHG\"\n ),\n cov_var = choices_selected(\n choices = variable_choices(adqs, c(\"BASE\", \"STRATA1\", \"SEX\")),\n selected = \"STRATA1\"\n ),\n paramcd = choices_selected(\n choices = value_choices(adqs, \"PARAMCD\", \"PARAM\"),\n selected = \"FKSI-FWB\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:21:15.3760 pid:8387 token:[] teal.modules.clinical Initializing tm_t_ancova\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 tern_0.9.0.9002 \n [9] rtables_0.6.3.9000 magrittr_2.0.3 \n[11] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] sass_0.4.7 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/other/rbmit01.html",
"href": "tables/other/rbmit01.html",
"title": "RBMIT01",
"section": "",
- "text": "Data Setup\nDraws\nImpute\nAnalyze\nPool\nCreate Output\nReproducibility\n\n\n\nWe use a publicly available example dataset from an antidepressant clinical trial of an active drug versus placebo from the rbmi package. The relevant endpoint is the Hamilton 17-item depression rating scale (HAMD17) which was assessed at baseline and at weeks 1, 2, 4, and 6. Study drug discontinuation occurred in 24% of subjects from the active drug and 26% of subjects from placebo. All data after study drug discontinuation are missing and there is a single additional intermittent missing observation.\n\nCodelibrary(tern.rbmi)\nlibrary(dplyr)\nset.seed(123)\n\ndata <- antidepressant_data\nlevels(data$THERAPY) <- c(\"PLACEBO\", \"DRUG\") # This is important! The order defines the computation order later\n\nmissing_var <- \"CHANGE\"\nvars <- list(\n id = \"PATIENT\",\n visit = \"VISIT\",\n expand_vars = c(\"BASVAL\", \"THERAPY\"),\n group = \"THERAPY\"\n)\ncovariates <- list(\n draws = c(\"BASVAL*VISIT\", \"THERAPY*VISIT\"),\n analyse = c(\"BASVAL\")\n)\n\ndata <- data %>%\n dplyr::select(PATIENT, THERAPY, VISIT, BASVAL, THERAPY, CHANGE) %>%\n dplyr::mutate(dplyr::across(.cols = vars$id, ~ as.factor(.x))) %>%\n dplyr::arrange(dplyr::across(.cols = c(vars$id, vars$visit)))\n\n# Use expand_locf to add rows corresponding to visits with missing outcomes to the dataset\ndata_full <- do.call(\n expand_locf,\n args = list(\n data = data,\n vars = c(vars$expand_vars, vars$group),\n group = vars$id,\n order = c(vars$id, vars$visit)\n ) %>%\n append(lapply(data[c(vars$id, vars$visit)], levels))\n)\n\ndata_full <- data_full %>%\n dplyr::group_by(dplyr::across(vars$id)) %>%\n dplyr::mutate(!!vars$group := Filter(Negate(is.na), .data[[vars$group]])[1])\n\n# there are duplicates - use first value\ndata_full <- data_full %>%\n dplyr::group_by(dplyr::across(c(vars$id, vars$group, vars$visit))) %>%\n dplyr::slice(1) %>%\n dplyr::ungroup()\n# need to have a single ID column\ndata_full <- data_full %>%\n tidyr::unite(\"TMP_ID\", dplyr::all_of(vars$id), sep = \"_#_\", remove = FALSE) %>%\n dplyr::mutate(TMP_ID = as.factor(TMP_ID))\n\n\nCreating Intercurrent Event Data\nSet the imputation strategy to \"MAR\" for each patient with at least one missing observation.\n\nCodedata_ice <- data_full %>%\n dplyr::arrange(dplyr::across(.cols = c(\"TMP_ID\", vars$visit))) %>%\n dplyr::filter(is.na(.data[[missing_var]])) %>%\n dplyr::group_by(TMP_ID) %>%\n dplyr::slice(1) %>%\n dplyr::ungroup() %>%\n dplyr::select(all_of(c(\"TMP_ID\", vars$visit))) %>%\n dplyr::mutate(strategy = \"MAR\")\n\n\n\n\n\nThe rbmi::draws() function fits the imputation models and stores the corresponding parameter estimates or Bayesian posterior parameter draws. The three main inputs to the rbmi::draws() function are:\n\n\ndata - The primary longitudinal data.frame containing the outcome variable and all covariates.\n\ndata_ice - A data.frame which specifies the first visit affected by an intercurrent event (ICE) and the imputation strategy for handling missing outcome data after the ICE. At most one ICE which is to be imputed by a non-MAR strategy is allowed per subject.\n\nmethod - The statistical method used to fit the imputation models and to create imputed datasets.\n\nDefine Key Variables\nDefine the names of key variables in our dataset and the covariates included in the imputation model using rbmi::set_vars(). Note that the covariates argument can also include interaction terms.\n\nCodedebug_mode <- FALSE\n\ndraws_vars <- rbmi::set_vars(\n outcome = missing_var,\n visit = vars$visit,\n group = vars$group,\n covariates = covariates$draws\n)\ndraws_vars$subjid <- \"TMP_ID\"\n\n\nDefine which imputation method to use, then create samples for the imputation parameters by running the draws() function.\n\nCodedraws_method <- method_bayes()\n\ndraws_obj <- rbmi::draws(\n data = data_full,\n data_ice = data_ice,\n vars = draws_vars,\n method = draws_method\n)\n\n\nSAMPLING FOR MODEL 'MMRM' NOW (CHAIN 1).\nChain 1: \nChain 1: Gradient evaluation took 0.000265 seconds\nChain 1: 1000 transitions using 10 leapfrog steps per transition would take 2.65 seconds.\nChain 1: Adjust your expectations accordingly!\nChain 1: \nChain 1: \nChain 1: Iteration: 1 / 1200 [ 0%] (Warmup)\nChain 1: Iteration: 120 / 1200 [ 10%] (Warmup)\nChain 1: Iteration: 201 / 1200 [ 16%] (Sampling)\nChain 1: Iteration: 320 / 1200 [ 26%] (Sampling)\nChain 1: Iteration: 440 / 1200 [ 36%] (Sampling)\nChain 1: Iteration: 560 / 1200 [ 46%] (Sampling)\nChain 1: Iteration: 680 / 1200 [ 56%] (Sampling)\nChain 1: Iteration: 800 / 1200 [ 66%] (Sampling)\nChain 1: Iteration: 920 / 1200 [ 76%] (Sampling)\nChain 1: Iteration: 1040 / 1200 [ 86%] (Sampling)\nChain 1: Iteration: 1160 / 1200 [ 96%] (Sampling)\nChain 1: Iteration: 1200 / 1200 [100%] (Sampling)\nChain 1: \nChain 1: Elapsed Time: 0.67 seconds (Warm-up)\nChain 1: 2.209 seconds (Sampling)\nChain 1: 2.879 seconds (Total)\nChain 1: \n\n\n\n\n\nThe next step is to use the parameters from the imputation model to generate the imputed datasets. This is done via the rbmi::impute() function. The function only has two key inputs: the imputation model output from rbmi::draws() and the reference groups relevant to reference-based imputation methods. It’s usage is thus:\n\nCodeimpute_references <- c(\"DRUG\" = \"PLACEBO\", \"PLACEBO\" = \"PLACEBO\")\n\nimpute_obj <- rbmi::impute(\n draws_obj,\n references = impute_references\n)\n\n\n\n\nThe next step is to run the analysis model on each imputed dataset. This is done by defining an analysis function and then calling rbmi::analyse() to apply this function to each imputed dataset.\n\nCode# Define analysis model\nanalyse_fun <- ancova\n\nref_levels <- levels(impute_obj$data$group[[1]])\nnames(ref_levels) <- c(\"ref\", \"alt\")\n\nanalyse_obj <- rbmi::analyse(\n imputations = impute_obj,\n fun = analyse_fun,\n vars = rbmi::set_vars(\n subjid = \"TMP_ID\",\n outcome = missing_var,\n visit = vars$visit,\n group = vars$group,\n covariates = covariates$analyse\n )\n)\n\n\n\n\nThe rbmi::pool() function can be used to summarize the analysis results across multiple imputed datasets to provide an overall statistic with a standard error, confidence intervals and a p-value for the hypothesis test of the null hypothesis that the effect is equal to 0. Using the broom::tidy() function the rbmi final results are reshaped.\n\nCodelibrary(broom)\n\npool_obj <- rbmi::pool(\n results = analyse_obj,\n conf.level = 0.95,\n alternative = c(\"two.sided\", \"less\", \"greater\"),\n type = c(\"percentile\", \"normal\")\n)\n\ndf <- tidy(pool_obj)\ndf\n\n group est se_est lower_cl_est upper_cl_est est_contr se_contr\n1 ref -1.615820 0.4862316 -2.575771 -0.6558685 NA NA\n2 alt -1.707626 0.4749573 -2.645319 -0.7699335 -0.09180645 0.6826279\n3 ref -4.259215 0.6512947 -5.545482 -2.9729489 NA NA\n4 alt -2.803091 0.6401567 -4.067559 -1.5386238 1.45612388 0.9134765\n5 ref -6.387805 0.7157832 -7.803078 -4.9725331 NA NA\n6 alt -4.109707 0.6921316 -5.477690 -2.7417237 2.27809862 1.0002177\n7 ref -7.693888 0.8014324 -9.280710 -6.1070669 NA NA\n8 alt -4.794189 0.7518189 -6.280149 -3.3082297 2.89969888 1.0969392\n lower_cl_contr upper_cl_contr p_value relative_reduc visit conf_level\n1 NA NA NA NA 4 0.95\n2 -1.4394968 1.255884 0.89317724 0.05681725 4 0.95\n3 NA NA NA NA 5 0.95\n4 -0.3478941 3.260142 0.11289798 -0.34187609 5 0.95\n5 NA NA NA NA 6 0.95\n6 0.3007916 4.255406 0.02424954 -0.35663244 6 0.95\n7 NA NA NA NA 7 0.95\n8 0.7303454 5.069052 0.00917510 -0.37688341 7 0.95\n\n\n\n\nFinally, use functions from the rtables and tern packages to generate a nicely formatted rtable object.\n\nCoderesult <- basic_table() %>%\n split_cols_by(\"group\", ref_group = levels(df$group)[1]) %>%\n split_rows_by(\"visit\", split_label = \"Visit\", label_pos = \"topleft\") %>%\n summarize_rbmi() %>%\n build_table(df)\nresult\n\nVisit ref alt \n—————————————————————————————————————————————————————————————————————————\n4 \n Adjusted Mean (SE) -1.616 (0.486) -1.708 (0.475) \n 95% CI (-2.576, -0.656) (-2.645, -0.770)\n Difference in Adjusted Means (SE) -0.092 (0.683) \n 95% CI (-1.439, 1.256) \n Relative Reduction (%) 5.7% \n p-value (RBMI) 0.8932 \n5 \n Adjusted Mean (SE) -4.259 (0.651) -2.803 (0.640) \n 95% CI (-5.545, -2.973) (-4.068, -1.539)\n Difference in Adjusted Means (SE) 1.456 (0.913) \n 95% CI (-0.348, 3.260) \n Relative Reduction (%) -34.2% \n p-value (RBMI) 0.1129 \n6 \n Adjusted Mean (SE) -6.388 (0.716) -4.110 (0.692) \n 95% CI (-7.803, -4.973) (-5.478, -2.742)\n Difference in Adjusted Means (SE) 2.278 (1.000) \n 95% CI (0.301, 4.255) \n Relative Reduction (%) -35.7% \n p-value (RBMI) 0.0242 \n7 \n Adjusted Mean (SE) -7.694 (0.801) -4.794 (0.752) \n 95% CI (-9.281, -6.107) (-6.280, -3.308)\n Difference in Adjusted Means (SE) 2.900 (1.097) \n 95% CI (0.730, 5.069) \n Relative Reduction (%) -37.7% \n p-value (RBMI) 0.0092 \n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n[1] broom_1.0.5 dplyr_1.1.2 tern.rbmi_0.1.2.9008 \n[4] tern_0.9.0.9002 rtables_0.6.3.9000 magrittr_2.0.3 \n[7] formatters_0.5.2.9001 rbmi_1.2.3 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 loo_2.6.0 fastmap_1.1.1 \n [4] TH.data_1.1-2 digest_0.6.33 estimability_1.4.1 \n [7] lifecycle_1.0.3 StanHeaders_2.26.27 survival_3.5-7 \n[10] processx_3.8.2 compiler_4.3.1 rlang_1.1.1 \n[13] tools_4.3.1 utf8_1.2.3 yaml_2.3.7 \n[16] mmrm_0.2.2 knitr_1.43 prettyunits_1.1.1 \n[19] htmlwidgets_1.6.2 pkgbuild_1.4.2 multcomp_1.4-25 \n[22] withr_2.5.0 purrr_1.0.2 numDeriv_2016.8-1.1\n[25] grid_4.3.1 stats4_4.3.1 fansi_1.0.4 \n[28] xtable_1.8-4 colorspace_2.1-0 inline_0.3.19 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 crayon_1.5.2 generics_0.1.3 \n[40] RcppParallel_5.1.7 rstudioapi_0.15.0 rstan_2.21.8 \n[43] stringr_1.5.0 splines_4.3.1 assertthat_0.2.1 \n[46] parallel_4.3.1 matrixStats_1.0.0 vctrs_0.6.3 \n[49] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[52] callr_3.7.3 testthat_3.1.10 tidyr_1.3.0 \n[55] glue_1.6.2 codetools_0.2-19 ps_1.7.5 \n[58] stringi_1.7.12 gtable_0.3.3 munsell_0.5.0 \n[61] tibble_3.2.1 pillar_1.9.0 htmltools_0.5.6 \n[64] brio_1.1.3 R6_2.5.1 TMB_1.9.6 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 Rcpp_1.0.11 \n[73] coda_0.19-4 gridExtra_2.3 nlme_3.1-163 \n[76] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[79] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nDraws\nImpute\nAnalyze\nPool\nCreate Output\nReproducibility\n\n\n\nWe use a publicly available example dataset from an antidepressant clinical trial of an active drug versus placebo from the rbmi package. The relevant endpoint is the Hamilton 17-item depression rating scale (HAMD17) which was assessed at baseline and at weeks 1, 2, 4, and 6. Study drug discontinuation occurred in 24% of subjects from the active drug and 26% of subjects from placebo. All data after study drug discontinuation are missing and there is a single additional intermittent missing observation.\n\nCodelibrary(tern.rbmi)\nlibrary(dplyr)\nset.seed(123)\n\ndata <- antidepressant_data\nlevels(data$THERAPY) <- c(\"PLACEBO\", \"DRUG\") # This is important! The order defines the computation order later\n\nmissing_var <- \"CHANGE\"\nvars <- list(\n id = \"PATIENT\",\n visit = \"VISIT\",\n expand_vars = c(\"BASVAL\", \"THERAPY\"),\n group = \"THERAPY\"\n)\ncovariates <- list(\n draws = c(\"BASVAL*VISIT\", \"THERAPY*VISIT\"),\n analyse = c(\"BASVAL\")\n)\n\ndata <- data %>%\n dplyr::select(PATIENT, THERAPY, VISIT, BASVAL, THERAPY, CHANGE) %>%\n dplyr::mutate(dplyr::across(.cols = vars$id, ~ as.factor(.x))) %>%\n dplyr::arrange(dplyr::across(.cols = c(vars$id, vars$visit)))\n\n# Use expand_locf to add rows corresponding to visits with missing outcomes to the dataset\ndata_full <- do.call(\n expand_locf,\n args = list(\n data = data,\n vars = c(vars$expand_vars, vars$group),\n group = vars$id,\n order = c(vars$id, vars$visit)\n ) %>%\n append(lapply(data[c(vars$id, vars$visit)], levels))\n)\n\ndata_full <- data_full %>%\n dplyr::group_by(dplyr::across(vars$id)) %>%\n dplyr::mutate(!!vars$group := Filter(Negate(is.na), .data[[vars$group]])[1])\n\n# there are duplicates - use first value\ndata_full <- data_full %>%\n dplyr::group_by(dplyr::across(c(vars$id, vars$group, vars$visit))) %>%\n dplyr::slice(1) %>%\n dplyr::ungroup()\n# need to have a single ID column\ndata_full <- data_full %>%\n tidyr::unite(\"TMP_ID\", dplyr::all_of(vars$id), sep = \"_#_\", remove = FALSE) %>%\n dplyr::mutate(TMP_ID = as.factor(TMP_ID))\n\n\nCreating Intercurrent Event Data\nSet the imputation strategy to \"MAR\" for each patient with at least one missing observation.\n\nCodedata_ice <- data_full %>%\n dplyr::arrange(dplyr::across(.cols = c(\"TMP_ID\", vars$visit))) %>%\n dplyr::filter(is.na(.data[[missing_var]])) %>%\n dplyr::group_by(TMP_ID) %>%\n dplyr::slice(1) %>%\n dplyr::ungroup() %>%\n dplyr::select(all_of(c(\"TMP_ID\", vars$visit))) %>%\n dplyr::mutate(strategy = \"MAR\")\n\n\n\n\n\nThe rbmi::draws() function fits the imputation models and stores the corresponding parameter estimates or Bayesian posterior parameter draws. The three main inputs to the rbmi::draws() function are:\n\n\ndata - The primary longitudinal data.frame containing the outcome variable and all covariates.\n\ndata_ice - A data.frame which specifies the first visit affected by an intercurrent event (ICE) and the imputation strategy for handling missing outcome data after the ICE. At most one ICE which is to be imputed by a non-MAR strategy is allowed per subject.\n\nmethod - The statistical method used to fit the imputation models and to create imputed datasets.\n\nDefine Key Variables\nDefine the names of key variables in our dataset and the covariates included in the imputation model using rbmi::set_vars(). Note that the covariates argument can also include interaction terms.\n\nCodedebug_mode <- FALSE\n\ndraws_vars <- rbmi::set_vars(\n outcome = missing_var,\n visit = vars$visit,\n group = vars$group,\n covariates = covariates$draws\n)\ndraws_vars$subjid <- \"TMP_ID\"\n\n\nDefine which imputation method to use, then create samples for the imputation parameters by running the draws() function.\n\nCodedraws_method <- method_bayes()\n\ndraws_obj <- rbmi::draws(\n data = data_full,\n data_ice = data_ice,\n vars = draws_vars,\n method = draws_method\n)\n\n\nSAMPLING FOR MODEL 'MMRM' NOW (CHAIN 1).\nChain 1: \nChain 1: Gradient evaluation took 0.00041 seconds\nChain 1: 1000 transitions using 10 leapfrog steps per transition would take 4.1 seconds.\nChain 1: Adjust your expectations accordingly!\nChain 1: \nChain 1: \nChain 1: Iteration: 1 / 1200 [ 0%] (Warmup)\nChain 1: Iteration: 120 / 1200 [ 10%] (Warmup)\nChain 1: Iteration: 201 / 1200 [ 16%] (Sampling)\nChain 1: Iteration: 320 / 1200 [ 26%] (Sampling)\nChain 1: Iteration: 440 / 1200 [ 36%] (Sampling)\nChain 1: Iteration: 560 / 1200 [ 46%] (Sampling)\nChain 1: Iteration: 680 / 1200 [ 56%] (Sampling)\nChain 1: Iteration: 800 / 1200 [ 66%] (Sampling)\nChain 1: Iteration: 920 / 1200 [ 76%] (Sampling)\nChain 1: Iteration: 1040 / 1200 [ 86%] (Sampling)\nChain 1: Iteration: 1160 / 1200 [ 96%] (Sampling)\nChain 1: Iteration: 1200 / 1200 [100%] (Sampling)\nChain 1: \nChain 1: Elapsed Time: 1.032 seconds (Warm-up)\nChain 1: 3.25 seconds (Sampling)\nChain 1: 4.282 seconds (Total)\nChain 1: \n\n\n\n\n\nThe next step is to use the parameters from the imputation model to generate the imputed datasets. This is done via the rbmi::impute() function. The function only has two key inputs: the imputation model output from rbmi::draws() and the reference groups relevant to reference-based imputation methods. It’s usage is thus:\n\nCodeimpute_references <- c(\"DRUG\" = \"PLACEBO\", \"PLACEBO\" = \"PLACEBO\")\n\nimpute_obj <- rbmi::impute(\n draws_obj,\n references = impute_references\n)\n\n\n\n\nThe next step is to run the analysis model on each imputed dataset. This is done by defining an analysis function and then calling rbmi::analyse() to apply this function to each imputed dataset.\n\nCode# Define analysis model\nanalyse_fun <- ancova\n\nref_levels <- levels(impute_obj$data$group[[1]])\nnames(ref_levels) <- c(\"ref\", \"alt\")\n\nanalyse_obj <- rbmi::analyse(\n imputations = impute_obj,\n fun = analyse_fun,\n vars = rbmi::set_vars(\n subjid = \"TMP_ID\",\n outcome = missing_var,\n visit = vars$visit,\n group = vars$group,\n covariates = covariates$analyse\n )\n)\n\n\n\n\nThe rbmi::pool() function can be used to summarize the analysis results across multiple imputed datasets to provide an overall statistic with a standard error, confidence intervals and a p-value for the hypothesis test of the null hypothesis that the effect is equal to 0. Using the broom::tidy() function the rbmi final results are reshaped.\n\nCodelibrary(broom)\n\npool_obj <- rbmi::pool(\n results = analyse_obj,\n conf.level = 0.95,\n alternative = c(\"two.sided\", \"less\", \"greater\"),\n type = c(\"percentile\", \"normal\")\n)\n\ndf <- tidy(pool_obj)\ndf\n\n group est se_est lower_cl_est upper_cl_est est_contr se_contr\n1 ref -1.615820 0.4862316 -2.575771 -0.6558685 NA NA\n2 alt -1.707626 0.4749573 -2.645319 -0.7699335 -0.09180645 0.6826279\n3 ref -4.273602 0.6513204 -5.559951 -2.9872533 NA NA\n4 alt -2.808293 0.6418892 -4.076312 -1.5402739 1.46530939 0.9163627\n5 ref -6.362123 0.7243964 -7.795134 -4.9291110 NA NA\n6 alt -4.105850 0.6867543 -5.462835 -2.7488648 2.25627257 1.0001715\n7 ref -7.630322 0.8118427 -9.238785 -6.0218592 NA NA\n8 alt -4.779206 0.7588778 -6.279596 -3.2788159 2.85111618 1.0894272\n lower_cl_contr upper_cl_contr p_value relative_reduc visit conf_level\n1 NA NA NA NA 4 0.95\n2 -1.4394968 1.255884 0.893177243 0.05681725 4 0.95\n3 NA NA NA NA 5 0.95\n4 -0.3445906 3.275209 0.111807295 -0.34287454 5 0.95\n5 NA NA NA NA 6 0.95\n6 0.2790774 4.233468 0.025610109 -0.35464148 6 0.95\n7 NA NA NA NA 7 0.95\n8 0.6972887 5.004944 0.009841494 -0.37365607 7 0.95\n\n\n\n\nFinally, use functions from the rtables and tern packages to generate a nicely formatted rtable object.\n\nCoderesult <- basic_table() %>%\n split_cols_by(\"group\", ref_group = levels(df$group)[1]) %>%\n split_rows_by(\"visit\", split_label = \"Visit\", label_pos = \"topleft\") %>%\n summarize_rbmi() %>%\n build_table(df)\nresult\n\nVisit ref alt \n—————————————————————————————————————————————————————————————————————————\n4 \n Adjusted Mean (SE) -1.616 (0.486) -1.708 (0.475) \n 95% CI (-2.576, -0.656) (-2.645, -0.770)\n Difference in Adjusted Means (SE) -0.092 (0.683) \n 95% CI (-1.439, 1.256) \n Relative Reduction (%) 5.7% \n p-value (RBMI) 0.8932 \n5 \n Adjusted Mean (SE) -4.274 (0.651) -2.808 (0.642) \n 95% CI (-5.560, -2.987) (-4.076, -1.540)\n Difference in Adjusted Means (SE) 1.465 (0.916) \n 95% CI (-0.345, 3.275) \n Relative Reduction (%) -34.3% \n p-value (RBMI) 0.1118 \n6 \n Adjusted Mean (SE) -6.362 (0.724) -4.106 (0.687) \n 95% CI (-7.795, -4.929) (-5.463, -2.749)\n Difference in Adjusted Means (SE) 2.256 (1.000) \n 95% CI (0.279, 4.233) \n Relative Reduction (%) -35.5% \n p-value (RBMI) 0.0256 \n7 \n Adjusted Mean (SE) -7.630 (0.812) -4.779 (0.759) \n 95% CI (-9.239, -6.022) (-6.280, -3.279)\n Difference in Adjusted Means (SE) 2.851 (1.089) \n 95% CI (0.697, 5.005) \n Relative Reduction (%) -37.4% \n p-value (RBMI) 0.0098 \n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n[1] broom_1.0.5 dplyr_1.1.2 tern.rbmi_0.1.2.9008 \n[4] tern_0.9.0.9002 rtables_0.6.3.9000 magrittr_2.0.3 \n[7] formatters_0.5.2.9001 rbmi_1.2.3 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 loo_2.6.0 fastmap_1.1.1 \n [4] TH.data_1.1-2 digest_0.6.33 estimability_1.4.1 \n [7] lifecycle_1.0.3 StanHeaders_2.26.27 survival_3.5-7 \n[10] processx_3.8.2 compiler_4.3.1 rlang_1.1.1 \n[13] tools_4.3.1 utf8_1.2.3 yaml_2.3.7 \n[16] mmrm_0.2.2 knitr_1.43 prettyunits_1.1.1 \n[19] htmlwidgets_1.6.2 pkgbuild_1.4.2 multcomp_1.4-25 \n[22] withr_2.5.0 purrr_1.0.2 numDeriv_2016.8-1.1\n[25] grid_4.3.1 stats4_4.3.1 fansi_1.0.4 \n[28] xtable_1.8-4 colorspace_2.1-0 inline_0.3.19 \n[31] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[34] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[37] rmarkdown_2.24 crayon_1.5.2 generics_0.1.3 \n[40] RcppParallel_5.1.7 rstudioapi_0.15.0 rstan_2.21.8 \n[43] stringr_1.5.0 splines_4.3.1 assertthat_0.2.1 \n[46] parallel_4.3.1 matrixStats_1.0.0 vctrs_0.6.3 \n[49] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[52] callr_3.7.3 testthat_3.1.10 tidyr_1.3.0 \n[55] glue_1.6.2 codetools_0.2-19 ps_1.7.5 \n[58] stringi_1.7.12 gtable_0.3.3 munsell_0.5.0 \n[61] tibble_3.2.1 pillar_1.9.0 htmltools_0.5.6 \n[64] brio_1.1.3 R6_2.5.1 TMB_1.9.6 \n[67] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[70] rbibutils_2.2.14 backports_1.4.1 Rcpp_1.0.11 \n[73] coda_0.19-4 gridExtra_2.3 nlme_3.1-163 \n[76] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[79] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/other/rmpt05.html",
"href": "tables/other/rmpt05.html",
"title": "RMPT05",
"section": "",
- "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\n# Simulate ADEX records with PARAMCD == \"TDURD\" as they are not in the sample dataset.\nset.seed(1)\nadex2 <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE)\n ) %>%\n bind_rows(adex)\n\n# Now pre-processing steps are carried out.\nanl <- adex2 %>%\n filter(\n PARAMCD == \"TDURD\",\n PARCAT2 == \"Drug A\",\n SAFFL == \"Y\"\n ) %>%\n mutate()\n\nadsl_f <- adsl %>% filter(adsl$SAFFL == \"Y\")\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Extent of Exposure by Race: Safety-Evaluable Patients\",\n main_footer = \"* Person time is the sum of exposure across all patients in unit: days.\",\n show_colcounts = TRUE\n) %>%\n summarize_patients_exposure_in_cols(\n var = \"AVAL\", col_split = TRUE,\n .labels = c(n_patients = \"Patients\", sum_exposure = \"Person time*\")\n ) %>%\n analyze_patients_exposure_in_cols(\n var = \"RACE\",\n col_split = FALSE\n ) %>%\n append_topleft(c(\"\", obj_label(adex$RACE)))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f)\nresult\n\nExtent of Exposure by Race: Safety-Evaluable Patients\n\n————————————————————————————————————————————————————————————————————————\n Patients Person time*\nRace (N=400) (N=400) \n————————————————————————————————————————————————————————————————————————\nTotal patients numbers/person time 217 (54.2%) 20641 \n ASIAN 113 (28.2%) 10239 \n BLACK OR AFRICAN AMERICAN 48 (12.0%) 4481 \n WHITE 40 (10.0%) 4237 \n AMERICAN INDIAN OR ALASKA NATIVE 14 (3.5%) 1566 \n MULTIPLE 1 (0.2%) 58 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 1 (0.2%) 60 \n OTHER 0 (0.0%) 0 \n UNKNOWN 0 (0.0%) 0 \n————————————————————————————————————————————————————————————————————————\n\n* Person time is the sum of exposure across all patients in unit: days.\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\nlabels <- var_labels(adex)\n\nset.seed(1, kind = \"Mersenne-Twister\")\nadex <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\"\n ) %>%\n bind_rows(adex)\n\nvar_labels(adex) <- labels\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEX\", adex,\n code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n labels <- var_labels(ADEX)\n set.seed(1, kind = \"Mersenne-Twister\")\n ADEX <- ADEX %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\") %>%\n bind_rows(ADEX)\n var_labels(ADEX) <- labels'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_exposure(\n label = \"Duration of Exposure Table\",\n dataname = \"ADEX\",\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = \"TDURD\"\n ),\n col_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"SEX\", \"ARM\")),\n selected = NULL\n ),\n row_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"RACE\", \"STRATA1\", \"SEX\")),\n selected = \"RACE\"\n ),\n parcat = choices_selected(\n choices = value_choices(adex, \"PARCAT2\"),\n selected = \"Drug A\"\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-08 19:59:37.8275 pid:8747 token:[] teal.modules.clinical Initializing tm_t_exposure\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Table\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n\n# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.\nadsl <- df_explicit_na(adsl)\nadex <- df_explicit_na(adex)\n\n# Simulate ADEX records with PARAMCD == \"TDURD\" as they are not in the sample dataset.\nset.seed(1)\nadex2 <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE)\n ) %>%\n bind_rows(adex)\n\n# Now pre-processing steps are carried out.\nanl <- adex2 %>%\n filter(\n PARAMCD == \"TDURD\",\n PARCAT2 == \"Drug A\",\n SAFFL == \"Y\"\n ) %>%\n mutate()\n\nadsl_f <- adsl %>% filter(adsl$SAFFL == \"Y\")\n\n\n\n\n\nCodelyt <- basic_table(\n title = \"Extent of Exposure by Race: Safety-Evaluable Patients\",\n main_footer = \"* Person time is the sum of exposure across all patients in unit: days.\",\n show_colcounts = TRUE\n) %>%\n summarize_patients_exposure_in_cols(\n var = \"AVAL\", col_split = TRUE,\n .labels = c(n_patients = \"Patients\", sum_exposure = \"Person time*\")\n ) %>%\n analyze_patients_exposure_in_cols(\n var = \"RACE\",\n col_split = FALSE\n ) %>%\n append_topleft(c(\"\", obj_label(adex$RACE)))\n\nresult <- build_table(lyt, df = anl, alt_counts_df = adsl_f)\nresult\n\nExtent of Exposure by Race: Safety-Evaluable Patients\n\n————————————————————————————————————————————————————————————————————————\n Patients Person time*\nRace (N=400) (N=400) \n————————————————————————————————————————————————————————————————————————\nTotal patients numbers/person time 217 (54.2%) 20641 \n ASIAN 113 (28.2%) 10239 \n BLACK OR AFRICAN AMERICAN 48 (12.0%) 4481 \n WHITE 40 (10.0%) 4237 \n AMERICAN INDIAN OR ALASKA NATIVE 14 (3.5%) 1566 \n MULTIPLE 1 (0.2%) 58 \n NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 1 (0.2%) 60 \n OTHER 0 (0.0%) 0 \n UNKNOWN 0 (0.0%) 0 \n————————————————————————————————————————————————————————————————————————\n\n* Person time is the sum of exposure across all patients in unit: days.\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadex <- synthetic_cdisc_dataset(\"latest\", \"adex\")\nlabels <- var_labels(adex)\n\nset.seed(1, kind = \"Mersenne-Twister\")\nadex <- adex %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(\n PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\"\n ) %>%\n bind_rows(adex)\n\nvar_labels(adex) <- labels\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", adsl, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADEX\", adex,\n code = 'ADEX <- synthetic_cdisc_dataset(\"latest\", \"adex\")\n labels <- var_labels(ADEX)\n set.seed(1, kind = \"Mersenne-Twister\")\n ADEX <- ADEX %>%\n distinct(USUBJID, .keep_all = TRUE) %>%\n mutate(PARAMCD = \"TDURD\",\n PARAM = \"Overall duration (days)\",\n AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),\n AVALU = \"Days\") %>%\n bind_rows(ADEX)\n var_labels(ADEX) <- labels'\n ),\n check = TRUE\n ),\n modules = modules(\n tm_t_exposure(\n label = \"Duration of Exposure Table\",\n dataname = \"ADEX\",\n paramcd = choices_selected(\n choices = value_choices(adex, \"PARAMCD\", \"PARAM\"),\n selected = \"TDURD\"\n ),\n col_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"SEX\", \"ARM\")),\n selected = NULL\n ),\n row_by_var = choices_selected(\n choices = variable_choices(adex, subset = c(\"RACE\", \"STRATA1\", \"SEX\")),\n selected = \"RACE\"\n ),\n parcat = choices_selected(\n choices = value_choices(adex, \"PARCAT2\"),\n selected = \"Drug A\"\n ),\n add_total = FALSE\n )\n ),\n filter = list(\n ADSL = list(SAFFL = \"Y\")\n )\n)\n\n[INFO] 2023-09-09 18:23:35.5520 pid:8754 token:[] teal.modules.clinical Initializing tm_t_exposure\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] dplyr_1.1.2 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 fastmap_1.1.1 TH.data_1.1-2 \n [4] promises_1.2.1 shinyjs_2.1.0 digest_0.6.33 \n [7] estimability_1.4.1 mime_0.12 tern.gee_0.1.0.9008 \n[10] lifecycle_1.0.3 ellipsis_0.3.2 processx_3.8.2 \n[13] survival_3.5-7 compiler_4.3.1 sass_0.4.7 \n[16] rlang_1.1.1 tools_4.3.1 utf8_1.2.3 \n[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1 \n[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4 \n[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7 \n[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1 \n[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3 \n[40] rstudioapi_0.15.0 cachem_1.0.8 splines_4.3.1 \n[43] assertthat_0.2.1 vctrs_0.6.3 webshot_0.5.5 \n[46] Matrix_1.6-1 sandwich_3.0-2 jsonlite_1.8.7 \n[49] callr_3.7.3 teal.widgets_0.4.0.9007 testthat_3.1.10 \n[52] fontawesome_0.5.1 jquerylib_0.1.4 tidyr_1.3.0 \n[55] glue_1.6.2 ps_1.7.5 codetools_0.2-19 \n[58] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[61] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[64] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[67] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[70] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[73] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[76] httpuv_1.6.11 bslib_0.5.1 Rcpp_1.0.11 \n[79] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[82] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "tables/other/aovt03.html",
@@ -851,14 +851,14 @@
"href": "graphs/other/mng01.html",
"title": "MNG01",
"section": "",
- "text": "Data Setup\nPlot of Mean and CI\nPlot of Mean and CIs of Change from Baseline (Changing the Input Analysis Data Set and Analysis Variable)\nPlot of Mean (+/-SD) (Changing the Statistics)\nPlot of Mean and CI (Modify Alpha Level)\nPlot of Mean and CI (with Number of Patients only in Table Section)\nPlot of Mean and CI (with Table Section)\nPlot of Median and CI (Visits Condensed in Table Section)\nPlot of Mean and Upper Confidence Limit\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(nestcolor)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\n\nadsl_f <- adsl %>%\n filter(SAFFL == \"Y\") %>%\n df_explicit_na()\n\nadlb_f <- adlb %>%\n mutate(AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) %>%\n dplyr::filter(\n SAFFL == \"Y\",\n ANL01FL == \"Y\",\n ONTRTFL == \"Y\",\n PARAMCD == \"ALT\",\n AVISIT != \"SCREENING\"\n ) %>%\n droplevels() %>%\n df_explicit_na()\n\nadvs_f <- advs %>%\n mutate(AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) %>%\n dplyr::filter(\n SAFFL == \"Y\",\n ONTRTFL == \"Y\",\n PARAMCD == \"DIABP\",\n AVISIT != \"SCREENING\"\n ) %>%\n droplevels() %>%\n df_explicit_na()\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = advs_f,\n alt_counts_df = adsl_f,\n variables = control_lineplot_vars(y = \"CHG\"),\n title = \"Plot of Mean and 95% Confidence Intervals of Change from Baseline by Visit\",\n subtitle = \"Assessment:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n interval = \"mean_sdi\",\n whiskers = c(\"mean_sdi_lwr\", \"mean_sdi_upr\"),\n title = \"Plot of Mean (+/-SD)\",\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n control = control_analyze_vars(conf_level = 0.80),\n title = \"Plot of Mean and 80% Confidence Limits by Visit\",\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n table = \"n\",\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n table = c(\"n\", \"mean\", \"mean_ci\"),\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\nThis option is not supported.\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n whiskers = \"mean_ci_upr\",\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n mutate(AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", ADLB, code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n mutate(AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min))'),\n check = TRUE\n ),\n modules = modules(\n tm_g_lineplot(\n label = \"LINE PLOT\",\n dataname = \"ADLB\",\n strata = choices_selected(\n variable_choices(ADSL, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n y = choices_selected(\n variable_choices(ADLB, c(\"AVAL\", \"BASE\", \"CHG\", \"PCHG\")),\n \"AVAL\"\n ),\n param = choices_selected(\n value_choices(ADLB, \"PARAMCD\", \"PARAM\"),\n \"ALT\"\n )\n )\n )\n)\n\n[INFO] 2023-09-08 20:02:37.7263 pid:9846 token:[] teal.modules.clinical Initializing tm_g_lineplot\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] processx_3.8.2 survival_3.5-7 compiler_4.3.1 \n[16] sass_0.4.7 rlang_1.1.1 tools_4.3.1 \n[19] utf8_1.2.3 yaml_2.3.7 knitr_1.43 \n[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25 \n[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6 \n[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[31] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[34] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[37] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[40] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[43] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[46] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[49] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[52] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[55] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[58] ps_1.7.5 codetools_0.2-19 cowplot_1.1.1 \n[61] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[64] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[67] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[70] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[73] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[76] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[79] bslib_0.5.1 httpuv_1.6.11 Rcpp_1.0.11 \n[82] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[85] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[88] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nPlot of Mean and CI\nPlot of Mean and CIs of Change from Baseline (Changing the Input Analysis Data Set and Analysis Variable)\nPlot of Mean (+/-SD) (Changing the Statistics)\nPlot of Mean and CI (Modify Alpha Level)\nPlot of Mean and CI (with Number of Patients only in Table Section)\nPlot of Mean and CI (with Table Section)\nPlot of Median and CI (Visits Condensed in Table Section)\nPlot of Mean and Upper Confidence Limit\nteal App\nReproducibility\n\n\n\n\nCodelibrary(dplyr)\nlibrary(tern)\nlibrary(scda)\nlibrary(nestcolor)\n\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\nadvs <- synthetic_cdisc_dataset(\"latest\", \"advs\")\n\nadsl_f <- adsl %>%\n filter(SAFFL == \"Y\") %>%\n df_explicit_na()\n\nadlb_f <- adlb %>%\n mutate(AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) %>%\n dplyr::filter(\n SAFFL == \"Y\",\n ANL01FL == \"Y\",\n ONTRTFL == \"Y\",\n PARAMCD == \"ALT\",\n AVISIT != \"SCREENING\"\n ) %>%\n droplevels() %>%\n df_explicit_na()\n\nadvs_f <- advs %>%\n mutate(AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) %>%\n dplyr::filter(\n SAFFL == \"Y\",\n ONTRTFL == \"Y\",\n PARAMCD == \"DIABP\",\n AVISIT != \"SCREENING\"\n ) %>%\n droplevels() %>%\n df_explicit_na()\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = advs_f,\n alt_counts_df = adsl_f,\n variables = control_lineplot_vars(y = \"CHG\"),\n title = \"Plot of Mean and 95% Confidence Intervals of Change from Baseline by Visit\",\n subtitle = \"Assessment:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n interval = \"mean_sdi\",\n whiskers = c(\"mean_sdi_lwr\", \"mean_sdi_upr\"),\n title = \"Plot of Mean (+/-SD)\",\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n control = control_analyze_vars(conf_level = 0.80),\n title = \"Plot of Mean and 80% Confidence Limits by Visit\",\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n table = \"n\",\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n table = c(\"n\", \"mean\", \"mean_ci\"),\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\nThis option is not supported.\n\n\n\nCodeplot <- g_lineplot(\n df = adlb_f,\n alt_counts_df = adsl_f,\n whiskers = \"mean_ci_upr\",\n subtitle = \"Laboratory Test:\"\n)\nplot\n\n\n\n\n\n\n\nCodelibrary(scda)\nlibrary(dplyr)\nlibrary(teal.modules.clinical)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n mutate(AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min))\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADLB\", ADLB, code = 'ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n mutate(AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min))'),\n check = TRUE\n ),\n modules = modules(\n tm_g_lineplot(\n label = \"LINE PLOT\",\n dataname = \"ADLB\",\n strata = choices_selected(\n variable_choices(ADSL, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n y = choices_selected(\n variable_choices(ADLB, c(\"AVAL\", \"BASE\", \"CHG\", \"PCHG\")),\n \"AVAL\"\n ),\n param = choices_selected(\n value_choices(ADLB, \"PARAMCD\", \"PARAM\"),\n \"ALT\"\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:27:36.4428 pid:9861 token:[] teal.modules.clinical Initializing tm_g_lineplot\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 scda_0.1.6.9012 \n [9] tern_0.9.0.9002 rtables_0.6.3.9000 \n[11] magrittr_2.0.3 formatters_0.5.2.9001 \n[13] dplyr_1.1.2 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] processx_3.8.2 survival_3.5-7 compiler_4.3.1 \n[16] sass_0.4.7 rlang_1.1.1 tools_4.3.1 \n[19] utf8_1.2.3 yaml_2.3.7 knitr_1.43 \n[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25 \n[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6 \n[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[31] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[34] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[37] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[40] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[43] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[46] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[49] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[52] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[55] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[58] ps_1.7.5 codetools_0.2-19 cowplot_1.1.1 \n[61] gtable_0.3.3 later_1.3.1 shinycssloaders_1.0.0 \n[64] munsell_0.5.0 tibble_3.2.1 logger_0.2.2 \n[67] pillar_1.9.0 htmltools_0.5.6 brio_1.1.3 \n[70] R6_2.5.1 Rdpack_2.4 evaluate_0.21 \n[73] lattice_0.21-8 rbibutils_2.2.14 backports_1.4.1 \n[76] memoise_2.0.1 broom_1.0.5 teal.reporter_0.2.1 \n[79] bslib_0.5.1 httpuv_1.6.11 Rcpp_1.0.11 \n[82] coda_0.19-4 nlme_3.1-163 checkmate_2.2.0 \n[85] xfun_0.40 zoo_1.8-12 forcats_1.0.0 \n[88] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "graphs/other/cig01.html",
"href": "graphs/other/cig01.html",
"title": "CIG01",
"section": "",
- "text": "Data Setup\nPlot of Mean and 95% CIs for Mean\nPlot of Confidence Interval Using a Different Stratification Variable\nPlot of Median and 95% CIs for Median\nPlot of Median and 95% CIs for Median Using Different Alpha Level\nTable of Mean and Median\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(ggplot2)\nlibrary(dplyr)\nlibrary(scda)\nlibrary(nestcolor)\n\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n filter(PARAMCD == \"ALT\", AVISIT == \"BASELINE\")\n\n\n\n\nThe function stat_mean_ci from the tern package can be used with default values to draw the 95% confidence interval around the mean.\n\nCodeplot <- ggplot(\n data = adlb,\n mapping = aes(\n x = ARMCD, y = AVAL, color = SEX,\n lty = SEX, shape = SEX\n )\n) +\n stat_summary(\n fun.data = tern::stat_mean_ci,\n geom = \"errorbar\",\n width = 0.1,\n position = position_dodge(width = 0.5)\n ) +\n stat_summary(\n fun = mean,\n geom = \"point\",\n position = position_dodge(width = 0.5)\n ) +\n labs(\n title = \"Confidence Interval Plot by Treatment Group\",\n caption = \"Mean and 95% CIs for mean are displayed.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n )\nplot\n\n\n\n\n\n\n\nCodeplot <- ggplot(\n data = adlb,\n mapping = aes(\n x = ARMCD, y = AVAL, color = STRATA2,\n lty = STRATA2, shape = STRATA2\n )\n) +\n stat_summary(\n fun.data = tern::stat_mean_ci,\n geom = \"errorbar\",\n width = 0.1,\n position = position_dodge(width = 0.5)\n ) +\n stat_summary(\n fun = mean,\n geom = \"point\",\n position = position_dodge(width = 0.5)\n ) +\n labs(\n title = \"Confidence Interval Plot by Treatment Group\",\n caption = \"Mean and 95% CIs for mean are displayed.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n )\nplot\n\n\n\n\n\n\nThe function stat_median_ci from the tern package works similarly to stat_mean_ci.\n\nCodeplot <- ggplot(\n data = adlb,\n mapping = aes(\n x = ARMCD, y = AVAL, color = STRATA1,\n lty = STRATA1, shape = STRATA1\n )\n) +\n stat_summary(\n fun.data = stat_median_ci,\n geom = \"errorbar\",\n width = 0.1,\n position = position_dodge(width = 0.5)\n ) +\n stat_summary(\n fun = median,\n geom = \"point\",\n position = position_dodge(width = 0.5)\n ) +\n labs(\n title = \"Confidence Interval Plot by Treatment Group\",\n caption = \"Median and 95% CIs for median are displayed.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n )\n\n\n\n\nTo modify the confidence level for the estimation of the confidence interval, the call to stat_mean_ci (or stat_median_ci) can be slightly modified.\n\nCodeplot <- ggplot(\n data = adlb,\n mapping = aes(\n x = ARMCD, y = AVAL, color = SEX,\n lty = SEX, shape = SEX\n )\n) +\n stat_summary(\n fun.data = function(x) tern::stat_mean_ci(x, conf_level = 0.9),\n geom = \"errorbar\",\n width = 0.1,\n position = position_dodge(width = 0.5)\n ) +\n stat_summary(\n fun = mean,\n geom = \"point\",\n position = position_dodge(width = 0.5)\n ) +\n labs(\n title = \"Confidence Interval Plot by Treatment Group\",\n caption = \"Mean and 90% CIs for mean are displayed.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n )\n\n\n\n\nThe corresponding table is simply obtained using the rtables framework:\n\nCodelyt <- basic_table() %>%\n split_cols_by(var = \"ARMCD\") %>%\n analyze_vars(vars = \"AVAL\", .stats = c(\"mean_sd\", \"median\"))\ntable <- build_table(lyt = lyt, df = adlb)\ntable\n\n ARM A ARM B ARM C \n————————————————————————————————————————————————\nMean (SD) 17.7 (9.9) 18.7 (9.8) 19.5 (9.1)\nMedian 17.5 18.2 19.0 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL),\n cdisc_dataset(\"ADLB\", ADLB),\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")'\n ),\n modules = modules(\n tm_g_ci(\n label = \"Confidence Interval Plot\",\n x_var = data_extract_spec(\n dataname = \"ADSL\",\n select = select_spec(\n choices = c(\"ARMCD\", \"BMRKR2\"),\n selected = c(\"ARMCD\"),\n multiple = FALSE,\n fixed = FALSE\n )\n ),\n y_var = data_extract_spec(\n dataname = \"ADLB\",\n filter = list(\n filter_spec(\n vars = \"PARAMCD\",\n choices = levels(ADLB$PARAMCD),\n selected = levels(ADLB$PARAMCD)[1],\n multiple = FALSE,\n label = \"Select lab:\"\n ),\n filter_spec(\n vars = \"AVISIT\",\n choices = levels(ADLB$AVISIT),\n selected = levels(ADLB$AVISIT)[1],\n multiple = FALSE,\n label = \"Select visit:\"\n )\n ),\n select = select_spec(\n label = \"Analyzed Value\",\n choices = c(\"AVAL\", \"CHG\"),\n selected = \"AVAL\",\n multiple = FALSE,\n fixed = FALSE\n )\n ),\n color = data_extract_spec(\n dataname = \"ADSL\",\n select = select_spec(\n label = \"Color by variable\",\n choices = c(\"SEX\", \"STRATA1\", \"STRATA2\"),\n selected = c(\"STRATA1\"),\n multiple = FALSE,\n fixed = FALSE\n )\n )\n )\n ),\n header = \"Example of Confidence Interval Plot\",\n footer = tags$p(\n class = \"text-muted\", \"Source: `teal.modules.clinical::tm_g_ci`\"\n )\n)\n\n[INFO] 2023-09-08 20:03:42.0725 pid:10080 token:[] teal.modules.clinical Initializing tm_g_ci\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 scda_0.1.6.9012 \n [9] dplyr_1.1.2 ggplot2_3.4.3 \n[11] tern_0.9.0.9002 rtables_0.6.3.9000 \n[13] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] processx_3.8.2 survival_3.5-7 compiler_4.3.1 \n[16] sass_0.4.7 rlang_1.1.1 tools_4.3.1 \n[19] utf8_1.2.3 yaml_2.3.7 knitr_1.43 \n[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25 \n[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6 \n[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[31] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] splines_4.3.1 assertthat_0.2.1 vctrs_0.6.3 \n[46] webshot_0.5.5 Matrix_1.6-1 sandwich_3.0-2 \n[49] jsonlite_1.8.7 callr_3.7.3 teal.widgets_0.4.0.9007\n[52] testthat_3.1.10 fontawesome_0.5.1 jquerylib_0.1.4 \n[55] tidyr_1.3.0 glue_1.6.2 ps_1.7.5 \n[58] codetools_0.2-19 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nPlot of Mean and 95% CIs for Mean\nPlot of Confidence Interval Using a Different Stratification Variable\nPlot of Median and 95% CIs for Median\nPlot of Median and 95% CIs for Median Using Different Alpha Level\nTable of Mean and Median\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(ggplot2)\nlibrary(dplyr)\nlibrary(scda)\nlibrary(nestcolor)\n\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>%\n filter(PARAMCD == \"ALT\", AVISIT == \"BASELINE\")\n\n\n\n\nThe function stat_mean_ci from the tern package can be used with default values to draw the 95% confidence interval around the mean.\n\nCodeplot <- ggplot(\n data = adlb,\n mapping = aes(\n x = ARMCD, y = AVAL, color = SEX,\n lty = SEX, shape = SEX\n )\n) +\n stat_summary(\n fun.data = tern::stat_mean_ci,\n geom = \"errorbar\",\n width = 0.1,\n position = position_dodge(width = 0.5)\n ) +\n stat_summary(\n fun = mean,\n geom = \"point\",\n position = position_dodge(width = 0.5)\n ) +\n labs(\n title = \"Confidence Interval Plot by Treatment Group\",\n caption = \"Mean and 95% CIs for mean are displayed.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n )\nplot\n\n\n\n\n\n\n\nCodeplot <- ggplot(\n data = adlb,\n mapping = aes(\n x = ARMCD, y = AVAL, color = STRATA2,\n lty = STRATA2, shape = STRATA2\n )\n) +\n stat_summary(\n fun.data = tern::stat_mean_ci,\n geom = \"errorbar\",\n width = 0.1,\n position = position_dodge(width = 0.5)\n ) +\n stat_summary(\n fun = mean,\n geom = \"point\",\n position = position_dodge(width = 0.5)\n ) +\n labs(\n title = \"Confidence Interval Plot by Treatment Group\",\n caption = \"Mean and 95% CIs for mean are displayed.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n )\nplot\n\n\n\n\n\n\nThe function stat_median_ci from the tern package works similarly to stat_mean_ci.\n\nCodeplot <- ggplot(\n data = adlb,\n mapping = aes(\n x = ARMCD, y = AVAL, color = STRATA1,\n lty = STRATA1, shape = STRATA1\n )\n) +\n stat_summary(\n fun.data = stat_median_ci,\n geom = \"errorbar\",\n width = 0.1,\n position = position_dodge(width = 0.5)\n ) +\n stat_summary(\n fun = median,\n geom = \"point\",\n position = position_dodge(width = 0.5)\n ) +\n labs(\n title = \"Confidence Interval Plot by Treatment Group\",\n caption = \"Median and 95% CIs for median are displayed.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n )\n\n\n\n\nTo modify the confidence level for the estimation of the confidence interval, the call to stat_mean_ci (or stat_median_ci) can be slightly modified.\n\nCodeplot <- ggplot(\n data = adlb,\n mapping = aes(\n x = ARMCD, y = AVAL, color = SEX,\n lty = SEX, shape = SEX\n )\n) +\n stat_summary(\n fun.data = function(x) tern::stat_mean_ci(x, conf_level = 0.9),\n geom = \"errorbar\",\n width = 0.1,\n position = position_dodge(width = 0.5)\n ) +\n stat_summary(\n fun = mean,\n geom = \"point\",\n position = position_dodge(width = 0.5)\n ) +\n labs(\n title = \"Confidence Interval Plot by Treatment Group\",\n caption = \"Mean and 90% CIs for mean are displayed.\",\n x = \"Treatment Group\",\n y = paste0(adlb$PARAMCD[1], \" (\", adlb$AVALU[1], \")\")\n )\n\n\n\n\nThe corresponding table is simply obtained using the rtables framework:\n\nCodelyt <- basic_table() %>%\n split_cols_by(var = \"ARMCD\") %>%\n analyze_vars(vars = \"AVAL\", .stats = c(\"mean_sd\", \"median\"))\ntable <- build_table(lyt = lyt, df = adlb)\ntable\n\n ARM A ARM B ARM C \n————————————————————————————————————————————————\nMean (SD) 17.7 (9.9) 18.7 (9.8) 19.5 (9.1)\nMedian 17.5 18.2 19.0 \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL),\n cdisc_dataset(\"ADLB\", ADLB),\n code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\n ADLB <- synthetic_cdisc_dataset(\"latest\", \"adlb\")'\n ),\n modules = modules(\n tm_g_ci(\n label = \"Confidence Interval Plot\",\n x_var = data_extract_spec(\n dataname = \"ADSL\",\n select = select_spec(\n choices = c(\"ARMCD\", \"BMRKR2\"),\n selected = c(\"ARMCD\"),\n multiple = FALSE,\n fixed = FALSE\n )\n ),\n y_var = data_extract_spec(\n dataname = \"ADLB\",\n filter = list(\n filter_spec(\n vars = \"PARAMCD\",\n choices = levels(ADLB$PARAMCD),\n selected = levels(ADLB$PARAMCD)[1],\n multiple = FALSE,\n label = \"Select lab:\"\n ),\n filter_spec(\n vars = \"AVISIT\",\n choices = levels(ADLB$AVISIT),\n selected = levels(ADLB$AVISIT)[1],\n multiple = FALSE,\n label = \"Select visit:\"\n )\n ),\n select = select_spec(\n label = \"Analyzed Value\",\n choices = c(\"AVAL\", \"CHG\"),\n selected = \"AVAL\",\n multiple = FALSE,\n fixed = FALSE\n )\n ),\n color = data_extract_spec(\n dataname = \"ADSL\",\n select = select_spec(\n label = \"Color by variable\",\n choices = c(\"SEX\", \"STRATA1\", \"STRATA2\"),\n selected = c(\"STRATA1\"),\n multiple = FALSE,\n fixed = FALSE\n )\n )\n )\n ),\n header = \"Example of Confidence Interval Plot\",\n footer = tags$p(\n class = \"text-muted\", \"Source: `teal.modules.clinical::tm_g_ci`\"\n )\n)\n\n[INFO] 2023-09-09 18:28:55.4893 pid:10096 token:[] teal.modules.clinical Initializing tm_g_ci\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 scda_0.1.6.9012 \n [9] dplyr_1.1.2 ggplot2_3.4.3 \n[11] tern_0.9.0.9002 rtables_0.6.3.9000 \n[13] magrittr_2.0.3 formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] processx_3.8.2 survival_3.5-7 compiler_4.3.1 \n[16] sass_0.4.7 rlang_1.1.1 tools_4.3.1 \n[19] utf8_1.2.3 yaml_2.3.7 knitr_1.43 \n[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25 \n[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6 \n[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[31] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[34] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[37] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[40] generics_0.1.3 rstudioapi_0.15.0 cachem_1.0.8 \n[43] splines_4.3.1 assertthat_0.2.1 vctrs_0.6.3 \n[46] webshot_0.5.5 Matrix_1.6-1 sandwich_3.0-2 \n[49] jsonlite_1.8.7 callr_3.7.3 teal.widgets_0.4.0.9007\n[52] testthat_3.1.10 fontawesome_0.5.1 jquerylib_0.1.4 \n[55] tidyr_1.3.0 glue_1.6.2 ps_1.7.5 \n[58] codetools_0.2-19 gtable_0.3.3 later_1.3.1 \n[61] shinycssloaders_1.0.0 munsell_0.5.0 tibble_3.2.1 \n[64] logger_0.2.2 pillar_1.9.0 htmltools_0.5.6 \n[67] brio_1.1.3 R6_2.5.1 Rdpack_2.4 \n[70] evaluate_0.21 lattice_0.21-8 rbibutils_2.2.14 \n[73] backports_1.4.1 memoise_2.0.1 broom_1.0.5 \n[76] teal.reporter_0.2.1 bslib_0.5.1 httpuv_1.6.11 \n[79] Rcpp_1.0.11 coda_0.19-4 nlme_3.1-163 \n[82] checkmate_2.2.0 xfun_0.40 zoo_1.8-12 \n[85] pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "graphs/other/mmrmg02.html",
@@ -872,14 +872,14 @@
"href": "graphs/other/kmg01.html",
"title": "KMG01",
"section": "",
- "text": "Data Setup\nStandard Plot\nPlot of Failures\nPlot Without Comparative Statistics\nPlot Without Censoring Marks\nPlot Modifying Censoring Marks\nPlot Modifying Options for Statistics, Tie Handling, Stratification, etc.\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\nlibrary(nestcolor)\n\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\nanl <- adtte %>%\n dplyr::filter(PARAMCD == \"OS\") %>%\n dplyr::mutate(is_event = CNSR == 0)\nvariables <- list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARMCD\")\n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_coxph = TRUE\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.162] \n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n xlab = \"Time (Days)\",\n yval = \"Failure\",\n ylim = c(0, 1),\n annot_surv_med = TRUE,\n annot_coxph = TRUE,\n font_size = 7.5,\n position_coxph = c(0.3, 0),\n position_surv_med = c(0.9, 0.3)\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.312] \n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_surv_med = TRUE\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.436] \n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n censor_show = FALSE,\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_coxph = TRUE\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.572] \n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n pch = 1,\n size = 2,\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_coxph = TRUE\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.722] \n\n\n\n\n\nCodevariables$strat <- c(\"STRATA1\", \"STRATA2\")\nplot <- g_km(\n df = anl,\n variables = variables,\n control_surv = control_surv_timepoint(conf_level = 0.8),\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_coxph = TRUE,\n control_coxph_pw = control_coxph(\n pval_method = \"wald\",\n ties = \"breslow\",\n conf_level = 0.8\n )\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.872] \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADTTE\", ADTTE, code = 'ADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")'),\n check = TRUE\n ),\n modules = modules(\n tm_g_km(\n label = \"KM PLOT\",\n plot_height = c(600, 100, 2000),\n dataname = \"ADTTE\",\n arm_var = choices_selected(\n variable_choices(ADSL, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n paramcd = choices_selected(\n value_choices(ADTTE, \"PARAMCD\", \"PARAM\"),\n \"OS\"\n ),\n arm_ref_comp = arm_ref_comp,\n strata_var = choices_selected(\n variable_choices(ADSL, c(\"SEX\", \"BMRKR2\")),\n \"SEX\"\n ),\n facet_var = choices_selected(\n variable_choices(ADSL, c(\"SEX\", \"BMRKR2\")),\n NULL\n )\n )\n )\n)\n\n[INFO] 2023-09-08 20:05:51.9845 pid:10536 token:[] teal.modules.clinical Initializing tm_g_km\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 dplyr_1.1.2 \n [9] scda_0.1.6.9012 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] processx_3.8.2 survival_3.5-7 compiler_4.3.1 \n[16] sass_0.4.7 rlang_1.1.1 tools_4.3.1 \n[19] utf8_1.2.3 yaml_2.3.7 knitr_1.43 \n[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25 \n[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6 \n[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[31] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[34] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[37] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[40] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[43] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[46] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[49] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[52] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[55] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[58] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[61] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[64] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[67] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[70] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[73] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[76] broom_1.0.5 teal.reporter_0.2.1 bslib_0.5.1 \n[79] httpuv_1.6.11 Rcpp_1.0.11 coda_0.19-4 \n[82] gridExtra_2.3 nlme_3.1-163 checkmate_2.2.0 \n[85] xfun_0.40 zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Data Setup\nStandard Plot\nPlot of Failures\nPlot Without Comparative Statistics\nPlot Without Censoring Marks\nPlot Modifying Censoring Marks\nPlot Modifying Options for Statistics, Tie Handling, Stratification, etc.\nteal App\nReproducibility\n\n\n\n\nCodelibrary(tern)\nlibrary(scda)\nlibrary(dplyr)\nlibrary(nestcolor)\n\nadtte <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\nanl <- adtte %>%\n dplyr::filter(PARAMCD == \"OS\") %>%\n dplyr::mutate(is_event = CNSR == 0)\nvariables <- list(tte = \"AVAL\", is_event = \"is_event\", arm = \"ARMCD\")\n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_coxph = TRUE\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.162] \n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n xlab = \"Time (Days)\",\n yval = \"Failure\",\n ylim = c(0, 1),\n annot_surv_med = TRUE,\n annot_coxph = TRUE,\n font_size = 7.5,\n position_coxph = c(0.3, 0),\n position_surv_med = c(0.9, 0.3)\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.312] \n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_surv_med = TRUE\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.436] \n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n censor_show = FALSE,\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_coxph = TRUE\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.572] \n\n\n\n\n\nCodeplot <- g_km(\n df = anl,\n variables = variables,\n pch = 1,\n size = 2,\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_coxph = TRUE\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.722] \n\n\n\n\n\nCodevariables$strat <- c(\"STRATA1\", \"STRATA2\")\nplot <- g_km(\n df = anl,\n variables = variables,\n control_surv = control_surv_timepoint(conf_level = 0.8),\n xlab = \"Time (Days)\",\n ylim = c(0, 1),\n annot_coxph = TRUE,\n control_coxph_pw = control_coxph(\n pval_method = \"wald\",\n ties = \"breslow\",\n conf_level = 0.8\n )\n)\n\n\n\nCodeplot\n\ngTree[GRID.gTree.872] \n\n\n\n\n\nCodelibrary(teal.modules.clinical)\nlibrary(scda)\n\nADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")\nADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")\n\narm_ref_comp <- list(\n ACTARMCD = list(\n ref = \"ARM B\",\n comp = c(\"ARM A\", \"ARM C\")\n ),\n ARM = list(\n ref = \"B: Placebo\",\n comp = c(\"A: Drug X\", \"C: Combination\")\n )\n)\n\napp <- init(\n data = cdisc_data(\n cdisc_dataset(\"ADSL\", ADSL, code = 'ADSL <- synthetic_cdisc_dataset(\"latest\", \"adsl\")'),\n cdisc_dataset(\"ADTTE\", ADTTE, code = 'ADTTE <- synthetic_cdisc_dataset(\"latest\", \"adtte\")'),\n check = TRUE\n ),\n modules = modules(\n tm_g_km(\n label = \"KM PLOT\",\n plot_height = c(600, 100, 2000),\n dataname = \"ADTTE\",\n arm_var = choices_selected(\n variable_choices(ADSL, c(\"ARM\", \"ARMCD\", \"ACTARMCD\")),\n \"ARM\"\n ),\n paramcd = choices_selected(\n value_choices(ADTTE, \"PARAMCD\", \"PARAM\"),\n \"OS\"\n ),\n arm_ref_comp = arm_ref_comp,\n strata_var = choices_selected(\n variable_choices(ADSL, c(\"SEX\", \"BMRKR2\")),\n \"SEX\"\n ),\n facet_var = choices_selected(\n variable_choices(ADSL, c(\"SEX\", \"BMRKR2\")),\n NULL\n )\n )\n )\n)\n\n[INFO] 2023-09-09 18:31:43.0879 pid:10552 token:[] teal.modules.clinical Initializing tm_g_km\n\nCodeshinyApp(app$ui, app$server)\n\n\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005 \n [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012 \n [5] teal.data_0.3.0.9003 shiny_1.7.5 \n [7] nestcolor_0.1.2.9004 dplyr_1.1.2 \n [9] scda_0.1.6.9012 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] processx_3.8.2 survival_3.5-7 compiler_4.3.1 \n[16] sass_0.4.7 rlang_1.1.1 tools_4.3.1 \n[19] utf8_1.2.3 yaml_2.3.7 knitr_1.43 \n[22] labeling_0.4.2 htmlwidgets_1.6.2 multcomp_1.4-25 \n[25] withr_2.5.0 purrr_1.0.2 shinyWidgets_0.7.6 \n[28] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[31] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[34] ggplot2_3.4.3 emmeans_1.8.7 scales_1.2.1 \n[37] MASS_7.3-60 cli_3.6.1 mvtnorm_1.2-2 \n[40] rmarkdown_2.24 generics_0.1.3 rstudioapi_0.15.0 \n[43] cachem_1.0.8 splines_4.3.1 assertthat_0.2.1 \n[46] vctrs_0.6.3 webshot_0.5.5 Matrix_1.6-1 \n[49] sandwich_3.0-2 jsonlite_1.8.7 callr_3.7.3 \n[52] teal.widgets_0.4.0.9007 testthat_3.1.10 fontawesome_0.5.1 \n[55] jquerylib_0.1.4 tidyr_1.3.0 glue_1.6.2 \n[58] ps_1.7.5 codetools_0.2-19 gtable_0.3.3 \n[61] later_1.3.1 shinycssloaders_1.0.0 munsell_0.5.0 \n[64] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[67] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[70] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[73] rbibutils_2.2.14 backports_1.4.1 memoise_2.0.1 \n[76] broom_1.0.5 teal.reporter_0.2.1 bslib_0.5.1 \n[79] httpuv_1.6.11 Rcpp_1.0.11 coda_0.19-4 \n[82] gridExtra_2.3 nlme_3.1-163 checkmate_2.2.0 \n[85] xfun_0.40 zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "graphs/other/ltg01.html",
"href": "graphs/other/ltg01.html",
"title": "LTG01",
"section": "",
- "text": "Lattice plots are natively handled by R, the examples below rely mostly on the package ggplot2.\n\n\nData Setup\nPlot of Liver Function Tests\nPlot of Liver Function Tests Including Mean, Median, and 95% CIs\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(teal)\nlibrary(teal.modules.clinical)\nlibrary(ggplot2)\nlibrary(dplyr)\nlibrary(nestcolor)\n\n# Datasets\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:8)\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n\n# Pre-processing\nadlb$AVISIT_txt <- adlb$AVISIT\nadlb$AVISIT <- as.numeric(adlb$AVISIT)\nadlb$ARM_N <- adlb$ARM\nlevels(adlb$ARM_N) <- with(\n data = adlb,\n paste0(\n levels(ARM_N), \" (N = \",\n tapply(SUBJID, ARM_N, function(x) length(unique(x))), \")\"\n )\n)\n\n# Plot utils\nnpch <- 1:25\nnpatients <- length(unique(adlb$SUBJID))\npch <- c(\n rep(npch, times = npatients %/% length(npch)),\n npch[1:(npatients %% length(npch))]\n)\n\n# Add the mean along with the 95% CI at every visit.\nmean_95_text <- \"Mean +/- 95% CI\"\n# Add the median and 95% CI as follows.\nmedian_95_text <- \"Median +/- 95% CI\"\n# Add the median and 95% CI as follows.\nmedian_80_text <- \"Median +/- 80% CI\"\n\n\n\n\nBasic Plot\n\nCode# General mapping and \"lattice\" (\"facet\" in ggplot2 nomenclature).\ng1 <- {\n ggplot(\n data = adlb,\n mapping = aes(x = AVISIT, y = AVAL, colour = SUBJID, shape = SUBJID)\n ) +\n facet_grid(LBTESTCD ~ ARM, scales = \"free_y\") +\n scale_shape_manual(values = pch)\n}\n\n# Add points and lines.\ng1 <- g1 + geom_point()\ng1 <- g1 + geom_line()\nplot <- g1\nplot\n\n\n\n\nModifying Facets\nThe units describing rows of panes and the number of patients under each arm is specified by modifying facet_grid():\n\nCode# Include the units and the sample size N.\ng2 <- g1 + facet_grid(\n paste0(LBTESTCD, \"\\n(\", AVALU, \")\") ~ ARM_N,\n scales = \"free_y\"\n)\n\nplot <- g2\nplot\n\n\n\n\nModifying X-Axis\nThe graphic elements are modified through usual ggplot2 functions. For instance, the x-axis could be improved as follows:\n\nCodeg3 <- g2 + theme(\n axis.text.x = element_text(angle = 45, hjust = 1),\n axis.title = element_blank()\n) + scale_x_continuous(breaks = adlb$AVISIT, labels = adlb$AVISIT_txt)\n\nplot <- g3\nplot\n\n\n\n\n\n\n\nThe functions stat_mean_ci and stat_median_ci from the tern package allow the addition of mean and/or median confidence intervals. The example below suggests a larger dataset, where the individual subject legend may not be relevant but the mean or the median are of special interest.\nPre-Processing\n\nCode# Datasets\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:40)\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n\n# Pre-processing\nadlb$AVISIT_txt <- adlb$AVISIT\nadlb$AVISIT <- as.numeric(adlb$AVISIT)\nadlb$ARM_N <- adlb$ARM\nlevels(adlb$ARM_N) <- with(\n data = adlb,\n paste0(\n levels(ARM_N), \" (N = \",\n tapply(SUBJID, ARM_N, function(x) length(unique(x))), \")\"\n )\n)\n\n# Plot utils\nnpch <- 1:25\nnpatients <- length(unique(adlb$SUBJID))\npch <- c(\n rep(npch, times = npatients %/% length(npch)),\n npch[1:(npatients %% length(npch))]\n)\n\n\nBasic Plot\n\nCode# General mapping and \"lattice\" (\"facet\" in ggplot2 nomenclature)\ng4 <- {\n ggplot(\n data = adlb,\n mapping = aes(x = AVISIT, y = AVAL, colour = SUBJID, shape = SUBJID)\n ) +\n facet_grid(LBTESTCD ~ ARM_N, scales = \"free_y\") +\n scale_shape_manual(values = pch) +\n scale_color_manual(values = rep(getOption(\"ggplot2.discrete.colour\"), 2))\n}\n\n# Add points and lines.\n# Note that with so many patients, legend might not be useful and transparency\n# is advisable.\ng4 <- g4 + geom_point(alpha = .3)\ng4 <- g4 + geom_line(alpha = .3)\ng4 <- g4 + guides(colour = \"none\", shape = \"none\")\ng4 <- g4 + theme(\n axis.text.x = element_text(angle = 45, hjust = 1),\n axis.title = element_blank()\n)\ng4 <- g4 + scale_x_continuous(breaks = adlb$AVISIT, labels = adlb$AVISIT_txt)\nplot <- g4\nplot\n\n\n\n\nAdding Mean\n\nCodeg51 <- g4 + stat_summary(\n fun = mean, linewidth = 1, geom = \"line\",\n aes(group = 1, linetype = mean_95_text)\n)\ng51 <- g51 + stat_summary(\n fun.data = tern::stat_mean_ci, geom = \"errorbar\",\n aes(group = 1, linetype = mean_95_text)\n)\nplot <- g51\nplot\n\n\n\n\nAdding Median\n\nCode# Instead of a mean, the median could be more relevant.\ng52 <- g51 + stat_summary(\n fun = median, linewidth = 1, geom = \"line\",\n aes(group = 1, linetype = median_95_text)\n)\ng52 <- g52 + stat_summary(\n fun.data = tern::stat_median_ci, geom = \"errorbar\",\n aes(group = 1, linetype = median_95_text)\n)\nplot <- g52 + guides(linetype = guide_legend(title = \"Aggregate\"))\nplot\n\n\n\n\nChanging Confidence Level\n\nCode# Change the confidence level of interval for the median.\n# Note: check `?stat_mean_ci()` and `?stat_median_ci()` for further fine tuning.\ng53 <- g4 + stat_summary(\n fun = median, linewidth = 1, geom = \"line\",\n aes(group = 1, linetype = median_80_text)\n)\ng53 <- g53 + stat_summary(\n fun.data = function(x) tern::stat_median_ci(x, conf_level = 0.8),\n geom = \"errorbar\", aes(group = 1, linetype = median_80_text)\n)\nplot <- g53\nplot\n\n\n\n\n\n\n\n\nCode# In progress\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] nestcolor_0.1.2.9004 dplyr_1.1.2 \n [3] ggplot2_3.4.3 teal.modules.clinical_0.8.16.9003\n [5] teal_0.14.0.9005 teal.transform_0.4.0.9003 \n [7] teal.slice_0.4.0.9011 teal.data_0.3.0.9003 \n [9] shiny_1.7.5 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] tools_4.3.1 utf8_1.2.3 yaml_2.3.7 \n[19] knitr_1.43 labeling_0.4.2 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9000 xtable_1.8-4 colorspace_2.1-0 \n[31] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[34] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[37] generics_0.1.3 rstudioapi_0.15.0 splines_4.3.1 \n[40] assertthat_0.2.1 vctrs_0.6.3 Matrix_1.6-1 \n[43] sandwich_3.0-2 jsonlite_1.8.7 testthat_3.1.10 \n[46] tidyr_1.3.0 glue_1.6.2 codetools_0.2-19 \n[49] gtable_0.3.3 later_1.3.1 munsell_0.5.0 \n[52] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[55] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[58] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[61] rbibutils_2.2.14 backports_1.4.1 broom_1.0.5 \n[64] httpuv_1.6.11 Rcpp_1.0.11 coda_0.19-4 \n[67] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[70] zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
+ "text": "Lattice plots are natively handled by R, the examples below rely mostly on the package ggplot2.\n\n\nData Setup\nPlot of Liver Function Tests\nPlot of Liver Function Tests Including Mean, Median, and 95% CIs\nteal App\nReproducibility\n\n\n\n\nCodelibrary(scda)\nlibrary(tern)\nlibrary(teal)\nlibrary(teal.modules.clinical)\nlibrary(ggplot2)\nlibrary(dplyr)\nlibrary(nestcolor)\n\n# Datasets\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:8)\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n\n# Pre-processing\nadlb$AVISIT_txt <- adlb$AVISIT\nadlb$AVISIT <- as.numeric(adlb$AVISIT)\nadlb$ARM_N <- adlb$ARM\nlevels(adlb$ARM_N) <- with(\n data = adlb,\n paste0(\n levels(ARM_N), \" (N = \",\n tapply(SUBJID, ARM_N, function(x) length(unique(x))), \")\"\n )\n)\n\n# Plot utils\nnpch <- 1:25\nnpatients <- length(unique(adlb$SUBJID))\npch <- c(\n rep(npch, times = npatients %/% length(npch)),\n npch[1:(npatients %% length(npch))]\n)\n\n# Add the mean along with the 95% CI at every visit.\nmean_95_text <- \"Mean +/- 95% CI\"\n# Add the median and 95% CI as follows.\nmedian_95_text <- \"Median +/- 95% CI\"\n# Add the median and 95% CI as follows.\nmedian_80_text <- \"Median +/- 80% CI\"\n\n\n\n\nBasic Plot\n\nCode# General mapping and \"lattice\" (\"facet\" in ggplot2 nomenclature).\ng1 <- {\n ggplot(\n data = adlb,\n mapping = aes(x = AVISIT, y = AVAL, colour = SUBJID, shape = SUBJID)\n ) +\n facet_grid(LBTESTCD ~ ARM, scales = \"free_y\") +\n scale_shape_manual(values = pch)\n}\n\n# Add points and lines.\ng1 <- g1 + geom_point()\ng1 <- g1 + geom_line()\nplot <- g1\nplot\n\n\n\n\nModifying Facets\nThe units describing rows of panes and the number of patients under each arm is specified by modifying facet_grid():\n\nCode# Include the units and the sample size N.\ng2 <- g1 + facet_grid(\n paste0(LBTESTCD, \"\\n(\", AVALU, \")\") ~ ARM_N,\n scales = \"free_y\"\n)\n\nplot <- g2\nplot\n\n\n\n\nModifying X-Axis\nThe graphic elements are modified through usual ggplot2 functions. For instance, the x-axis could be improved as follows:\n\nCodeg3 <- g2 + theme(\n axis.text.x = element_text(angle = 45, hjust = 1),\n axis.title = element_blank()\n) + scale_x_continuous(breaks = adlb$AVISIT, labels = adlb$AVISIT_txt)\n\nplot <- g3\nplot\n\n\n\n\n\n\n\nThe functions stat_mean_ci and stat_median_ci from the tern package allow the addition of mean and/or median confidence intervals. The example below suggests a larger dataset, where the individual subject legend may not be relevant but the mean or the median are of special interest.\nPre-Processing\n\nCode# Datasets\nadsl <- synthetic_cdisc_dataset(\"latest\", \"adsl\") %>% slice(1:40)\nadlb <- synthetic_cdisc_dataset(\"latest\", \"adlb\") %>% filter(USUBJID %in% adsl$USUBJID)\n\n# Pre-processing\nadlb$AVISIT_txt <- adlb$AVISIT\nadlb$AVISIT <- as.numeric(adlb$AVISIT)\nadlb$ARM_N <- adlb$ARM\nlevels(adlb$ARM_N) <- with(\n data = adlb,\n paste0(\n levels(ARM_N), \" (N = \",\n tapply(SUBJID, ARM_N, function(x) length(unique(x))), \")\"\n )\n)\n\n# Plot utils\nnpch <- 1:25\nnpatients <- length(unique(adlb$SUBJID))\npch <- c(\n rep(npch, times = npatients %/% length(npch)),\n npch[1:(npatients %% length(npch))]\n)\n\n\nBasic Plot\n\nCode# General mapping and \"lattice\" (\"facet\" in ggplot2 nomenclature)\ng4 <- {\n ggplot(\n data = adlb,\n mapping = aes(x = AVISIT, y = AVAL, colour = SUBJID, shape = SUBJID)\n ) +\n facet_grid(LBTESTCD ~ ARM_N, scales = \"free_y\") +\n scale_shape_manual(values = pch) +\n scale_color_manual(values = rep(getOption(\"ggplot2.discrete.colour\"), 2))\n}\n\n# Add points and lines.\n# Note that with so many patients, legend might not be useful and transparency\n# is advisable.\ng4 <- g4 + geom_point(alpha = .3)\ng4 <- g4 + geom_line(alpha = .3)\ng4 <- g4 + guides(colour = \"none\", shape = \"none\")\ng4 <- g4 + theme(\n axis.text.x = element_text(angle = 45, hjust = 1),\n axis.title = element_blank()\n)\ng4 <- g4 + scale_x_continuous(breaks = adlb$AVISIT, labels = adlb$AVISIT_txt)\nplot <- g4\nplot\n\n\n\n\nAdding Mean\n\nCodeg51 <- g4 + stat_summary(\n fun = mean, linewidth = 1, geom = \"line\",\n aes(group = 1, linetype = mean_95_text)\n)\ng51 <- g51 + stat_summary(\n fun.data = tern::stat_mean_ci, geom = \"errorbar\",\n aes(group = 1, linetype = mean_95_text)\n)\nplot <- g51\nplot\n\n\n\n\nAdding Median\n\nCode# Instead of a mean, the median could be more relevant.\ng52 <- g51 + stat_summary(\n fun = median, linewidth = 1, geom = \"line\",\n aes(group = 1, linetype = median_95_text)\n)\ng52 <- g52 + stat_summary(\n fun.data = tern::stat_median_ci, geom = \"errorbar\",\n aes(group = 1, linetype = median_95_text)\n)\nplot <- g52 + guides(linetype = guide_legend(title = \"Aggregate\"))\nplot\n\n\n\n\nChanging Confidence Level\n\nCode# Change the confidence level of interval for the median.\n# Note: check `?stat_mean_ci()` and `?stat_median_ci()` for further fine tuning.\ng53 <- g4 + stat_summary(\n fun = median, linewidth = 1, geom = \"line\",\n aes(group = 1, linetype = median_80_text)\n)\ng53 <- g53 + stat_summary(\n fun.data = function(x) tern::stat_median_ci(x, conf_level = 0.8),\n geom = \"errorbar\", aes(group = 1, linetype = median_80_text)\n)\nplot <- g53\nplot\n\n\n\n\n\n\n\n\nCode# In progress\n\n\n\n\nSession Info\n\nCodesessionInfo()\n\nR version 4.3.1 (2023-06-16)\nPlatform: x86_64-pc-linux-gnu (64-bit)\nRunning under: Ubuntu 22.04.2 LTS\n\nMatrix products: default\nBLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 \nLAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0\n\nlocale:\n [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C \n [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 \n [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 \n [7] LC_PAPER=en_US.UTF-8 LC_NAME=C \n [9] LC_ADDRESS=C LC_TELEPHONE=C \n[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C \n\ntime zone: Etc/UTC\ntzcode source: system (glibc)\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n [1] nestcolor_0.1.2.9004 dplyr_1.1.2 \n [3] ggplot2_3.4.3 teal.modules.clinical_0.8.16.9003\n [5] teal_0.14.0.9005 teal.transform_0.4.0.9003 \n [7] teal.slice_0.4.0.9012 teal.data_0.3.0.9003 \n [9] shiny_1.7.5 tern_0.9.0.9002 \n[11] rtables_0.6.3.9000 magrittr_2.0.3 \n[13] formatters_0.5.2.9001 scda_0.1.6.9012 \n\nloaded via a namespace (and not attached):\n [1] tidyselect_1.2.0 farver_2.1.1 fastmap_1.1.1 \n [4] TH.data_1.1-2 promises_1.2.1 shinyjs_2.1.0 \n [7] digest_0.6.33 estimability_1.4.1 mime_0.12 \n[10] tern.gee_0.1.0.9008 lifecycle_1.0.3 ellipsis_0.3.2 \n[13] survival_3.5-7 compiler_4.3.1 rlang_1.1.1 \n[16] tools_4.3.1 utf8_1.2.3 yaml_2.3.7 \n[19] knitr_1.43 labeling_0.4.2 htmlwidgets_1.6.2 \n[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2 \n[25] geepack_1.3.9 grid_4.3.1 fansi_1.0.4 \n[28] teal.logger_0.1.3.9001 xtable_1.8-4 colorspace_2.1-0 \n[31] emmeans_1.8.7 scales_1.2.1 MASS_7.3-60 \n[34] cli_3.6.1 mvtnorm_1.2-2 rmarkdown_2.24 \n[37] generics_0.1.3 rstudioapi_0.15.0 splines_4.3.1 \n[40] assertthat_0.2.1 vctrs_0.6.3 Matrix_1.6-1 \n[43] sandwich_3.0-2 jsonlite_1.8.7 testthat_3.1.10 \n[46] tidyr_1.3.0 glue_1.6.2 codetools_0.2-19 \n[49] gtable_0.3.3 later_1.3.1 munsell_0.5.0 \n[52] tibble_3.2.1 logger_0.2.2 pillar_1.9.0 \n[55] htmltools_0.5.6 brio_1.1.3 R6_2.5.1 \n[58] Rdpack_2.4 evaluate_0.21 lattice_0.21-8 \n[61] rbibutils_2.2.14 backports_1.4.1 broom_1.0.5 \n[64] httpuv_1.6.11 Rcpp_1.0.11 coda_0.19-4 \n[67] nlme_3.1-163 checkmate_2.2.0 xfun_0.40 \n[70] zoo_1.8-12 pkgconfig_2.0.3 \n\n\n\n.lock file\nDownload the .lock file and use renv::restore() on it to recreate environment used to generate this website.\n\nCodeparent_file_path <- knitr::current_input(dir = TRUE)\n\nbook_root_dir <- parent_file_path\nwhile (!file.exists(file.path(book_root_dir, \"_quarto.yml\"))) book_root_dir <- dirname(book_root_dir)\n\nlock_path <- file.path(\"../../assets/www/lock\", paste0(gsub(file.path(book_root_dir, \"\"), \"\", gsub(\"\\\\.rmarkdown$\", \"\", knitr::current_input(dir = TRUE))), \".lock\"))\n\nwithr::with_options(\n list(renv.verbose = FALSE),\n renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)\n)\n\n\nDownload"
},
{
"objectID": "listings/pharmacokinetic/pkcl01.html",
diff --git a/sitemap.xml b/sitemap.xml
index 4c2c1de791..019cb5473f 100644
--- a/sitemap.xml
+++ b/sitemap.xml
@@ -2,570 +2,570 @@
https://insightsengineering.github.io/tlg-catalog/tlg-index.html
- 2023-09-08T20:09:48.100Z
+ 2023-09-09T18:36:44.051Z
https://insightsengineering.github.io/tlg-catalog/listings/other/vsl01.html
- 2023-09-08T20:09:44.352Z
+ 2023-09-09T18:36:39.067Z
https://insightsengineering.github.io/tlg-catalog/listings/other/lbl02b.html
- 2023-09-08T20:09:36.368Z
+ 2023-09-09T18:36:28.051Z
https://insightsengineering.github.io/tlg-catalog/listings/other/cml02a_gl.html
- 2023-09-08T20:09:28.680Z
+ 2023-09-09T18:36:17.791Z
https://insightsengineering.github.io/tlg-catalog/listings/other/ael03.html
- 2023-09-08T20:09:21.596Z
+ 2023-09-09T18:36:08.063Z
https://insightsengineering.github.io/tlg-catalog/listings/other/mhl01.html
- 2023-09-08T20:09:13.768Z
+ 2023-09-09T18:35:57.155Z
https://insightsengineering.github.io/tlg-catalog/listings/other/exl01.html
- 2023-09-08T20:09:06.092Z
+ 2023-09-09T18:35:46.663Z
https://insightsengineering.github.io/tlg-catalog/listings/other/oncl01.html
- 2023-09-08T20:08:57.884Z
+ 2023-09-09T18:35:35.778Z
https://insightsengineering.github.io/tlg-catalog/listings/other/ael02.html
- 2023-09-08T20:08:50.160Z
+ 2023-09-09T18:35:24.950Z
https://insightsengineering.github.io/tlg-catalog/listings/other/lbl01_rls.html
- 2023-09-08T20:08:42.697Z
+ 2023-09-09T18:35:14.654Z
https://insightsengineering.github.io/tlg-catalog/listings/other/ael01_nollt.html
- 2023-09-08T20:08:34.501Z
+ 2023-09-09T18:35:03.286Z
https://insightsengineering.github.io/tlg-catalog/listings/other/lbl01.html
- 2023-09-08T20:08:27.325Z
+ 2023-09-09T18:34:53.386Z
https://insightsengineering.github.io/tlg-catalog/listings/pharmacokinetic/pkcl02.html
- 2023-09-08T20:08:19.409Z
+ 2023-09-09T18:34:42.718Z
https://insightsengineering.github.io/tlg-catalog/listings/pharmacokinetic/adal02.html
- 2023-09-08T20:08:11.377Z
+ 2023-09-09T18:34:31.478Z
https://insightsengineering.github.io/tlg-catalog/listings/pharmacokinetic/pkpl02.html
- 2023-09-08T20:08:03.505Z
+ 2023-09-09T18:34:20.522Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/brg01.html
- 2023-09-08T20:07:55.649Z
+ 2023-09-09T18:34:09.662Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/fstg01.html
- 2023-09-08T20:07:17.381Z
+ 2023-09-09T18:33:18.506Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/ippg01.html
- 2023-09-08T20:05:42.022Z
+ 2023-09-09T18:31:29.421Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/bwg01.html
- 2023-09-08T20:04:31.730Z
+ 2023-09-09T18:29:56.660Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/mmrmg01.html
- 2023-09-08T20:03:36.723Z
+ 2023-09-09T18:28:47.356Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/fstg02.html
- 2023-09-08T20:02:27.327Z
+ 2023-09-09T18:27:21.067Z
https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkcg02.html
- 2023-09-08T20:01:33.832Z
+ 2023-09-09T18:26:14.647Z
https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkpg03.html
- 2023-09-08T20:01:13.976Z
+ 2023-09-09T18:25:47.138Z
https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkcg01.html
- 2023-09-08T20:00:53.196Z
+ 2023-09-09T18:25:18.054Z
https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkpg04.html
- 2023-09-08T20:00:31.020Z
+ 2023-09-09T18:24:46.130Z
https://insightsengineering.github.io/tlg-catalog/test-utils/save_results.html
- 2023-09-08T20:00:19.184Z
+ 2023-09-09T18:24:29.378Z
https://insightsengineering.github.io/tlg-catalog/tables/other/rmpt06.html
- 2023-09-08T20:00:05.292Z
+ 2023-09-09T18:24:10.061Z
https://insightsengineering.github.io/tlg-catalog/tables/other/rmpt04.html
- 2023-09-08T19:59:33.628Z
+ 2023-09-09T18:23:29.201Z
https://insightsengineering.github.io/tlg-catalog/tables/other/cmht01.html
- 2023-09-08T19:58:52.773Z
+ 2023-09-09T18:22:35.401Z
https://insightsengineering.github.io/tlg-catalog/tables/other/ratet01.html
- 2023-09-08T19:57:37.413Z
+ 2023-09-09T18:21:06.827Z
https://insightsengineering.github.io/tlg-catalog/tables/other/disclosurest01.html
- 2023-09-08T19:57:06.509Z
+ 2023-09-09T18:20:26.431Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/lgrt02.html
- 2023-09-08T19:56:33.498Z
+ 2023-09-09T18:19:41.927Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/aovt01.html
- 2023-09-08T19:55:22.706Z
+ 2023-09-09T18:18:15.998Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/mmrmt01.html
- 2023-09-08T19:54:07.547Z
+ 2023-09-09T18:16:46.358Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/dort01.html
- 2023-09-08T19:52:38.011Z
+ 2023-09-09T18:14:57.369Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/coxt02.html
- 2023-09-08T19:51:08.416Z
+ 2023-09-09T18:13:14.356Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkpt03.html
- 2023-09-08T19:49:50.625Z
+ 2023-09-09T18:11:43.500Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkpt07.html
- 2023-09-08T19:49:36.693Z
+ 2023-09-09T18:11:20.708Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkpt11.html
- 2023-09-08T19:49:24.089Z
+ 2023-09-09T18:11:00.615Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/adat03.html
- 2023-09-08T19:49:08.593Z
+ 2023-09-09T18:10:36.571Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/adat04a.html
- 2023-09-08T19:48:54.705Z
+ 2023-09-09T18:10:14.503Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/adat02.html
- 2023-09-08T19:48:41.501Z
+ 2023-09-09T18:09:53.211Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkpt02.html
- 2023-09-08T19:48:28.313Z
+ 2023-09-09T18:09:32.155Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet04.html
- 2023-09-08T19:48:15.330Z
+ 2023-09-09T18:09:11.438Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet04_pi.html
- 2023-09-08T19:47:00.830Z
+ 2023-09-09T18:07:35.486Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet10.html
- 2023-09-08T19:46:04.722Z
+ 2023-09-09T18:06:21.709Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet01_aesi.html
- 2023-09-08T19:45:04.083Z
+ 2023-09-09T18:05:07.444Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet05.html
- 2023-09-08T19:44:04.943Z
+ 2023-09-09T18:03:53.255Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet03.html
- 2023-09-08T19:43:10.708Z
+ 2023-09-09T18:02:42.578Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet02_smq.html
- 2023-09-08T19:42:01.192Z
+ 2023-09-09T18:01:13.214Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet05_all.html
- 2023-09-08T19:41:01.865Z
+ 2023-09-09T18:00:00.241Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/dst01.html
- 2023-09-08T19:40:16.045Z
+ 2023-09-09T17:59:01.185Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/cmt01a.html
- 2023-09-08T19:39:17.721Z
+ 2023-09-09T17:57:49.421Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/eudrat01.html
- 2023-09-08T19:38:13.406Z
+ 2023-09-09T17:56:29.784Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/egt02.html
- 2023-09-08T19:37:35.066Z
+ 2023-09-09T17:55:39.720Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/vst01.html
- 2023-09-08T19:36:26.886Z
+ 2023-09-09T17:54:17.487Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/vst02.html
- 2023-09-08T19:35:32.691Z
+ 2023-09-09T17:53:10.827Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/dmt01.html
- 2023-09-08T19:34:28.451Z
+ 2023-09-09T17:51:52.018Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/enrollment01.html
- 2023-09-08T19:33:46.424Z
+ 2023-09-09T17:50:57.930Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/pdt02.html
- 2023-09-08T19:32:46.240Z
+ 2023-09-09T17:49:33.981Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/cmt01b.html
- 2023-09-08T19:32:17.372Z
+ 2023-09-09T17:48:55.264Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt03.html
- 2023-09-08T19:31:44.233Z
+ 2023-09-09T17:48:11.012Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt14.html
- 2023-09-08T19:30:24.853Z
+ 2023-09-09T17:46:31.343Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt11.html
- 2023-09-08T19:29:10.838Z
+ 2023-09-09T17:45:00.882Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt08.html
- 2023-09-08T19:28:01.766Z
+ 2023-09-09T17:43:41.138Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt15.html
- 2023-09-08T19:27:47.122Z
+ 2023-09-09T17:43:18.649Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt10_bl.html
- 2023-09-08T19:27:12.154Z
+ 2023-09-09T17:42:32.785Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt12.html
- 2023-09-08T19:26:59.127Z
+ 2023-09-09T17:42:12.649Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt01.html
- 2023-09-08T19:26:44.875Z
+ 2023-09-09T17:41:50.317Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt04.html
- 2023-09-08T19:25:50.963Z
+ 2023-09-09T17:40:46.781Z
https://insightsengineering.github.io/tlg-catalog/index.html
- 2023-09-08T19:25:11.139Z
+ 2023-09-09T17:39:59.908Z
https://insightsengineering.github.io/tlg-catalog/appendix/reproducibility.html
- 2023-09-08T19:25:08.887Z
+ 2023-09-09T17:39:57.332Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt12_bl.html
- 2023-09-08T19:25:17.471Z
+ 2023-09-09T17:40:09.020Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt02.html
- 2023-09-08T19:26:12.911Z
+ 2023-09-09T17:41:13.513Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt05.html
- 2023-09-08T19:26:52.783Z
+ 2023-09-09T17:42:02.701Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt10.html
- 2023-09-08T19:27:05.594Z
+ 2023-09-09T17:42:22.641Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt06.html
- 2023-09-08T19:27:21.178Z
+ 2023-09-09T17:42:47.065Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt09.html
- 2023-09-08T19:27:55.322Z
+ 2023-09-09T17:43:31.401Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt07.html
- 2023-09-08T19:28:35.650Z
+ 2023-09-09T17:44:20.514Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt11_bl.html
- 2023-09-08T19:29:46.049Z
+ 2023-09-09T17:45:41.662Z
https://insightsengineering.github.io/tlg-catalog/tables/lab-results/lbt13.html
- 2023-09-08T19:31:21.617Z
+ 2023-09-09T17:47:42.652Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/eudrat02.html
- 2023-09-08T19:31:50.381Z
+ 2023-09-09T17:48:20.504Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/cmt01.html
- 2023-09-08T19:32:40.444Z
+ 2023-09-09T17:49:24.725Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/pdt01.html
- 2023-09-08T19:33:10.764Z
+ 2023-09-09T17:50:04.017Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/dtht01.html
- 2023-09-08T19:33:53.632Z
+ 2023-09-09T17:51:09.822Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/egt05_qtcat.html
- 2023-09-08T19:35:07.647Z
+ 2023-09-09T17:52:38.495Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/egt04.html
- 2023-09-08T19:35:39.171Z
+ 2023-09-09T17:53:21.663Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/egt03.html
- 2023-09-08T19:37:02.570Z
+ 2023-09-09T17:55:00.624Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/egt01.html
- 2023-09-08T19:38:06.902Z
+ 2023-09-09T17:56:19.104Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/cmt02_pt.html
- 2023-09-08T19:38:50.825Z
+ 2023-09-09T17:57:13.456Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/mht01.html
- 2023-09-08T19:39:42.437Z
+ 2023-09-09T17:58:21.249Z
https://insightsengineering.github.io/tlg-catalog/tables/safety/ext01.html
- 2023-09-08T19:40:39.029Z
+ 2023-09-09T17:59:31.257Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet09_smq.html
- 2023-09-08T19:41:27.448Z
+ 2023-09-09T18:00:32.434Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet02.html
- 2023-09-08T19:42:36.324Z
+ 2023-09-09T18:02:01.462Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet06.html
- 2023-09-08T19:43:44.043Z
+ 2023-09-09T18:03:26.971Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet09.html
- 2023-09-08T19:44:35.539Z
+ 2023-09-09T18:04:30.795Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet01.html
- 2023-09-08T19:45:31.187Z
+ 2023-09-09T18:05:41.840Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet07.html
- 2023-09-08T19:46:25.662Z
+ 2023-09-09T18:06:48.697Z
https://insightsengineering.github.io/tlg-catalog/tables/adverse-events/aet06_smq.html
- 2023-09-08T19:47:35.074Z
+ 2023-09-09T18:08:16.046Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkpt04.html
- 2023-09-08T19:48:21.937Z
+ 2023-09-09T18:09:21.915Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkpt05.html
- 2023-09-08T19:48:35.425Z
+ 2023-09-09T18:09:43.567Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkpt08.html
- 2023-09-08T19:48:47.617Z
+ 2023-09-09T18:10:02.791Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/adat04b.html
- 2023-09-08T19:49:01.613Z
+ 2023-09-09T18:10:25.543Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkct01.html
- 2023-09-08T19:49:17.693Z
+ 2023-09-09T18:10:50.751Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/pkpt06.html
- 2023-09-08T19:49:30.233Z
+ 2023-09-09T18:11:10.436Z
https://insightsengineering.github.io/tlg-catalog/tables/pharmacokinetic/adat01.html
- 2023-09-08T19:49:43.769Z
+ 2023-09-09T18:11:32.240Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/cfbt01.html
- 2023-09-08T19:50:22.908Z
+ 2023-09-09T18:12:21.764Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/rspt01.html
- 2023-09-08T19:51:44.720Z
+ 2023-09-09T18:13:57.277Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/ttet01.html
- 2023-09-08T19:53:20.791Z
+ 2023-09-09T18:15:48.841Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/coxt01.html
- 2023-09-08T19:54:42.770Z
+ 2023-09-09T18:17:28.538Z
https://insightsengineering.github.io/tlg-catalog/tables/efficacy/onct05.html
- 2023-09-08T19:56:01.790Z
+ 2023-09-09T18:19:02.578Z
https://insightsengineering.github.io/tlg-catalog/tables/other/rmpt03.html
- 2023-09-08T19:56:57.546Z
+ 2023-09-09T18:20:11.823Z
https://insightsengineering.github.io/tlg-catalog/tables/other/rmpt01.html
- 2023-09-08T19:57:30.009Z
+ 2023-09-09T18:20:55.535Z
https://insightsengineering.github.io/tlg-catalog/tables/other/aovt02.html
- 2023-09-08T19:58:12.593Z
+ 2023-09-09T18:21:47.988Z
https://insightsengineering.github.io/tlg-catalog/tables/other/rbmit01.html
- 2023-09-08T19:59:10.165Z
+ 2023-09-09T18:23:00.625Z
https://insightsengineering.github.io/tlg-catalog/tables/other/rmpt05.html
- 2023-09-08T19:59:56.992Z
+ 2023-09-09T18:23:57.449Z
https://insightsengineering.github.io/tlg-catalog/tables/other/aovt03.html
- 2023-09-08T20:00:17.568Z
+ 2023-09-09T18:24:27.034Z
https://insightsengineering.github.io/tlg-catalog/test-utils/envir_hook.html
- 2023-09-08T20:00:20.876Z
+ 2023-09-09T18:24:31.910Z
https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkcg03.html
- 2023-09-08T20:00:40.792Z
+ 2023-09-09T18:25:00.242Z
https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkpg06.html
- 2023-09-08T20:01:04.628Z
+ 2023-09-09T18:25:34.230Z
https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkpg01.html
- 2023-09-08T20:01:24.040Z
+ 2023-09-09T18:26:00.978Z
https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkpg02.html
- 2023-09-08T20:01:44.108Z
+ 2023-09-09T18:26:29.119Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/mng01.html
- 2023-09-08T20:02:54.911Z
+ 2023-09-09T18:27:56.496Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/cig01.html
- 2023-09-08T20:03:59.047Z
+ 2023-09-09T18:29:15.364Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/mmrmg02.html
- 2023-09-08T20:05:10.674Z
+ 2023-09-09T18:30:53.653Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/kmg01.html
- 2023-09-08T20:06:36.645Z
+ 2023-09-09T18:32:29.797Z
https://insightsengineering.github.io/tlg-catalog/graphs/other/ltg01.html
- 2023-09-08T20:07:41.757Z
+ 2023-09-09T18:33:51.454Z
https://insightsengineering.github.io/tlg-catalog/listings/pharmacokinetic/pkcl01.html
- 2023-09-08T20:07:59.361Z
+ 2023-09-09T18:34:14.822Z
https://insightsengineering.github.io/tlg-catalog/listings/pharmacokinetic/pkpl01.html
- 2023-09-08T20:08:07.609Z
+ 2023-09-09T18:34:26.210Z
https://insightsengineering.github.io/tlg-catalog/listings/pharmacokinetic/pkpl04.html
- 2023-09-08T20:08:15.557Z
+ 2023-09-09T18:34:37.306Z
https://insightsengineering.github.io/tlg-catalog/listings/other/cml01.html
- 2023-09-08T20:08:23.265Z
+ 2023-09-09T18:34:47.954Z
https://insightsengineering.github.io/tlg-catalog/listings/other/dsl01.html
- 2023-09-08T20:08:30.965Z
+ 2023-09-09T18:34:58.494Z
https://insightsengineering.github.io/tlg-catalog/listings/other/lbl02a_rls.html
- 2023-09-08T20:08:38.665Z
+ 2023-09-09T18:35:09.074Z
https://insightsengineering.github.io/tlg-catalog/listings/other/dsl02.html
- 2023-09-08T20:08:46.317Z
+ 2023-09-09T18:35:19.606Z
https://insightsengineering.github.io/tlg-catalog/listings/other/ael04.html
- 2023-09-08T20:08:53.816Z
+ 2023-09-09T18:35:30.250Z
https://insightsengineering.github.io/tlg-catalog/listings/other/egl01.html
- 2023-09-08T20:09:02.172Z
+ 2023-09-09T18:35:41.522Z
https://insightsengineering.github.io/tlg-catalog/listings/other/lbl02a.html
- 2023-09-08T20:09:10.060Z
+ 2023-09-09T18:35:51.991Z
https://insightsengineering.github.io/tlg-catalog/listings/other/ael02_ed.html
- 2023-09-08T20:09:17.796Z
+ 2023-09-09T18:36:02.823Z
https://insightsengineering.github.io/tlg-catalog/listings/other/ael01.html
- 2023-09-08T20:09:25.140Z
+ 2023-09-09T18:36:12.903Z
https://insightsengineering.github.io/tlg-catalog/listings/other/cml02b_gl.html
- 2023-09-08T20:09:32.368Z
+ 2023-09-09T18:36:22.699Z
https://insightsengineering.github.io/tlg-catalog/listings/other/dsur4.html
- 2023-09-08T20:09:39.984Z
+ 2023-09-09T18:36:33.099Z
https://insightsengineering.github.io/tlg-catalog/repro.html
- 2023-09-08T20:09:46.868Z
+ 2023-09-09T18:36:42.491Z
diff --git a/tables/adverse-events/aet01.html b/tables/adverse-events/aet01.html
index 149758de93..bd74b86769 100644
--- a/tables/adverse-events/aet01.html
+++ b/tables/adverse-events/aet01.html
@@ -1694,7 +1694,7 @@
)
)
@@ -1388,7 +1388,7 @@
other attached packages:
[1] teal.modules.clinical_0.8.16.9003 teal_0.14.0.9005
- [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9011
+ [3] teal.transform_0.4.0.9003 teal.slice_0.4.0.9012
[5] teal.data_0.3.0.9003 shiny_1.7.5
[7] tern_0.9.0.9002 rtables_0.6.3.9000
[9] magrittr_2.0.3 formatters_0.5.2.9001
@@ -1404,7 +1404,7 @@
[19] yaml_2.3.7 knitr_1.43 htmlwidgets_1.6.2
[22] multcomp_1.4-25 withr_2.5.0 purrr_1.0.2
[25] shinyWidgets_0.7.6 geepack_1.3.9 grid_4.3.1
-[28] fansi_1.0.4 teal.logger_0.1.3.9000 xtable_1.8-4
+[28] fansi_1.0.4 teal.logger_0.1.3.9001 xtable_1.8-4
[31] colorspace_2.1-0 ggplot2_3.4.3 emmeans_1.8.7
[34] scales_1.2.1 MASS_7.3-60 cli_3.6.1
[37] mvtnorm_1.2-2 rmarkdown_2.24 generics_0.1.3
diff --git a/tables/safety/vst02_files/figure-html/teal-1.png b/tables/safety/vst02_files/figure-html/teal-1.png
index aec306d053..ef7bbf656d 100644
Binary files a/tables/safety/vst02_files/figure-html/teal-1.png and b/tables/safety/vst02_files/figure-html/teal-1.png differ