I think I realized what Mark is trying to accomplish, i had similar idea prior to shiny module becoming available.
below are modified code based on the above gist that allows user to do filtering more freely.
library(shiny)
dynamicSelectInput <- function(id, label, multiple = FALSE){
ns <- shiny::NS(id)
shiny::selectInput(ns("dynamic_select"), label,
choices = NULL, multiple = multiple, width = "100%")
}
#' Dynamical Update of a selectInput
#' @param the_data data.frame containing column of choices
#' @param column The column to select from
#' @param default_select The choices to select on load
dynamicSelect <- function(input, output, session, the_data, column, default_select = NULL){
## update input$dynamic_select
observe({
shiny::validate(
shiny::need(the_data(),"Fetching data")
)
dt <- the_data()
testthat::expect_is(dt, "data.frame")
testthat::expect_is(column, "character")
choice <- unique(dt[[column]])
updateSelectInput(session, "dynamic_select",
choices = choice,
selected = default_select)
})
return(reactive(input$dynamic_select))
}
#' Using Dynamic Input
#' @param id Shiny Id
#' @param aggs The Aggregation names
outerTableUI <- function(id, aggs){
ns <- shiny::NS(id)
tagList(
fluidRow(
lapply(seq_along(aggs), function(x) {
column(width = 4,
dynamicSelectInput(ns(aggs[[x]]), aggs[[x]], multiple = TRUE)
)
})
),
fluidRow(
## if this works should be able to filter this table
## by the selected filters above
tableOutput(ns("table"))
)
)
}
#' server side
#' @export
outerTable <- function(input, output, session, the_data, aggs){