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_ipp
(#1263)
Part of insightsengineering/teal#1371 <details><summary> Working Example </summary> ```r devtools::load_all("../teal") devtools::load_all(".") library(nestcolor) library(dplyr) data <- teal_data() data <- within(data, { ADSL <- tmc_ex_adsl %>% slice(1:20) %>% df_explicit_na() ADLB <- tmc_ex_adlb %>% filter(USUBJID %in% ADSL$USUBJID) %>% df_explicit_na() %>% filter(AVISIT != "SCREENING") }) 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_ipp( label = "Individual Patient Plot", dataname = "ADLB", arm_var = choices_selected( value_choices(ADLB, "ARMCD"), "ARM A" ), paramcd = choices_selected( value_choices(ADLB, "PARAMCD"), "ALT" ), aval_var = choices_selected( variable_choices(ADLB, c("AVAL", "CHG")), "AVAL" ), avalu_var = choices_selected( variable_choices(ADLB, c("AVALU")), "AVALU", fixed = TRUE ), id_var = choices_selected( variable_choices(ADLB, c("USUBJID")), "USUBJID", fixed = TRUE ), visit_var = choices_selected( variable_choices(ADLB, c("AVISIT")), "AVISIT" ), baseline_var = choices_selected( variable_choices(ADLB, c("BASE")), "BASE", fixed = TRUE ), add_baseline_hline = FALSE, separate_by_obs = FALSE, decorators = list(caption_decorator(.var_to_replace = "plot")) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details>
- Loading branch information