Shiny module for filtering data
Usage
dataFilterUI(id)
dataFilterServer(
id,
data = reactive(NULL),
hide = FALSE,
hover_text = NULL,
reset = NULL
)Arguments
- id
unique identifier for the module to prevent namespace clashes when making multiple calls to this shiny module.
- data
an array wrapped in
reactive()containing the data to be filtered.- hide
logical indicating whether the data filtering user interface should be hidden from the user, set to FALSE by default.
- hover_text
text to display on download button when user hovers cursor over button, set to NULL by default to turn off hover text.
- reset
optional reactive expression that resets the filters whenever it changes. By default filters are reset whenever
datachanges; supply a separate trigger (e.g. the data input) to keep filters active while the data is being edited.
Author
Dillon Hammill, dillon.hammill21@gmail.com
Examples
if (interactive()) {
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
dataInputUI("input1"),
dataFilterUI("filter1"),
tableOutput("data1")
)
server <- function(input,
output,
session) {
data_input <- dataInputServer("input1")
# list with slots data and rows (indices)
data_filter <- dataFilterServer("filter1",
data = data_input
)
output$data1 <- renderTable({
data_filter$data()
})
}
shinyApp(ui, server)
}