0

When following the example in the ShinyWidgets documentation for the selectizegroup module, I cannot produce a table with a reactive data set. https://dreamrs.github.io/shinyWidgets/reference/selectizeGroup-module.html

Example here:

if (interactive()) {

  library(shiny)
  library(shinyWidgets)

  data("mpg", package = "ggplot2")

  ui <- fluidPage(
    fluidRow(
      column(
        width = 10, offset = 1,
        tags$h3("Filter data with selectize group"),
        panel(
          pickerInput(
            inputId = "car_select",
            choices = unique(mpg$manufacturer),
            options = list(
              `live-search` = TRUE,
              title = "None selected"
            )
          ),
          selectizeGroupUI(
            id = "my-filters",
            params = list(
              manufacturer = list(inputId = "manufacturer", title = "Manufacturer:"),
              model = list(inputId = "model", title = "Model:"),
              trans = list(inputId = "trans", title = "Trans:"),
              class = list(inputId = "class", title = "Class:")
            )
          ),
          status = "primary"
        ),
        DT::dataTableOutput(outputId = "table")
      )
    )
  )

  server <- function(input, output, session) {

    mpg_filter <- reactive({
      subset(mpg, manufacturer %in% input$car_select)
    })

    res_mod <- callModule(
      module = selectizeGroupServer,
      id = "my-filters",
      data = mpg_filter,
      vars = c("manufacturer", "model", "trans", "class")
    )

    output$table <- DT::renderDataTable({
      req(res_mod())
      res_mod()
    })
  }

  shinyApp(ui, server)
}

The example with the non-reactive dataset does work for me. Here's what I get:

screenshot

Is anyone else having trouble with this? Or am I missing something?

  • 2
    works fine for me. – YBS Oct 31 '22 at 17:52
  • That is just the landing page as nothing has been selected yet. Please select a value in the dropdown where it says "None selected". Alternatively add this line `selected = "audi",` between lines `choices = unique(mpg$manufacturer),` and `options = list(`. This will start the app with a car manufacturer selected. – Eli Berkow Nov 01 '22 at 11:02
  • Is it possible to set in `selectizeGroupUI` e.g. `selected = "audi"`? – Zizou Nov 10 '22 at 10:30

0 Answers0