'Set selecInput to have no option selected
When running the app, you will see that Option 1 is already selected, however it is strange because in ui I inserted selected="No option selected". So what am I doing wrong?
My idea is that when running the algorithm, there is no option selected in selectInput.
Executable code below:
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fluidRow(
column(
width = 6,
selectInput("test", label = h5("Choose"),choices = list("Option1 " = "1", "Option2" = "2", selected="No option selected")),
))),
mainPanel(
)
)
)
server <- function(input, output, session) {
}
shinyApp(ui = ui, server = server)
Solution 1:[1]
One way is to put an empty string in choices:
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fluidRow(
column(
width = 6,
selectInput("test",
label = h5("Choose"),
choices = list("", "Option1 " = "1", "Option2" = "2"),
selected=NULL),
))),
mainPanel(
)
)
)
server <- function(input, output, session) {
}
shinyApp(ui = ui, server = server)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TarJae |


