The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

shinyfilters

CRAN status R-CMD-check

Overview

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

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,
                id = "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. 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. Create a server to manage the data.frame's filterInput()'s
    res <- serverFilterInput(
        x = df, 
        input = input, 
        range = TRUE
    )
    ################################################################
    
    #####################################################
    # 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:

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

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.