Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce decorator for
tm_t_events_patyear
(#1277)
Part of insightsengineering/teal#1371 <details> <summary>Example with decorator</summary> ```r devtools::load_all("../tern") devtools::load_all("../teal") devtools::load_all(".") library(dplyr) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADAETTE <- tmc_ex_adaette %>% filter(PARAMCD %in% c("AETTE1", "AETTE2", "AETTE3")) %>% mutate(is_event = CNSR == 0) %>% mutate(n_events = as.integer(is_event)) }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADAETTE <- data[["ADAETTE"]] insert_rrow_decorator <- function(default_caption = "I am a good new row", .var_to_replace = "table") { teal_transform_module( label = "New row", ui = function(id) shiny::textInput(shiny::NS(id, "new_row"), "New row", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- rtables::insert_rrow(.var_to_replace, rtables::rrow(new_row)) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } # 1. Basic Example app <- init( data = data, modules = modules( tm_t_events_patyear( label = "AE Rate Adjusted for Patient-Years At Risk Table", dataname = "ADAETTE", arm_var = choices_selected( choices = variable_choices(ADSL, c("ARM", "ARMCD")), selected = "ARMCD" ), add_total = TRUE, events_var = choices_selected( choices = variable_choices(ADAETTE, "n_events"), selected = "n_events", fixed = TRUE ), paramcd = choices_selected( choices = value_choices(ADAETTE, "PARAMCD", "PARAM"), selected = "AETTE1" ), decorators = list(insert_rrow_decorator()) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details>