select-group {datamods} | R Documentation |
Select Group Input Module
Description
Group of mutually dependent select menus for filtering data.frame
's columns (like in Excel).
Usage
select_group_ui(
id,
params,
label = NULL,
btn_reset_label = "Reset filters",
inline = TRUE,
vs_args = list()
)
select_group_server(id, data_r, vars_r)
Arguments
id |
Module's id. |
params |
A list of parameters passed to each
|
label |
Character, global label on top of all labels. |
btn_reset_label |
Character, reset button label. If |
inline |
If |
vs_args |
Arguments passed to all |
data_r |
Either a |
vars_r |
character, columns to use to create filters,
must correspond to variables listed in |
Value
A shiny::reactive()
function containing data filtered with an attribute inputs
containing a named list of selected inputs.
Examples
# Default -----------------------------------------------------------------
library(shiny)
library(datamods)
library(shinyWidgets)
ui <- fluidPage(
# theme = bslib::bs_theme(version = 5L),
fluidRow(
column(
width = 10, offset = 1,
tags$h3("Filter data with select group module"),
shinyWidgets::panel(
select_group_ui(
id = "my-filters",
params = list(
list(inputId = "Manufacturer", label = "Manufacturer:"),
list(inputId = "Type", label = "Type:"),
list(inputId = "AirBags", label = "AirBags:"),
list(inputId = "DriveTrain", label = "DriveTrain:")
), vs_args = list(disableSelectAll = FALSE)
),
status = "primary"
),
reactable::reactableOutput(outputId = "table"),
tags$b("Inputs values:"),
verbatimTextOutput("inputs")
)
)
)
server <- function(input, output, session) {
res_mod <- select_group_server(
id = "my-filters",
data = reactive(MASS::Cars93),
vars = reactive(c("Manufacturer", "Type", "AirBags", "DriveTrain"))
)
output$table <- reactable::renderReactable({
reactable::reactable(res_mod())
})
output$inputs <- renderPrint({
attr(res_mod(), "inputs")
})
}
if (interactive())
shinyApp(ui, server)