Learn R Programming

shinyfilters

Overview

shinyfilters makes it easy to create Shiny inputs from vectors, data.frames, and more.

  • filterInput(): Create filter inputs from any object
  • updateFilterInput(): Update filter inputs
  • serverFilterInput(): Server logic to update filter inputs
  • apply_filters(): Apply filter inputs to objects

Installation

The latest release is available on CRAN:

# install.packages("pak")
pak::pak("shinyfilters")

Or, you can install the development version:

pak::pak("joshwlivingston/shinyfilters")

Usage

Vectors

library(shinyfilters)
library(shiny)

ui <- fluidPage(
    sidebarLayout(
        sidebarPanel(
            # Create a filterInput() inside a shiny app:
            filterInput(
                x = letters,
                inputId = "letter",
                label = "Pick a letter:"
            )
        ),
        mainPanel(
            textOutput("selected_letter")
        )
    )
)
server <- function(input, output, session) {
    output$selected_letter <- renderText({
        paste("You selected:", input$letter)
    })
}
shinyApp(ui, server)

Data.frames

library(shinyfilters)

library(DT)
library(shiny)

df <- data.frame(
    x = letters,
    y = sample(c("red", "green", "blue"), 26, replace = TRUE),
    z = round(runif(26, 0, 3.5), 2),
    q = sample(Sys.Date() - 0:7, 26, replace = TRUE)
)

ui <- fluidPage(
    sidebarLayout(
        sidebarPanel(
            # 1/3. Create a filterInput() for each column in a data.frame:
            filterInput(
                x = df,
                range = TRUE,
                selectize = TRUE,
                slider = TRUE,
                multiple = TRUE
            )
        ),
        mainPanel(
            DTOutput("df_full"),
            verbatimTextOutput("input_values"),
            DTOutput("df_filt")
        )
    )
)

server <- function(input, output, session) {
    output$df_full <- renderDT(datatable(df))
    # 2/3. Create a server to manage the data.frame's filterInput()'s
    res <- serverFilterInput(
        x = df, 
        input = input, 
        range = TRUE
    )
    
    # 3/3. Use the server's results
    output$input_values <- renderPrint(res$input_values)
    output$df_filt <- renderDT(datatable(
        apply_filters(df, res$input_values)
    ))
}

shinyApp(ui, server)

Extending shinyfilters

You can extend shinyfilters by adding or overwriting methods to the following:

  • filterInput(), updateFilterInput()
  • args_filter_input()
  • get_filter_logical()

See vignette("customizing-shinyfilters") for more.

Copy Link

Version

Install

install.packages('shinyfilters')

Version

0.3.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Josh Livingston

Last Published

January 17th, 2026

Functions in shinyfilters (0.3.0)

get_input_values

Get Multiple Values from a shiny Input Object
filterInput

Create a shiny Input
serverFilterInput

Run the backend server for filterInput
apply_filters

Apply Filters to an object
call_input_function

Prepare and Evaluate Input Function and Arguments
args_filter_input

Derive Arguments for shiny Inputs
get_filter_logical

Compute a Filter Predicate
arg_name_input_generics

Determine Filter Input Argument Names
get_input_ids

Retrieve the Ids of Input Objects
updateFilterInput

Update a shiny Input
get_input_labels

Retrieve the Labels of Input Objects