1

I was wondering if it's possible to have an output datatable in a R Shiny app with Excel-like filtering. More specifically, I'm looking for a way to either select all the elements in a given column but exclude a few (imagine we have 100 different values in a column and we want to exclude just 2 of them) or unselect all the values and only choose a few. In Excel we have those little square boxes that allow us to tick/untick a specific value in a column. Now, I know we have the shiny selectInput with the MULTIPLE parameter:

selectInput("select_max_mdy_rtg", label = "Max Mdy Rtg", 
                                                   choices = list("Aaa" = "aaa", "Aa1"="aa1", "Aa2"="aa2", "Aa3" = "aa3", "A1"="a1","A2"="a2","A3"="a3",
                                                                  "Baa1"="baa1","Baa2"="baa2","Baa3"="baa3","Ba1"="ba1","Ba2"="ba2","Ba3"="ba3","B1"="b1","B2"="b2","B3"="b3",
                                                                  "Caa1"="caa1","Caa2"="caa2","Caa3"="caa3","Ca"="ca","C"="c","D"="d","NR/WR/NA"="na"), 
                                                   selected = 'aaa', MULTIPLE=T)

However, this doesn't allow me to exclude just a few values. I have seen a similar question Shiny datatable filter box but the solution proposed there doesn't allow to select all the values and exclude just a few of them, plus I don't necessarily need the filters at the bottom of the table. I would need precisely what we can do in excel when filtering values in a given column. Thoughts on this? Thanks

Angelo
  • 1,594
  • 5
  • 17
  • 50

1 Answers1

1

You could try looking into PickerInput from the ShinyWidgets package

For example:

pickerInput("select_max_mdy_rtg", "Max Mdy Rtg", 
                                  choices = list("Aaa" = "aaa", "Aa1"="aa1", "Aa2"="aa2", "Aa3" = "aa3", "A1"="a1","A2"="a2","A3"="a3",
                                                 "Baa1"="baa1","Baa2"="baa2","Baa3"="baa3","Ba1"="ba1","Ba2"="ba2","Ba3"="ba3","B1"="b1","B2"="b2","B3"="b3",
                                                 "Caa1"="caa1","Caa2"="caa2","Caa3"="caa3","Ca"="ca","C"="c","D"="d","NR/WR/NA"="na"), 
                                  options = list(`actions-box` = TRUE), 
                                  multiple = TRUE)
koolmees
  • 2,725
  • 9
  • 23