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_outliers
(#805)
Partner to insightsengineering/teal#1357 <details><summary>Working Example </summary> ```r devtools::load_all('../teal') devtools::load_all('.') # general data example data <- teal_data() data <- within(data, { CO2 <- CO2 CO2[["primary_key"]] <- seq_len(nrow(CO2)) }) join_keys(data) <- join_keys(join_key("CO2", "CO2", "primary_key")) vars <- choices_selected(variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment"))) boxplot_decorator <- teal_transform_module( label = "Footnote", ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Box plot Footnote", value = "BOX PLOT 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(), { if (exists("box_plot")) { footnote_str <- footnote box_plot <- box_plot + ggplot2::labs(caption = footnote_str) } }, footnote = input$footnote ) ) }) } ) cum_dist_decorator <- teal_transform_module( label = "Footnote", ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Cum dist Footnote", value = "CUM DIST 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(), { if (exists("cum_dist_plot")) { footnote_str <- footnote cum_dist_plot <- cum_dist_plot + ggplot2::labs(caption = footnote_str) } }, footnote = input$footnote ) ) }) } ) app <- init( data = data, modules = modules( tm_outliers( outlier_var = list( data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variable:", choices = variable_choices(data[["CO2"]], c("conc", "uptake")), selected = "uptake", multiple = FALSE, fixed = FALSE ) ) ), categorical_var = list( data_extract_spec( dataname = "CO2", filter = filter_spec( vars = vars, choices = value_choices(data[["CO2"]], vars$selected), selected = value_choices(data[["CO2"]], vars$selected), multiple = TRUE ) ) ), decorators = list(boxplot_decorator, cum_dist_decorator) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` <details> --------- Signed-off-by: André Veríssimo <[email protected]> Co-authored-by: André Veríssimo <[email protected]>
- Loading branch information