issues
search
insightsengineering
/
teal.modules.general
General Purpose Teal Modules
https://insightsengineering.github.io/teal.modules.general/
Other
9
stars
13
forks
source link
introduce decorators for `tm_g_distribution`
#801
Open
averissimo
opened
6 hours ago
averissimo
commented
6 hours ago
Part of
https://github.com/insightsengineering/teal/issues/1370
Working Example
```r pkgload::load_all("../teal") pkgload::load_all("../teal.modules.general") footnote_dec <- teal_transform_module( label = "Footnote", ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = "I am a good decorator"), server = function(id, data) { moduleServer(id, function(input, output, session) { logger::log_info("🟢 Footnote called to action!", namespace = "teal.modules.general") reactive( within( data(), { footnote_str <- footnote plot <- plot + ggplot2::labs(caption = footnote_str) }, footnote = input$footnote ) ) }) } ) table_dup_dec <- teal_transform_module( server = make_teal_transform_server( expression( logger::log_info("🔴 Table dup being called to action!", namespace = "teal.modules.general"), summary_table <- rbind(summary_table, summary_table), if (exists("test_table")) test_table <- rbind(test_table, test_table, test_table) ) ) ) # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] vars1 <- choices_selected( variable_choices(data[["ADSL"]], c("ARM", "COUNTRY", "SEX")), selected = NULL ) app <- init( data = data, modules = modules( tm_g_distribution( decorators = list(footnote_dec, table_dup_dec), dist_var = data_extract_spec( dataname = "ADSL", select = select_spec( choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE ) ), strata_var = data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars1, multiple = TRUE ) ), group_var = data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars1, multiple = TRUE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ```
Part of https://github.com/insightsengineering/teal/issues/1370
Working Example
```r pkgload::load_all("../teal") pkgload::load_all("../teal.modules.general") footnote_dec <- teal_transform_module( label = "Footnote", ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = "I am a good decorator"), server = function(id, data) { moduleServer(id, function(input, output, session) { logger::log_info("🟢 Footnote called to action!", namespace = "teal.modules.general") reactive( within( data(), { footnote_str <- footnote plot <- plot + ggplot2::labs(caption = footnote_str) }, footnote = input$footnote ) ) }) } ) table_dup_dec <- teal_transform_module( server = make_teal_transform_server( expression( logger::log_info("🔴 Table dup being called to action!", namespace = "teal.modules.general"), summary_table <- rbind(summary_table, summary_table), if (exists("test_table")) test_table <- rbind(test_table, test_table, test_table) ) ) ) # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] vars1 <- choices_selected( variable_choices(data[["ADSL"]], c("ARM", "COUNTRY", "SEX")), selected = NULL ) app <- init( data = data, modules = modules( tm_g_distribution( decorators = list(footnote_dec, table_dup_dec), dist_var = data_extract_spec( dataname = "ADSL", select = select_spec( choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE ) ), strata_var = data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars1, multiple = TRUE ) ), group_var = data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars1, multiple = TRUE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ```