I am trying to use a single input reactivity model that affects multiple outputs, as described in a brilliant cheat sheet. I need to use renderUI because the select list is displayed dynamically (not shown in the example) However, during initialization, selectInput returns NULL, not the default value. After this first NULL value, the input works as expected. I'm new to shine and maybe doing something wrong.
UPDATE: other controls unexpectedly return not only NULL, but also NA after initialization.
See code below. See Console Output, the first input returns NULL.
Listening on http:
NULL
chr "1"
chr "2"
chr "1"
library(shiny)
runApp(list(
ui = bootstrapPage(
fluidPage( uiOutput('ui.A') )
),
server = function(input, output){
output$ui.A = renderUI({
selectInput("A", label = h4("input A"),
choices = list(A_1=1, A_2=2),
selected = 1)
})
A.r <- reactive({input$A })
observe({
A <- A.r()
str(A)
})
}))
source
share