Skip to contents

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,
  total_label = "All Patients",
  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 to ADSL.

row_by_var

(teal.transform::choices_selected() or teal.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() or teal.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 or data_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 argument paramcd.

id_var

(choices_selected or data_extract_spec)
object specifying the variable name for subject id.

parcat

(teal.transform::choices_selected() or teal.transform::data_extract_spec())
object with all available choices and preselected option for parameter category values.

aval_var

(choices_selected or data_extract_spec)
object with all available choices and preselected option for the analysis variable.

avalu_var

(teal.transform::choices_selected() or teal.transform::data_extract_spec())
object with the analysis unit variable.

add_total

(logical)
whether to include column with total number of patients.

total_label

(string)
string to display as total column/row label if column/row is enabled (see add_total).

na_level

(string)
used to replace all NA 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 the shiny::helpText() elements are useful.

basic_table_args

optional, (basic_table_args)
object created by teal.widgets::basic_table_args() with settings for the module table. The argument is merged with option teal.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

adsl <- tmc_ex_adsl
adex <- tmc_ex_adex

set.seed(1, kind = "Mersenne-Twister")
labels <- formatters::var_labels(adex, fill = FALSE)
adex <- adex %>%
  dplyr::distinct(USUBJID, .keep_all = TRUE) %>%
  dplyr::mutate(
    PARAMCD = "TDURD",
    PARAM = "Overall duration (days)",
    AVAL = sample(x = seq(1, 200), size = dplyr::n(), replace = TRUE),
    AVALU = "Days"
  ) %>%
  dplyr::bind_rows(adex)
formatters::var_labels(adex) <- labels

app <- init(
  data = cdisc_data(
    cdisc_dataset("ADSL", adsl),
    cdisc_dataset("ADEX", adex)
  ),
  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] 2023-08-14 14:44:19.9558 pid:1183 token:[] teal.modules.clinical Initializing tm_t_exposure
if (interactive()) {
  shinyApp(app$ui, app$server)
}