I have selectinput dropdown like this:
selectInput("locInput", "Location", choices=c("All","New Mexico", "Colorado", "California"))
What I want to achieve is to make selectinput by default not filter by anything, as in when "All" is selected then it should list all observations (so from California, Colorado etc.) So what I tried to do is create simple logic for this:
server <- function(input, output) {
filtered<-reactive({
shows %>%
filter(Length >= input$lenInput[1],
Length <= input$lenInput[2],
if (input$locInput != "All"){
Location==input$locInput
})
But doesnt seem to work. Any ideas what can I change in order to make it working correctly?
There wonderful
shinyWidgets
package which already has theSelect All
feature in itspickerInput
You need an else condition. Surprisingly, this works if the condition is
TRUE
, but if it isFALSE
, thenfilter
has an error since you have an empty condition. To solve this, just addelse TRUE
, which will filter no rows (sinceTRUE
isTRUE
for all rows):