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)
CodePudding user response:
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)