Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce decorators for
tm_g_ci
(#1265)
Part of insightsengineering/teal#1371 WIP <details> <summary> Example with decorator </summary> ```r devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl ADLB <- tmc_ex_adlb }) join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADLB <- data[["ADLB"]] caption_decorator <- function(default_caption = "I am a good decorator", .var_to_replace = "plot") { teal_transform_module( label = "Caption", ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption), server = make_teal_transform_server( substitute({ .var_to_replace <- .var_to_replace + ggplot2::labs(caption = footnote) }, env = list(.var_to_replace = as.name(.var_to_replace))) ) ) } app <- init( data = data, modules = modules( tm_g_ci( label = "Confidence Interval Plot", x_var = data_extract_spec( dataname = "ADSL", select = select_spec( choices = c("ARMCD", "BMRKR2"), selected = c("ARMCD"), multiple = FALSE, fixed = FALSE ) ), y_var = data_extract_spec( dataname = "ADLB", filter = list( filter_spec( vars = "PARAMCD", choices = levels(ADLB$PARAMCD), selected = levels(ADLB$PARAMCD)[1], multiple = FALSE, label = "Select lab:" ), filter_spec( vars = "AVISIT", choices = levels(ADLB$AVISIT), selected = levels(ADLB$AVISIT)[1], multiple = FALSE, label = "Select visit:" ) ), select = select_spec( label = "Analyzed Value", choices = c("AVAL", "CHG"), selected = "AVAL", multiple = FALSE, fixed = FALSE ) ), color = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Color by variable", choices = c("SEX", "STRATA1", "STRATA2"), selected = c("STRATA1"), multiple = FALSE, fixed = FALSE ) ), decorators = list(caption_decorator(.var_to_replace = "plot")) ) ) ) shinyApp(app$ui, app$server) ``` </details> --------- Co-authored-by: Marcin <[email protected]> Co-authored-by: m7pr <[email protected]>
- Loading branch information