View source: R/tm_t_events_summary.R
tm_t_events_summary | R Documentation |
This module produces an adverse events summary table.
tm_t_events_summary(
label,
dataname,
parentname = ifelse(inherits(arm_var, "data_extract_spec"),
teal.transform::datanames_input(arm_var), "ADSL"),
arm_var,
flag_var_anl = NULL,
flag_var_aesi = NULL,
dthfl_var =
teal.transform::choices_selected(teal.transform::variable_choices(parentname,
"DTHFL"), "DTHFL", fixed = TRUE),
dcsreas_var =
teal.transform::choices_selected(teal.transform::variable_choices(parentname,
"DCSREAS"), "DCSREAS", fixed = TRUE),
llt = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
"AEDECOD"), "AEDECOD", fixed = TRUE),
aeseq_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
"AESEQ"), "AESEQ", fixed = TRUE),
add_total = TRUE,
total_label = default_total_label(),
na_level = default_na_str(),
count_dth = TRUE,
count_wd = TRUE,
count_subj = TRUE,
count_pt = TRUE,
count_events = TRUE,
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args(),
transformators = list(),
decorators = list()
)
a teal_module
object.
This module generates the following objects, which can be modified in place using decorators:
table
(TableTree
as created from rtables::build_table
)
A Decorator is applied to the specific output using a named list of teal_transform_module
objects.
The name of this list corresponds to the name of the output to which the decorator is applied.
See code snippet below:
tm_t_events_summary( ..., # arguments for module decorators = list( table = teal_transform_module(...) # applied only to `table` output ) )
For additional details and examples of decorators, refer to the vignette
vignette("decorate-module-output", package = "teal.modules.clinical")
.
To learn more please refer to the vignette
vignette("transform-module-output", package = "teal")
or the teal::teal_transform_module()
documentation.
The TLG Catalog where additional example apps implementing this module can be found.
library(dplyr)
data <- teal_data()
data <- within(data, {
ADSL <- tmc_ex_adsl %>%
mutate(
DTHFL = case_when(
!is.na(DTHDT) ~ "Y",
TRUE ~ ""
) %>% with_label("Subject Death Flag")
)
ADAE <- tmc_ex_adae
.add_event_flags <- function(dat) {
dat <- dat %>%
mutate(
TMPFL_SER = AESER == "Y",
TMPFL_REL = AEREL == "Y",
TMPFL_GR5 = AETOXGR == "5",
TMP_SMQ01 = !is.na(SMQ01NAM),
TMP_SMQ02 = !is.na(SMQ02NAM),
TMP_CQ01 = !is.na(CQ01NAM)
)
column_labels <- list(
TMPFL_SER = "Serious AE",
TMPFL_REL = "Related AE",
TMPFL_GR5 = "Grade 5 AE",
TMP_SMQ01 = aesi_label(dat[["SMQ01NAM"]], dat[["SMQ01SC"]]),
TMP_SMQ02 = aesi_label("Y.9.9.9.9/Z.9.9.9.9 AESI"),
TMP_CQ01 = aesi_label(dat[["CQ01NAM"]])
)
col_labels(dat)[names(column_labels)] <- as.character(column_labels)
dat
}
#' Generating user-defined event flags.
ADAE <- ADAE %>% .add_event_flags()
.ae_anl_vars <- names(ADAE)[startsWith(names(ADAE), "TMPFL_")]
.aesi_vars <- names(ADAE)[startsWith(names(ADAE), "TMP_")]
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_t_events_summary(
label = "Adverse Events Summary",
dataname = "ADAE",
arm_var = choices_selected(
choices = variable_choices("ADSL", c("ARM", "ARMCD")),
selected = "ARM"
),
flag_var_anl = choices_selected(
choices = variable_choices("ADAE", data[[".ae_anl_vars"]]),
selected = data[[".ae_anl_vars"]][1],
keep_order = TRUE,
fixed = FALSE
),
flag_var_aesi = choices_selected(
choices = variable_choices("ADAE", data[[".aesi_vars"]]),
selected = data[[".aesi_vars"]][1],
keep_order = TRUE,
fixed = FALSE
),
add_total = TRUE
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.