I have shiny app contains multiple dynamic/conditional inputs (next input based on what I choose at previous one). For this purpose I use renderUI
.
output$input1_server <- renderUI({
validate(need(base(), "Error"))
df <- base %>%
filter(age >= 10) %>%
select(city)
selectInput(session$ns("input1"), "Input #1:",
choices = df$city,
width = "100%")
})
I also have reactive
which uses inputs as arguments for filtering, such as:
data <- reactive({
base %>%
#some filters %>%
#some manipulations %>%
#etc
})
Then I use reactive
data() to build a reactive plot
plot <- reactive({
data() %>%
ggplot( ... ) %>%
geom_bar( ... ) %>%
#etc...
})
# Rendering
output$plot_output <- renderPlot({ plot() })
The problem occurs when I change dynamic input, which causes changing of other dynamic inputs. Then error in renderPlot()
occurs, however, despite the error, in a few seconds plot appears. I am sure that error occurs because of vast number of renderUI. I tried to use sys.sleep
to give more time for function executions, but it does not work. The code is correct, because when I use it out of shiny app it works.