Skip to content

Commit

Permalink
tdata to teal_data - tm_t_events_by_grade (#877)
Browse files Browse the repository at this point in the history
**Example App**
```

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  lbls_adae <- formatters::var_labels(tmc_ex_adae)
  ADAE <- tmc_ex_adae %>%
    dplyr::mutate_if(is.character, as.factor) #' be certain of having factors
  formatters::var_labels(ADAE) <- lbls_adae
})

datanames <- c("ADSL", "ADAE")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]

app <- init(
  data = data,
  modules = modules(
    tm_t_events_by_grade(
      label = "Adverse Events by Grade Table",
      dataname = "ADAE",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      llt = choices_selected(
        choices = variable_choices(data[["ADAE"]], c("AETERM", "AEDECOD")),
        selected = c("AEDECOD")
      ),
      hlt = choices_selected(
        choices = variable_choices(data[["ADAE"]], c("AEBODSYS", "AESOC")),
        selected = "AEBODSYS"
      ),
      grade = choices_selected(
        choices = variable_choices(data[["ADAE"]], c("AETOXGR", "AESEV")),
        selected = "AETOXGR"
      )
    )
  )
)
shinyApp(app$ui, app$server)
```
  • Loading branch information
kartikeyakirar authored Nov 23, 2023
1 parent 0c61d3b commit cf50017
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions R/tm_t_events_by_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,8 @@ srv_t_events_by_grade <- function(id,
basic_table_args) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "tdata")
checkmate::assert_class(data, "reactive")
checkmate::assert_class(isolate(data()), "teal_data")

shiny::moduleServer(id, function(input, output, session) {
selector_list <- teal.transform::data_extract_multiple_srv(
Expand Down Expand Up @@ -1046,19 +1047,17 @@ srv_t_events_by_grade <- function(id,
anl_inputs <- teal.transform::merge_expression_srv(
datasets = data,
selector_list = selector_list,
join_keys = teal.data::join_keys(data),
merge_function = "dplyr::inner_join"
)

adsl_inputs <- teal.transform::merge_expression_module(
datasets = data,
data_extract = list(arm_var = arm_var),
join_keys = teal.data::join_keys(data),
anl_name = "ANL_ADSL"
)

anl_q <- shiny::reactive({
teal.code::new_qenv(tdata2env(data), code = get_code_tdata(data)) %>%
data() %>%
teal.code::eval_code(as.expression(anl_inputs()$expr)) %>%
teal.code::eval_code(as.expression(adsl_inputs()$expr))
})
Expand Down

0 comments on commit cf50017

Please sign in to comment.