Hello,
I have this really basic example with pickerInput
to represent my problem. I essentially only want the filter comparison to take place if not all the items are selected on the list. If all the items are selected, I simply want it to allocate data
to df
. I have a lot of filter conditions that can't all do the comparison for %in% ongoing. Any help?
library(shinyWidgets)
library(shiny)
reactiveStorage <- reactiveValues(df = NULL)
data <- data.frame(
Cat = c("a", "b", "c", "d", "a", "b", "d"),
Var1 = c(31, 20, 94, 33, 69, 43, 35),
Var2 = c(86, 23, 96, 69, 26, 51, 93),
Var3 = c(4, 43, 91, 47, 86, 76, 80),
Var4 = c(20, 23, 72, 70, 35, 96, 37),
Var5 = c(64, 31, 56, 64, 36, 77, 55)
)
ui <- fluidPage(
pickerInput(
inputId = "somefiltervalue",
label = "A label",
choices = c("a", "b","c","d"),
selected = c(1,2,3,4),
multiple = TRUE,
options = list(`actions-box` = TRUE)
),
actionButton("compare","Filter"),
tableOutput("value")
)
server <- function(input, output) {
output$value <- renderTable({
req(input$compare)
df <- data %>% filter(Cat %in%(input$somefiltervalue))
})
}
shinyApp(ui, server)
Created on 2020-10-07 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0)