The Shiny documentation mentions that for selectInput():
selectedThe value (or, if none was supplied, the title) of the naviga
@Yihui Xie's answer requires selectInput(..., selectize = TRUE). If you want selectize = FALSE, you can still achieve a similar effect as follows.
This is not documented:
selectedThe initially selected value (or multiple values ifmultiple = TRUE). If not specified then defaults to the first value for single-select lists and no values for multiple select lists.
But for single-select lists if you can use selectize = FALSE, size = 4 (any non-NULL size would work), then you can set selected = FALSE to force no default selection.
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
mainPanel(
uiOutput("Choose_Molecule")
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
# First UI input (Service column) filter clientData
output$Choose_Molecule <- renderUI({
selectInput("molecule",
"Select Molecule:",
choices = rownames(mtcars),
selected = FALSE,
multiple = FALSE
, selectize = FALSE, size = 4 ##needed for `selected = FALSE` to work
)
})
}
# Run the application
shinyApp(ui = ui, server = server)