I have a shiny application similar to this example, what I want is to get choices in the input without having the "all"choice. For example here, if i remove "all" all the other choices disappear and I dont want this...
For information this application is able to update the choices of inputs in function of the first inputs for example if I choose "A" in the first input, I will see only "1" in my second input choice.
@Benjamin: Yes it's this but keeping my update functionality like said with my example
Thanks in advance
library(shiny)
library(dplyr)
library(DT)
ui <- fluidPage(
titlePanel("Title"),
sidebarLayout(
sidebarPanel(width=3,
selectInput("filter1", "Filter 1", multiple = T, choices = c("All", LETTERS), selected = "All"),
selectInput("filter2", "Filter 2", multiple = T, choices = c("All", as.character(seq.int(1, length(letters), 1))),
selected = "All")
),
mainPanel(
DT::dataTableOutput("tableprint")
)
)
)
server <- function(input, output, session) {
output$tableprint <- DT::renderDataTable({
# Data
df <- tibble(Letters = LETTERS, Numbers = as.character(seq.int(1, length(letters), 1)))
# Create filters based on inputs
f1 <- if("All" %in% input$filter1) LETTERS else input$filter1
f2 <- if("All" %in% input$filter2) as.character(seq.int(1, length(letters), 1)) else input$filter2
# Filter data
filtered_df <- filter(df,
Letters %in% f1,
Numbers %in% f2)
# Update selectInput choices based on the filtered data. Update 'selected' to reflect the user input.
updateSelectInput(session, "filter1", choices = c("All", filtered_df$Letters), selected = input$filter1)
updateSelectInput(session, "filter2", choices = c("All", filtered_df$Numbers), selected = input$filter2)
datatable(filtered_df)
})
}
# Run the application
shinyApp(ui = ui, server = server)
updateSelectInputcalls seem unnecessary to me. If you take those out, do you get what you want? - Benjamin