The following problem is abstracted from a webapp I am currently working on. In the actual version, the choices for the selectInput are imported and change based on previous user Input (thats why I am using renderUI).
The problem is the following: The input box does not show a default value (it actually does not have a value, as I get error messages from the calculations based on the input, at default).
library(shiny)
test <- c('AC-50', 'AC-50', 'AC-35x2 Dual Motor', 'AC-35x2 Dual Motor')
test2 <- c('a','b','c','d')
ui <- fluidPage(
uiOutput("test")
)
server <- function(input, output){
output$test <- renderUI({
selectInput("test", "Select:", choices=test)
})
}
shinyApp(ui = ui, server = server)
A couple of further observations that arose during my attempts at troubleshooting:
- Oddly, this is only the case if choices is set to 'test'. 'test2' (random strings created for troubleshooting purposes) returns a default value
- Playing around with selected=NULL seems to have no effect
I am by no means a Shiny (or R) expert, so I might be overlooking something, but any help would be appreciated.