Home > Mobile >  How to use filter in data table - Shiny - R
How to use filter in data table - Shiny - R

Time:12-06

I've this Shiny code example:

library(shiny)
library(DT)
x = read.xlsx("my_path\\2.xlsx") #my file I want to use
shinyApp(
  ui = fluidPage(
    fluidRow(
      column(12,
             DTOutput('table')
      )
    )
  ),
  
  
  server = function(input, output) {
    output$table <- renderDT(iris,
                             filter = "top",
                             options = list(
                               pageLength = 5
                             )
    )
  }
)

When I click on some filter I get a list of all the possible values:

enter image description here

But when I use my file (x), instead of iris - it doesn't work and the list doesn't open any idea how to fix it?

CodePudding user response:

Try something like this with the column you want to make searchable:

x$column <- as.factor(x$column)

The Species column in the Iris dataset is a factor; when using character columns, DT will allow you to type in possible values.

  • Related