Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

In R, the default selection on my selectInput is removed once the Shiny App renders

$
0
0

I have created a basic Shiny Application using RStudio. I am using selectInput to filter the charts on my dashboard. One of the charts I created works fine, and the default selection is kept when the app loads. However, for my other chart the specified default briefly appears on loading but then disappears and leaves both the chart and selectInput empty until a filter is manually chosen.

    fluidRow(
        column(6,
            sidebarPanel(
                selectInput("indication",
                            "Indication:",
                            choices = data1$indication,
                            selected = 1))),
        column(6,
               sidebarPanel(
                   selectInput("Practice_Id",
                               "Practice ID:",
                               choices = data2$Practice_Id,
                               selected = 1)))
# relevant output below

    output$riskBarPlot <- renderPlotly({

        risk_bar_filt <- risk_bar_data %>%
            filter(Practice_Id == input$Practice_Id)

        risk_bar <- ggplot(risk_bar_filt, aes(x = Indication, y = Brier_Score)) +
            geom_bar(aes(fill = Brier_Score, stat= "identity") +
        ggplotly(risk_bar, tooltip = c("x", "y"))
    })

It is the second input in this example that doesn't work properly, I have just included the first one to show that it works correctly and there are no major differences between them. I have also tried changing it to [selected = "value I want selected by default"] but that didn't fix the bug.

Image of the dashboard once loaded:

Screenshot of the dashboard once loaded

Any help on making the default selection appear when app loads would be greatly appreciated!


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>