Teal module: Exposure Table for Risk management plan
Usage
tm_t_exposure(
label,
dataname,
parentname = ifelse(inherits(col_by_var, "data_extract_spec"),
teal.transform::datanames_input(col_by_var), "ADSL"),
row_by_var,
col_by_var,
paramcd = teal.transform::choices_selected(choices =
teal.transform::value_choices(dataname, "PARAMCD", "PARAM"), selected = "TDURD"),
paramcd_label = "PARAM",
id_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
subset = "USUBJID"), selected = "USUBJID", fixed = TRUE),
parcat,
aval_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
subset = "AVAL"), selected = "AVAL", fixed = TRUE),
avalu_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
subset = "AVALU"), selected = "AVALU", fixed = TRUE),
add_total,
na_level = "<Missing>",
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args()
)
Arguments
- label
(
character
)
menu item label of the module in the teal app.- dataname
(
character
)
analysis data used in teal module.- parentname
(
character
)
parent analysis data used in teal module, usually this refers toADSL
.- row_by_var
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
object with all available choices and preselected option for variable names that can be used to split rows.- col_by_var
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
object with all available choices and preselected option for variable names that can be used to split columns.- paramcd
(
choices_selected
ordata_extract_spec
)
variable value designating the studied parameter.- paramcd_label
(
character
)
the column from the dataset where the value will be used to label the argumentparamcd
.- id_var
(
choices_selected
ordata_extract_spec
)
object specifying the variable name for subject id.- parcat
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
object with all available choices and preselected option for parameter category values.- aval_var
(
choices_selected
ordata_extract_spec
)
object with all available choices and preselected option for the analysis variable.- avalu_var
(
teal.transform::choices_selected()
orteal.transform::data_extract_spec()
)
object with the analysis unit variable.- add_total
(
logical
)
whether to include column with total number of patients.- na_level
(
string
)
used to replace allNA
or empty values in character or factor variables in the data.- pre_output
optional, (
shiny.tag
)
with text placed before the output to put the output into context. For example a title.- post_output
optional, (
shiny.tag
)
with text placed after the output to put the output into context. For example theshiny::helpText()
elements are useful.- basic_table_args
-
optional, (
basic_table_args
)
object created byteal.widgets::basic_table_args()
with settings for the module table. The argument is merged with optionteal.basic_table_args
and with default module arguments (hard coded in the module body).For more details, see the vignette:
vignette("custom-basic-table-arguments", package = "teal.widgets")
.
Examples
library(scda)
library(dplyr)
synthetic_cdisc_data_latest <- synthetic_cdisc_data("latest")
adsl <- synthetic_cdisc_data_latest$adsl
adex <- synthetic_cdisc_data_latest$adex
set.seed(1, kind = "Mersenne-Twister")
labels <- formatters::var_labels(adex, fill = FALSE)
adex <- adex %>%
distinct(USUBJID, .keep_all = TRUE) %>%
mutate(
PARAMCD = "TDURD",
PARAM = "Overall duration (days)",
AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),
AVALU = "Days"
) %>%
bind_rows(adex)
formatters::var_labels(adex) <- labels
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", adsl,
code = "synthetic_cdisc_data_latest <- synthetic_cdisc_data('latest')
ADSL <- synthetic_cdisc_data_latest$adsl"
),
cdisc_dataset("ADEX", adex,
code = "set.seed(1, kind = 'Mersenne-Twister')
synthetic_cdisc_data_latest <- synthetic_cdisc_data('latest')
ADEX <- synthetic_cdisc_data_latest$adex
labels <- formatters::var_labels(ADEX, fill = FALSE)
ADEX <- ADEX %>%
distinct(USUBJID, .keep_all = TRUE) %>%
mutate(PARAMCD = 'TDURD',
PARAM = 'Overall duration (days)',
AVAL = sample(x = seq(1, 200), size = n(), replace = TRUE),
AVALU = 'Days') %>%
bind_rows(ADEX)
formatters::var_labels(ADEX) <- labels" # nolint
)
),
modules = modules(
tm_t_exposure(
label = "Duration of Exposure Table",
dataname = "ADEX",
paramcd = choices_selected(
choices = value_choices(adex, "PARAMCD", "PARAM"),
selected = "TDURD"
),
col_by_var = choices_selected(
choices = variable_choices(adex, subset = c("SEX", "ARM")),
selected = "SEX"
),
row_by_var = choices_selected(
choices = variable_choices(adex, subset = c("RACE", "REGION1", "STRATA1", "SEX")),
selected = "RACE"
),
parcat = choices_selected(
choices = value_choices(adex, "PARCAT2"),
selected = "Drug A"
),
add_total = FALSE
)
),
filter = list(
ADSL = list(SAFFL = "Y")
)
)
#> [INFO] 2022-10-14 09:10:49.3502 pid:3139 token:[] teal.modules.clinical Initializing tm_t_exposure
if (FALSE) {
shinyApp(app$ui, app$server)
}