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_scatterplotmatrix
(#808)
Part of insightsengineering/teal#1370 <details><summary> Working Example </summary> ```r pkgload::load_all("../teal") pkgload::load_all(".") 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(), { plot$xlab <- footnote }, footnote = input$footnote ) ) }) } ) # general data example data <- teal_data() data <- within(data, { countries <- data.frame( id = c("DE", "FR", "IT", "ES", "PT", "GR", "NL", "BE", "LU", "AT"), government = factor( c(2, 2, 2, 1, 2, 2, 1, 1, 1, 2), labels = c("Monarchy", "Republic") ), language_family = factor( c(1, 3, 3, 3, 3, 2, 1, 1, 3, 1), labels = c("Germanic", "Hellenic", "Romance") ), population = c(83, 67, 60, 47, 10, 11, 17, 11, 0.6, 9), area = c(357, 551, 301, 505, 92, 132, 41, 30, 2.6, 83), gdp = c(3.4, 2.7, 2.1, 1.4, 0.3, 0.2, 0.7, 0.5, 0.1, 0.4), debt = c(2.1, 2.3, 2.4, 2.6, 2.3, 2.4, 2.3, 2.4, 2.3, 2.4) ) sales <- data.frame( id = 1:50, country_id = sample( c("DE", "FR", "IT", "ES", "PT", "GR", "NL", "BE", "LU", "AT"), size = 50, replace = TRUE ), year = sort(sample(2010:2020, 50, replace = TRUE)), venue = sample(c("small", "medium", "large", "online"), 50, replace = TRUE), cancelled = sample(c(TRUE, FALSE), 50, replace = TRUE), quantity = rnorm(50, 100, 20), costs = rnorm(50, 80, 20), profit = rnorm(50, 20, 10) ) }) join_keys(data) <- join_keys( join_key("countries", "countries", "id"), join_key("sales", "sales", "id"), join_key("countries", "sales", c("id" = "country_id")) ) app <- init( data = data, modules = modules( tm_g_scatterplotmatrix( label = "Scatterplot matrix", variables = list( data_extract_spec( dataname = "countries", select = select_spec( label = "Select variables:", choices = variable_choices(data[["countries"]]), selected = c("area", "gdp", "debt"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ), data_extract_spec( dataname = "sales", filter = filter_spec( label = "Select variable:", vars = "country_id", choices = value_choices(data[["sales"]], "country_id"), selected = c("DE", "FR", "IT", "ES", "PT", "GR", "NL", "BE", "LU", "AT"), multiple = TRUE ), select = select_spec( label = "Select variables:", choices = variable_choices(data[["sales"]], c("quantity", "costs", "profit")), selected = c("quantity", "costs", "profit"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ) ), decorators = list(footnote_dec) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } ``` </details> --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: André Veríssimo <[email protected]>
- Loading branch information