How to filter tables with advanced methods for Shiny Apps?

Hi Shiny Developers,

I wonder, what is the best way to show and filter data tables in Shiny Apps?

In order to make dynamics tables, I prefer to use DT package but, I don't like its filtering method. It is too primitive for me. Also, I looked at other table packages and their filtering methods seem similar to DT package.

Tableau has many extensions. One of them is Super Tables. It allows users interactive and dynamic Excel-like tables. I liked its structure and high capability of filtering.

https://exchange.tableau.com/en-gb/products/111

What do you do for advanced filtering in the tables in your Shiny Apps. Is there a chance to make tables like Tableau's Super Tables for filtering.

Thanks in advance.

Unfortunately, DT doesn't support the kind of advanced filtering you're referring too. However, I've built similar filters using Shiny Widgets, where the input from the widget influences the table. Here is a brief example of how a checkbox group input can be used to filter an arbitrary dataset data for column A.

library(shiny)
library(tidyverse)
library(DT)

ui <- (
   checkboxGroupInput("filter","Select:",choices=c("A","B","C")),
   DT::dataTableOutput("table")
)

server <- function(input, output, session){
  output$table <- renderDataTable({
      req(input$filter)
      dt <- filter(data, A %in% input$filter)
      dt
  })
}

shinyApp(ui, server)

This can be expanded in several ways. I generally wrap my dataframe generation in a reactive expression that is then called each time one of the filter inputs is changed. If your filter inputs are dependent on your dataframe, you can also dynamically adjust their values using update functions. For instance, the example above could use updateCheckboxGroupInput in order to dynamically adjust the options of the filter input to be the unique options of A.

I hope this helps!

1 Like

Thanks for your response @BLukomski,

I may not have been clear when I asked the question. I am sorry about that.

As you gave that example, we can add some inputs to filter the data. However, it is a specific solution, not a general solution. Especially, if the number of columns in the data is large, we can't add inputs one by one for filtering. We have to design a general and advanced filtering method about that.

While I was researching advanced filtering, I saw a great package called shinyDataFilter created by @dgkf . In my opinion, it needs some developments such as working with all data types, preventing some bugs and so on. That's why, I'm afraid of using the package at the moment. :pensive:

In addition, we can design a filtering method like the following topic. It needs to generalize for all data types too.

I'm trying to create a filtering method by looking at the examples and their logic I mentioned above. It would be difficult to generalize a filtering method likewise. :grimacing:

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.