KMG01
Kaplan-Meier Plot
Code
variables$strata <- c("STRATA1", "STRATA2")
plot <- g_km(
df = anl,
variables = variables,
control_surv = control_surv_timepoint(conf_level = 0.8),
xlab = "Time (Days)",
ylim = c(0, 1),
annot_coxph = TRUE,
control_coxph_pw = control_coxph(
pval_method = "wald",
ties = "breslow",
conf_level = 0.8
)
)
plot
Code
library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)
ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADTTE <- synthetic_cdisc_dataset("latest", "adtte")
})
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
arm_ref_comp <- list(
ACTARMCD = list(
ref = "ARM B",
comp = c("ARM A", "ARM C")
),
ARM = list(
ref = "B: Placebo",
comp = c("A: Drug X", "C: Combination")
)
)
## Reusable Configuration For Modules
ADSL <- data[["ADSL"]]
ADTTE <- data[["ADTTE"]]
## Setup App
app <- init(
data = data,
modules = modules(
tm_g_km(
label = "KM PLOT",
plot_height = c(600, 100, 2000),
dataname = "ADTTE",
arm_var = choices_selected(
variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
"ARM"
),
paramcd = choices_selected(
value_choices(ADTTE, "PARAMCD", "PARAM"),
"OS"
),
arm_ref_comp = arm_ref_comp,
strata_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
"SEX"
),
facet_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
NULL
)
)
)
)
shinyApp(app$ui, app$server)
Experimental use!
shinylive
allow you to modify to run shiny
application entirely in the web browser. Modify the code below and click re-run the app to see the results. The performance is slighly worse and some of the features (e.g. downloading) might not work at all.
#| standalone: true
#| viewerHeight: 800
#| components: [viewer, editor]
#| layout: vertical
# -- WEBR HELPERS --
options(webr_pkg_repos = c("r-universe" = "https://insightsengineering.r-universe.dev", getOption("webr_pkg_repos")))
if (packageVersion("webr") < "0.3.0") {
.e <- as.environment("webr_shims")
.e[["library"]] <- function(pkg, ...) {
package <- as.character(substitute(pkg))
if (length(find.package(package, quiet = TRUE)) == 0) {
webr::install(package)
}
base::library(package, character.only = TRUE, ...)
}
}
# -- APP CODE --
library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
library(scda)
library(scda.2022)
ADSL <- synthetic_cdisc_dataset("latest", "adsl")
ADTTE <- synthetic_cdisc_dataset("latest", "adtte")
})
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
arm_ref_comp <- list(
ACTARMCD = list(
ref = "ARM B",
comp = c("ARM A", "ARM C")
),
ARM = list(
ref = "B: Placebo",
comp = c("A: Drug X", "C: Combination")
)
)
## Reusable Configuration For Modules
ADSL <- data[["ADSL"]]
ADTTE <- data[["ADTTE"]]
## Setup App
app <- init(
data = data,
modules = modules(
tm_g_km(
label = "KM PLOT",
plot_height = c(600, 100, 2000),
dataname = "ADTTE",
arm_var = choices_selected(
variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
"ARM"
),
paramcd = choices_selected(
value_choices(ADTTE, "PARAMCD", "PARAM"),
"OS"
),
arm_ref_comp = arm_ref_comp,
strata_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
"SEX"
),
facet_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
NULL
)
)
)
)
shinyApp(app$ui, app$server)
Timestamp
Session Info
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
locale:
[1] C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] teal.modules.clinical_0.9.1 teal.transform_0.5.0
[3] teal_0.15.2 teal.slice_0.5.1
[5] teal.data_0.6.0 teal.code_0.5.0
[7] shiny_1.8.1.1 nestcolor_0.1.2
[9] dplyr_1.1.4 scda.2022_0.1.5
[11] scda_0.1.6 tern_0.9.4
[13] rtables_0.6.7 magrittr_2.0.3
[15] formatters_0.5.6
loaded via a namespace (and not attached):
[1] Rdpack_2.6 formatR_1.14 tern.gee_0.1.3
[4] logger_0.3.0 testthat_3.2.1.1 sandwich_3.1-0
[7] rlang_1.1.3 multcomp_1.4-25 compiler_4.4.0
[10] systemfonts_1.0.6 callr_3.7.6 vctrs_0.6.5
[13] pkgconfig_2.0.3 fastmap_1.1.1 backports_1.4.1
[16] fontawesome_0.5.2 labeling_0.4.3 utf8_1.2.4
[19] promises_1.3.0 rmarkdown_2.26 ps_1.7.6
[22] ragg_1.3.1 purrr_1.0.2 xfun_0.43
[25] shinyvalidate_0.1.3 cachem_1.0.8 teal.reporter_0.3.1
[28] jsonlite_1.8.8 later_1.3.2 broom_1.0.5
[31] R6_2.5.1 bslib_0.7.0 brio_1.1.5
[34] jquerylib_0.1.4 estimability_1.5 Rcpp_1.0.12
[37] knitr_1.46 zoo_1.8-12 teal.logger_0.2.0
[40] httpuv_1.6.15 Matrix_1.7-0 splines_4.4.0
[43] tidyselect_1.2.1 yaml_2.3.8 codetools_0.2-20
[46] websocket_1.4.1 processx_3.8.4 teal.widgets_0.4.2
[49] lattice_0.22-6 tibble_3.2.1 withr_3.0.0
[52] coda_0.19-4.1 evaluate_0.23 survival_3.6-4
[55] pillar_1.9.0 shinycssloaders_1.0.0 checkmate_2.3.1
[58] shinyjs_2.1.0 generics_0.1.3 chromote_0.2.0
[61] ggplot2_3.5.1 munsell_0.5.1 scales_1.3.0
[64] xtable_1.8-4 glue_1.7.0 emmeans_1.10.1
[67] tools_4.4.0 webshot2_0.1.1 webshot_0.5.5
[70] mvtnorm_1.2-4 cowplot_1.1.3 grid_4.4.0
[73] tidyr_1.3.1 rbibutils_2.2.16 colorspace_2.1-0
[76] nlme_3.1-164 cli_3.6.2 textshaping_0.3.7
[79] fansi_1.0.6 geepack_1.3.10 gtable_0.3.5
[82] sass_0.4.9 digest_0.6.35 TH.data_1.1-2
[85] htmlwidgets_1.6.4 farver_2.1.1 memoise_2.0.1
[88] htmltools_0.5.8.1 lifecycle_1.0.4 shinyWidgets_0.8.6
[91] mime_0.12 MASS_7.3-60.2
.lock
file
Download the .lock
file and use renv::restore()
on it to recreate environment used to generate this website.
Code
parent_file_path <- knitr::current_input(dir = TRUE)
book_root_dir <- parent_file_path
while (!file.exists(file.path(book_root_dir, "_quarto.yml"))) book_root_dir <- dirname(book_root_dir)
lock_path <- file.path(
"../../assets/www/lock",
paste0(
gsub(
file.path(book_root_dir, ""),
"",
gsub(
"\\.rmarkdown$",
"",
knitr::current_input(dir = TRUE)
)
),
".lock"
)
)
withr::with_options(
list(renv.verbose = FALSE),
renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)
)