My goal is to fill a value from a select input to a text input. The text input should be able to be modified by the user later. Unfortunately, my app does not work (the select is not filled) but there are no error.
ui.R
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("id",
label = "Choose a number",
choices = list()
),
textInput("txt1", "number", 0)
),
mainPanel(
)
)
))
server.R
df <- data.frame(a=c(1,2),b=c(3,4))
shinyServer(function(input, output, session) {
# fill the select input
updateSelectInput(session, "id", choices = df$a)
observe({
# When I comment this line, the select is correctly filled
updateTextInput(session, "txt1", value = df[df$a==input$id,'a'])
})
})
Any ideas of what could be wrong?