Learn R Programming

shinyWidgets (version 0.4.3)

selectizeGroup-module: Selectize Group

Description

Group of mutually dependent `selectizeInput` for filtering data.frame's columns (like in Excel).

Usage

selectizeGroupUI(id, params, label = NULL, btn_label = "Reset filters")

selectizeGroupServer(input, output, session, data, vars)

Arguments

id

Module's id.

params

a named list of parameters passed to each `selectizeInput`, you can use : `inputId` (obligatory, must be variable name), `label`, `placeholder`.

label

character, global label on top of all labels.

btn_label

reset button label.

input

standard shiny input.

output

standard shiny output.

session

standard shiny session.

data

a data.frame, or an object coercible to data.frame.

vars

character, columns to use to create filters, must correspond to variables listed in params.

Value

a reactive function containing data filtered.

Examples

Run this code
# NOT RUN {
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(
        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"
      ),
      dataTableOutput(outputId = "table")
    )
  )
)

server <- function(input, output, session) {
  res_mod <- callModule(
    module = selectizeGroupServer,
    id = "my-filters",
    data = mpg,
    vars = c("manufacturer", "model", "trans", "class")
  )
  output$table <- renderDataTable(res_mod())
}

shinyApp(ui, server)

}

# }

Run the code above in your browser using DataLab